Remove support for "remove after notify" on moderation
authorMagnus Hagander <magnus@hagander.net>
Wed, 20 Dec 2017 12:58:17 +0000 (13:58 +0100)
committerMagnus Hagander <magnus@hagander.net>
Wed, 20 Dec 2017 12:58:17 +0000 (13:58 +0100)
This broke when we had ManyToMany relations on a record. We didn't use
to have that, but with tags for news we now do. With this change, the
"reject with a notice" becomes a two step operation, the first one
adding the notification and the second one doing the removal. That'll
have to do for now, and at some point in the future we may create a
completely separate (non /admin/) workflow for moderation and fix it
that way.

pgweb/util/admin.py
templates/admin/change_form_pgweb.html

index aff1c2f07a20341aca1d6d644627c22c1506d394..60a5f00d31281c1770ce9f7cd68fb9457899d5b6 100644 (file)
@@ -72,8 +72,7 @@ class PgwebAdmin(admin.ModelAdmin):
                                n.save()
 
                                # Now send an email too
-                               msgstr = _get_notification_text(request.POST.has_key('remove_after_notify'),
-                                                                                               obj,
+                               msgstr = _get_notification_text(obj,
                                                                                                request.POST['new_notification'])
 
                                send_simple_mail(settings.NOTIFICATION_FROM,
@@ -85,17 +84,11 @@ class PgwebAdmin(admin.ModelAdmin):
                                send_simple_mail(settings.NOTIFICATION_FROM,
                                                                 settings.NOTIFICATION_EMAIL,
                                                                 "Moderation comment on %s %s" % (obj.__class__._meta.verbose_name, obj.id),
-                                                                _get_moderator_notification_text(request.POST.has_key('remove_after_notify'),
-                                                                                                                                 obj,
+                                                                _get_moderator_notification_text(obj,
                                                                                                                                  request.POST['new_notification'],
                                                                                                                                  request.user.username
                                                                                                                          ))
 
-                               if request.POST.has_key('remove_after_notify'):
-                                       # Object should not be saved, it should be deleted
-                                       obj.delete()
-                                       return
-
 
                # Either no notifications, or done with notifications
                super(PgwebAdmin, self).save_model(request, obj, form, change)
@@ -105,17 +98,9 @@ def register_pgwebadmin(model):
        admin.site.register(model, PgwebAdmin)
 
 
-def _get_notification_text(remove, obj, txt):
+def _get_notification_text(obj, txt):
        objtype = obj.__class__._meta.verbose_name
-       if remove:
-               return """You recently submitted a %s to postgresql.org.
-
-This submission has been rejected by a moderator, with the following comment:
-
-%s
-""" % (objtype, txt)
-       else:
-               return """You recently submitted a %s to postgresql.org.
+       return """You recently submitted a %s to postgresql.org.
 
 During moderation, this item has received comments that need to be
 addressed before it can be approved. The comment given by the moderator is:
@@ -128,15 +113,13 @@ request, and your submission will be re-moderated.
 
 
 
-def _get_moderator_notification_text(remove, obj, txt, moderator):
+def _get_moderator_notification_text(obj, txt, moderator):
        return """Moderator %s made a comment to a pending object:
 Object type: %s
 Object id: %s
 Comment: %s
-Delete after comment: %s
 """ % (moderator,
           obj.__class__._meta.verbose_name,
           obj.id,
           txt,
-          remove and "Yes" or "No",
           )
index 61accc4404c4d9135677881b9fd646d8df54f364..4dcc115d8f4fc7edf62de084565c0ba31b3a925c 100644 (file)
@@ -36,7 +36,8 @@ Note that the summary field can use
 <p>
 {%if original.org.email%}
 New notification: <input type="text" name="new_notification" style="width:400px;" /> (<b>Note!</b> This comment is emailed to the organization!)<br/>
-<input type="checkbox" name="remove_after_notify">Delete after notification</>
+To send a notification on rejection, first add the notification above and hit
+"Save and continue editing". Then as a separate step, delete the record.
 {%else%}
 Organisation has <b>no email</b>, so cannot send notifications to it!
 {%endif%}