Send moderation notice to moderators even when no changes are made
authorMagnus Hagander <magnus@hagander.net>
Sun, 17 Jan 2021 15:17:57 +0000 (16:17 +0100)
committerMagnus Hagander <magnus@hagander.net>
Sun, 17 Jan 2021 15:20:43 +0000 (16:20 +0100)
When a moderation notice was sent without making any actual state
changse (so not approving, rejecting or returning), the notice would
only be sent to the submitter, and not to the moderators. Which
obviously can lead to some confusion. So make sure that it's always sent
there as well, and the message clearly states that it was just a
comment.

pgweb/core/views.py

index dd9be63616241077a10f2fa2e61ef219103c62c3..5edcadfaaa7d4140ecfdb974d47d4a3c2d6f46f1 100644 (file)
@@ -364,7 +364,15 @@ def _send_moderation_message(request, obj, message, notice, what):
         )
 
     # Send notification to admins
+    if obj.twomoderators and obj.firstmoderator:
+        # For two-moderator objects, only one is required to reject or send back for editing. In that case,
+        # just log the current user who is the one that did that.
+        modname = "{} and {}".format(obj.firstmoderator, request.user)
+    else:
+        modname = request.user
+
     if what:
+        # If an actual change happened, notify of that
         admmsg = message
         if obj.is_approved:
             admmsg += "\n\nNOTE! This {} was previously approved!!".format(obj._meta.verbose_name)
@@ -376,17 +384,22 @@ def _send_moderation_message(request, obj, message, notice, what):
             # No point in sending an edit link to a page that doesn't exist anymore
             admmsg += "\n\nEdit at: {}/admin/_moderate/{}/{}/\n".format(settings.SITE_ROOT, obj._meta.model_name, obj.id)
 
-        if obj.twomoderators and obj.firstmoderator:
-            # For two-moderator objects, only one is required to reject or send back for editing. In that case,
-            # just log the current user who is the one that did that.
-            modname = "{} and {}".format(obj.firstmoderator, request.user)
-        else:
-            modname = request.user
-
         send_simple_mail(settings.NOTIFICATION_FROM,
                          settings.NOTIFICATION_EMAIL,
                          "{} '{}' {} by {}".format(obj._meta.verbose_name.capitalize(), obj.title, what, modname),
                          admmsg)
+    elif notice:
+        # There was no change, but there was a moderation notice. We still want to inform the moderators that this happened
+        admmsg = "No changes were made, but the following notice was sent:\n{}\n\nEdit at: {}/admin/_moderate/{}/{}/\n".format(
+            notice,
+            settings.SITE_ROOT,
+            obj._meta.model_name,
+            obj.id,
+        )
+        send_simple_mail(settings.NOTIFICATION_FROM,
+                         settings.NOTIFICATION_EMAIL,
+                         "Moderation notice on '{}' {} by {}".format(obj._meta.verbose_name.capitalize(), obj.title, modname),
+                         admmsg)
 
 
 # Moderate a single item