diff --git a/src/postorius/static/postorius/js/held_messages.js b/src/postorius/static/postorius/js/held_messages.js index 9f7aaec..88e7d03 100644 --- a/src/postorius/static/postorius/js/held_messages.js +++ b/src/postorius/static/postorius/js/held_messages.js @@ -8,6 +8,7 @@ url: rest_url + msgid, success: function(data) { $('#msg-title').html(data.subject); + $('.modal-footer form input[name="msgid"]').attr('value', msgid); $('#held-stripped-message').html(data.stripped_msg.replace(/\n/g, "
")); $('#held-full-message').html(data.msg.replace(/\n/g, "
")); $('#held-messages-modal').modal('show'); diff --git a/src/postorius/templates/postorius/lists/held_messages.html b/src/postorius/templates/postorius/lists/held_messages.html index 5543b11..651416b 100644 --- a/src/postorius/templates/postorius/lists/held_messages.html +++ b/src/postorius/templates/postorius/lists/held_messages.html @@ -23,11 +23,13 @@ - - @@ -36,14 +38,14 @@ - {% for msg in held_messages %} - + - {% endfor %} @@ -82,10 +78,21 @@ diff --git a/src/postorius/urls.py b/src/postorius/urls.py index 0b7bf66..b386bcc 100644 --- a/src/postorius/urls.py +++ b/src/postorius/urls.py @@ -51,16 +51,10 @@ url(r'^mass_removal/$', list_views.ListMassRemovalView.as_view(), name='mass_removal'), url(r'^delete$', list_views.list_delete, name='list_delete'), - url(r'^held_messages/(?P[^/]+)/accept$', - list_views.accept_held_message, name='accept_held_message'), - url(r'^held_messages/(?P[^/]+)/discard$', - list_views.discard_held_message, name='discard_held_message'), - url(r'^held_messages/(?P[^/]+)/defer$', - list_views.defer_held_message, name='defer_held_message'), - url(r'^held_messages/(?P[^/]+)/reject$', - list_views.reject_held_message, name='reject_held_message'), url(r'^held_messages$', list_views.list_moderation, name='list_held_messages'), + url(r'^held_messages/moderate$', list_views.moderate_held_message, + name='moderate_held_message'), url(r'^bans/$', list_views.list_bans, name='list_bans'), url(r'^header-matches/$', list_views.list_header_matches, name='list_header_matches'), @@ -106,6 +100,8 @@ url(r'^users/address_activation/(?P[A-Za-z0-9]+)/$', user_views.address_activation_link, name='address_activation_link'), - url(r'^api/list/(?P[^/]+)/held_message/$', rest_views.get_held_message, name='uncomplete_rest_held_message'), - url(r'^api/list/(?P[^/]+)/held_message/(?P\d+)/$', rest_views.get_held_message, name='rest_held_message'), + url(r'^api/list/(?P[^/]+)/held_message/$', + rest_views.get_held_message, name='uncomplete_rest_held_message'), + url(r'^api/list/(?P[^/]+)/held_message/(?P\d+)/$', + rest_views.get_held_message, name='rest_held_message'), ] diff --git a/src/postorius/views/list.py b/src/postorius/views/list.py index 6851acd..ec6a659 100644 --- a/src/postorius/views/list.py +++ b/src/postorius/views/list.py @@ -421,6 +421,28 @@ @login_required +@list_moderator_required +def moderate_held_message(request, list_id): + if request.method != 'POST': + return HttpReponseNotAllowed(['POST',]) + msg_id = request.POST['msgid'] + try: + mailing_list = List.objects.get_or_404(fqdn_listname=list_id) + if 'accept' in request.POST: + mailing_list.accept_message(msg_id) + messages.success(request, _('The message was accepted')) + elif 'reject' in request.POST: + mailing_list.reject_message(msg_id) + messages.success(request, _('The message was rejected')) + elif 'discard' in request.POST: + mailing_list.discard_message(msg_id) + messages.success(request, _('The message was discarded')) + except MailmanApiError: + return utils.render_api_error(request) + + return redirect('list_held_messages', list_id) + +@login_required @list_owner_required def csv_view(request, list_id): """Export all the subscriber in csv @@ -544,74 +566,6 @@ @login_required @list_moderator_required -def accept_held_message(request, list_id, msg_id): - """Accepts a held message. - """ - try: - the_list = List.objects.get_or_404(fqdn_listname=list_id) - the_list.accept_message(msg_id) - except MailmanApiError: - return utils.render_api_error(request) - except HTTPError as e: - messages.error(request, e.msg) - return redirect('list_held_messages', the_list.list_id) - messages.success(request, _('The message has been accepted.')) - return redirect('list_held_messages', the_list.list_id) - - -@login_required -@list_moderator_required -def discard_held_message(request, list_id, msg_id): - """Discards a held message. - """ - try: - the_list = List.objects.get_or_404(fqdn_listname=list_id) - the_list.discard_message(msg_id) - except MailmanApiError: - return utils.render_api_error(request) - except HTTPError as e: - messages.error(request, e.msg) - return redirect('list_held_messages', the_list.list_id) - messages.success(request, _('The message has been discarded.')) - return redirect('list_held_messages', the_list.list_id) - - -@login_required -@list_moderator_required -def defer_held_message(request, list_id, msg_id): - """Defers a held message for a later decision. - """ - try: - the_list = List.objects.get_or_404(fqdn_listname=list_id) - the_list.defer_message(msg_id) - except MailmanApiError: - return utils.render_api_error(request) - except HTTPError as e: - messages.error(request, e.msg) - return redirect('list_held_messages', the_list.list_id) - messages.success(request, _('The message has been deferred.')) - return redirect('list_held_messages', the_list.list_id) - - -@login_required -@list_moderator_required -def reject_held_message(request, list_id, msg_id): - """Rejects a held message. - """ - try: - the_list = List.objects.get_or_404(fqdn_listname=list_id) - the_list.reject_message(msg_id) - except MailmanApiError: - return utils.render_api_error(request) - except HTTPError as e: - messages.error(request, e.msg) - return redirect('list_held_messages', the_list.list_id) - messages.success(request, _('The message has been rejected.')) - return redirect('list_held_messages', the_list.list_id) - - -@login_required -@list_moderator_required def list_subscription_requests(request, list_id): """Shows a list of held messages. """
{% trans 'Perform action on selected messages' %} - - - + +
{% trans 'Perform action on selected messages' %}
+
+ + + +
{% trans 'Sender' %} {% trans 'Reason' %} {% trans 'Hold Date' %}
{{ msg.subject }}{{ msg.subject }} + {{ msg.sender }} {% if msg.reasons %} @@ -55,12 +57,6 @@ {% endif %} {{ msg.hold_date }} - {% trans 'View' %} - {% trans 'Accept' %} - {% trans 'Reject' %} - {% trans 'Discard' %} -