Repository: django-wiki/django-wiki

Issue:
Plugins notifications problem
When I tried to make my own plugin for my personal project I come accross notification issue when saving an attachment. By debuging. I look into the code that send the notification and think that there is the following issue in **src/wiki/plugins/notifications/apps.py**
```
def ready(self):

    ...

    for plugin in registry.get_plugins():

        notifications = getattr(plugin, "notifications", [])
        for notification_dict in notifications:

            @disable_signal_for_loaddata
            def plugin_notification(instance, **kwargs):

                ... #here when plugin_notification is called the value of notification_dict is the same that at the end of ready()

            signals.post_save.connect(
                plugin_notification, sender=notification_dict["model"]
            )
```
The receiver is called with the configuration of the last notifications add, that doesn't cause much problem since the notifications of _attachments_ and _images_ are almost the same.


Discussion:

Resolving patch:
diff --git a/src/wiki/plugins/notifications/apps.py b/src/wiki/plugins/notifications/apps.py
--- a/src/wiki/plugins/notifications/apps.py
+++ b/src/wiki/plugins/notifications/apps.py
@@ -17,33 +17,36 @@ def ready(self):
         from wiki.decorators import disable_signal_for_loaddata
         from . import models
 
+        def get_receiver(notification_dict):
+            @disable_signal_for_loaddata
+            def plugin_notification(instance, **kwargs):
+                if notification_dict.get("ignore", lambda x: False)(instance):
+                    return
+                if kwargs.get("created", False) == notification_dict.get(
+                    "created", True
+                ):
+                    if "get_url" in notification_dict:
+                        url = notification_dict["get_url"](instance)
+                    else:
+                        url = models.default_url(
+                            notification_dict["get_article"](instance)
+                        )
+
+                    message = notification_dict["message"](instance)
+                    notify(
+                        message,
+                        notification_dict["key"],
+                        target_object=notification_dict["get_article"](instance),
+                        url=url,
+                    )
+
+            return plugin_notification
+
         for plugin in registry.get_plugins():
 
             notifications = getattr(plugin, "notifications", [])
             for notification_dict in notifications:
 
-                @disable_signal_for_loaddata
-                def plugin_notification(instance, **kwargs):
-                    if notification_dict.get("ignore", lambda x: False)(instance):
-                        return
-                    if kwargs.get("created", False) == notification_dict.get(
-                        "created", True
-                    ):
-                        if "get_url" in notification_dict:
-                            url = notification_dict["get_url"](instance)
-                        else:
-                            url = models.default_url(
-                                notification_dict["get_article"](instance)
-                            )
-
-                        message = notification_dict["message"](instance)
-                        notify(
-                            message,
-                            notification_dict["key"],
-                            target_object=notification_dict["get_article"](instance),
-                            url=url,
-                        )
-
                 signals.post_save.connect(
-                    plugin_notification, sender=notification_dict["model"]
+                    get_receiver(notification_dict), sender=notification_dict["model"]
                 )


Test patch: