prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Initiator dashboard: too many notification
  I get notifications of any projects of my organization, even it's not my project. I'm not sure if I want to see all changes in all projects of my organization. I think it will be too much.
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `apps/notifications/signals.py`
  Content:
  ```
  1 from django.db.models import signals
  2 from django.dispatch import receiver
  3 
  4 from adhocracy4.actions.models import Action
  5 from adhocracy4.actions.verbs import Verbs
  6 from adhocracy4.follows.models import Follow
  7 from adhocracy4.phases.models import Phase
  8 from adhocracy4.projects.models import Project
  9 from apps.organisations.models import Organisation
  10 from . import emails
  11 
  12 
  13 @receiver(signals.post_save, sender=Action)
  14 def send_notifications(instance, created, **kwargs):
  15     action = instance
  16     verb = Verbs(action.verb)
  17 
  18     if verb == Verbs.CREATE or verb == Verbs.ADD:
  19         emails.NotifyCreatorEmail.send(action)
  20 
  21         if action.project:
  22             emails.NotifyModeratorsEmail.send(action)
  23             emails.NotifyFollowersOnNewItemCreated.send(action)
  24 
  25     elif verb == Verbs.SCHEDULE:
  26         if isinstance(action.obj, Phase):
  27             emails.NotifyFollowersOnPhaseIsOverSoonEmail.send(action)
  28 
  29 
  30 @receiver(signals.m2m_changed, sender=Project.moderators.through)
  31 def autofollow_project_moderators(instance, action, pk_set, reverse, **kwargs):
  32     if action == 'post_add':
  33         if not reverse:
  34             project = instance
  35             users_pks = pk_set
  36 
  37             for user_pk in users_pks:
  38                 Follow.objects.update_or_create(
  39                     project=project,
  40                     creator_id=user_pk,
  41                     defaults={
  42                         'enabled': True
  43                     }
  44                 )
  45         else:
  46             user = instance
  47             project_pks = pk_set
  48 
  49             for project_pk in project_pks:
  50                 Follow.objects.update_or_create(
  51                     project_id=project_pk,
  52                     creator_id=user,
  53                     defaults={
  54                         'enabled': True
  55                     }
  56                 )
  57 
  58 
  59 @receiver(signals.m2m_changed, sender=Organisation.initiators.through)
  60 def autofollow_organisation_initiators(instance, action, pk_set, reverse,
  61                                        **kwargs):
  62     if action == 'post_add':
  63         if not reverse:
  64             organisation = instance
  65             users_pks = pk_set
  66 
  67             for project in Project.objects.filter(organisation=organisation):
  68                 for user_pk in users_pks:
  69                     Follow.objects.update_or_create(
  70                         project=project,
  71                         creator_id=user_pk,
  72                         defaults={
  73                             'enabled': True
  74                         }
  75                     )
  76         else:
  77             user = instance
  78             organisation_pk_set = pk_set
  79 
  80             for project in Project.objects.filter(
  81                     organisation_id__in=organisation_pk_set):
  82                 Follow.objects.update_or_create(
  83                     project=project,
  84                     creator=user,
  85                     defaults={
  86                         'enabled': True
  87                     }
  88                 )
  89 
  90 
  91 @receiver(signals.post_save)
  92 def autofollow_organisation_initiators_new_projects(sender, instance, created,
  93                                                     **kwargs):
  94     if issubclass(sender, Project):
  95         # we have to check if the senders inherits from Project to catch
  96         # signals from external projects and bplans
  97         project = instance
  98         if created:
  99             for user in project.organisation.initiators.all():
  100                 Follow.objects.update_or_create(
  101                     project=project,
  102                     creator=user,
  103                     defaults={
  104                         'enabled': True
  105                     }
  106                 )
  107
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/apps/notifications/signals.py b/apps/notifications/signals.py
  --- a/apps/notifications/signals.py
  +++ b/apps/notifications/signals.py
  @@ -6,7 +6,6 @@
   from adhocracy4.follows.models import Follow
   from adhocracy4.phases.models import Phase
   from adhocracy4.projects.models import Project
  -from apps.organisations.models import Organisation
   from . import emails
   
   
  @@ -54,53 +53,3 @@
                           'enabled': True
                       }
                   )
  -
  -
  -@receiver(signals.m2m_changed, sender=Organisation.initiators.through)
  -def autofollow_organisation_initiators(instance, action, pk_set, reverse,
  -                                       **kwargs):
  -    if action == 'post_add':
  -        if not reverse:
  -            organisation = instance
  -            users_pks = pk_set
  -
  -            for project in Project.objects.filter(organisation=organisation):
  -                for user_pk in users_pks:
  -                    Follow.objects.update_or_create(
  -                        project=project,
  -                        creator_id=user_pk,
  -                        defaults={
  -                            'enabled': True
  -                        }
  -                    )
  -        else:
  -            user = instance
  -            organisation_pk_set = pk_set
  -
  -            for project in Project.objects.filter(
  -                    organisation_id__in=organisation_pk_set):
  -                Follow.objects.update_or_create(
  -                    project=project,
  -                    creator=user,
  -                    defaults={
  -                        'enabled': True
  -                    }
  -                )
  -
  -
  -@receiver(signals.post_save)
  -def autofollow_organisation_initiators_new_projects(sender, instance, created,
  -                                                    **kwargs):
  -    if issubclass(sender, Project):
  -        # we have to check if the senders inherits from Project to catch
  -        # signals from external projects and bplans
  -        project = instance
  -        if created:
  -            for user in project.organisation.initiators.all():
  -                Follow.objects.update_or_create(
  -                    project=project,
  -                    creator=user,
  -                    defaults={
  -                        'enabled': True
  -                    }
  -                )
  
verification_info: {"golden_diff": "diff --git a/apps/notifications/signals.py b/apps/notifications/signals.py\n--- a/apps/notifications/signals.py\n+++ b/apps/notifications/signals.py\n@@ -6,7 +6,6 @@\n from adhocracy4.follows.models import Follow\n from adhocracy4.phases.models import Phase\n from adhocracy4.projects.models import Project\n-from apps.organisations.models import Organisation\n from . import emails\n \n \n@@ -54,53 +53,3 @@\n                         'enabled': True\n                     }\n                 )\n-\n-\n-@receiver(signals.m2m_changed, sender=Organisation.initiators.through)\n-def autofollow_organisation_initiators(instance, action, pk_set, reverse,\n-                                       **kwargs):\n-    if action == 'post_add':\n-        if not reverse:\n-            organisation = instance\n-            users_pks = pk_set\n-\n-            for project in Project.objects.filter(organisation=organisation):\n-                for user_pk in users_pks:\n-                    Follow.objects.update_or_create(\n-                        project=project,\n-                        creator_id=user_pk,\n-                        defaults={\n-                            'enabled': True\n-                        }\n-                    )\n-        else:\n-            user = instance\n-            organisation_pk_set = pk_set\n-\n-            for project in Project.objects.filter(\n-                    organisation_id__in=organisation_pk_set):\n-                Follow.objects.update_or_create(\n-                    project=project,\n-                    creator=user,\n-                    defaults={\n-                        'enabled': True\n-                    }\n-                )\n-\n-\n-@receiver(signals.post_save)\n-def autofollow_organisation_initiators_new_projects(sender, instance, created,\n-                                                    **kwargs):\n-    if issubclass(sender, Project):\n-        # we have to check if the senders inherits from Project to catch\n-        # signals from external projects and bplans\n-        project = instance\n-        if created:\n-            for user in project.organisation.initiators.all():\n-                Follow.objects.update_or_create(\n-                    project=project,\n-                    creator=user,\n-                    defaults={\n-                        'enabled': True\n-                    }\n-                )\n", "issue": "Initiator dashboard: too many notification\nI get notifications of any projects of my organization, even it's not my project. I'm not sure if I want to see all changes in all projects of my organization. I think it will be too much.\n", "before_files": [{"content": "from django.db.models import signals\nfrom django.dispatch import receiver\n\nfrom adhocracy4.actions.models import Action\nfrom adhocracy4.actions.verbs import Verbs\nfrom adhocracy4.follows.models import Follow\nfrom adhocracy4.phases.models import Phase\nfrom adhocracy4.projects.models import Project\nfrom apps.organisations.models import Organisation\nfrom . import emails\n\n\n@receiver(signals.post_save, sender=Action)\ndef send_notifications(instance, created, **kwargs):\n    action = instance\n    verb = Verbs(action.verb)\n\n    if verb == Verbs.CREATE or verb == Verbs.ADD:\n        emails.NotifyCreatorEmail.send(action)\n\n        if action.project:\n            emails.NotifyModeratorsEmail.send(action)\n            emails.NotifyFollowersOnNewItemCreated.send(action)\n\n    elif verb == Verbs.SCHEDULE:\n        if isinstance(action.obj, Phase):\n            emails.NotifyFollowersOnPhaseIsOverSoonEmail.send(action)\n\n\n@receiver(signals.m2m_changed, sender=Project.moderators.through)\ndef autofollow_project_moderators(instance, action, pk_set, reverse, **kwargs):\n    if action == 'post_add':\n        if not reverse:\n            project = instance\n            users_pks = pk_set\n\n            for user_pk in users_pks:\n                Follow.objects.update_or_create(\n                    project=project,\n                    creator_id=user_pk,\n                    defaults={\n                        'enabled': True\n                    }\n                )\n        else:\n            user = instance\n            project_pks = pk_set\n\n            for project_pk in project_pks:\n                Follow.objects.update_or_create(\n                    project_id=project_pk,\n                    creator_id=user,\n                    defaults={\n                        'enabled': True\n                    }\n                )\n\n\n@receiver(signals.m2m_changed, sender=Organisation.initiators.through)\ndef autofollow_organisation_initiators(instance, action, pk_set, reverse,\n                                       **kwargs):\n    if action == 'post_add':\n        if not reverse:\n            organisation = instance\n            users_pks = pk_set\n\n            for project in Project.objects.filter(organisation=organisation):\n                for user_pk in users_pks:\n                    Follow.objects.update_or_create(\n                        project=project,\n                        creator_id=user_pk,\n                        defaults={\n                            'enabled': True\n                        }\n                    )\n        else:\n            user = instance\n            organisation_pk_set = pk_set\n\n            for project in Project.objects.filter(\n                    organisation_id__in=organisation_pk_set):\n                Follow.objects.update_or_create(\n                    project=project,\n                    creator=user,\n                    defaults={\n                        'enabled': True\n                    }\n                )\n\n\n@receiver(signals.post_save)\ndef autofollow_organisation_initiators_new_projects(sender, instance, created,\n                                                    **kwargs):\n    if issubclass(sender, Project):\n        # we have to check if the senders inherits from Project to catch\n        # signals from external projects and bplans\n        project = instance\n        if created:\n            for user in project.organisation.initiators.all():\n                Follow.objects.update_or_create(\n                    project=project,\n                    creator=user,\n                    defaults={\n                        'enabled': True\n                    }\n                )\n", "path": "apps/notifications/signals.py"}], "after_files": [{"content": "from django.db.models import signals\nfrom django.dispatch import receiver\n\nfrom adhocracy4.actions.models import Action\nfrom adhocracy4.actions.verbs import Verbs\nfrom adhocracy4.follows.models import Follow\nfrom adhocracy4.phases.models import Phase\nfrom adhocracy4.projects.models import Project\nfrom . import emails\n\n\n@receiver(signals.post_save, sender=Action)\ndef send_notifications(instance, created, **kwargs):\n    action = instance\n    verb = Verbs(action.verb)\n\n    if verb == Verbs.CREATE or verb == Verbs.ADD:\n        emails.NotifyCreatorEmail.send(action)\n\n        if action.project:\n            emails.NotifyModeratorsEmail.send(action)\n            emails.NotifyFollowersOnNewItemCreated.send(action)\n\n    elif verb == Verbs.SCHEDULE:\n        if isinstance(action.obj, Phase):\n            emails.NotifyFollowersOnPhaseIsOverSoonEmail.send(action)\n\n\n@receiver(signals.m2m_changed, sender=Project.moderators.through)\ndef autofollow_project_moderators(instance, action, pk_set, reverse, **kwargs):\n    if action == 'post_add':\n        if not reverse:\n            project = instance\n            users_pks = pk_set\n\n            for user_pk in users_pks:\n                Follow.objects.update_or_create(\n                    project=project,\n                    creator_id=user_pk,\n                    defaults={\n                        'enabled': True\n                    }\n                )\n        else:\n            user = instance\n            project_pks = pk_set\n\n            for project_pk in project_pks:\n                Follow.objects.update_or_create(\n                    project_id=project_pk,\n                    creator_id=user,\n                    defaults={\n                        'enabled': True\n                    }\n                )\n", "path": "apps/notifications/signals.py"}]}