Don't send notifications for new objects that are tri-state moderation
authorMagnus Hagander <magnus@hagander.net>
Thu, 10 Sep 2020 18:47:19 +0000 (20:47 +0200)
committerMagnus Hagander <magnus@hagander.net>
Thu, 10 Sep 2020 18:47:19 +0000 (20:47 +0200)
These will get a notification when they are explicitly submitted for
moderation, so there is no point in having a separate notice sent when
they're created, since there is nothing for the moderators to do at that
point.

pgweb/util/helpers.py

index f594ea164b02d248fb2eb0cbbf89d6972f7194b0..d34d7e08717fe3e3b9e558391ba94f182b06b586 100644 (file)
@@ -80,8 +80,14 @@ def simple_form(instancetype, itemid, request, formclass, formtemplate='base/for
             # bother notifying about the changes. But if it lacks this field, we notify
             # about everything, as well as if the field exists and the item has already
             # been approved.
-            # Newly added objects are always notified.
-            if not is_new:
+            # Newly added objects are always notified if they are two-state, but not if they
+            # are tri-state (in which case they get notified when submitted for
+            # moderation).
+            if is_new:
+                if hasattr(instance, 'modstate'):
+                    # Tri-state indicated by the existence of the modstate field
+                    do_notify = False
+            else:
                 if hasattr(instance, 'approved'):
                     if not getattr(instance, 'approved', True):
                         do_notify = False