From ed720adbc5322460f417d4f8d6845183460d27e0 Mon Sep 17 00:00:00 2001 From: Evert Date: Thu, 1 Mar 2018 19:36:34 +0200 Subject: [PATCH] Delete reply contents and add ban button to replies --- Discussions/templates/board.html | 17 +++++++++++++++++ Discussions/urls.py | 1 + Discussions/views.py | 11 +++++++++++ 3 files changed, 29 insertions(+) diff --git a/Discussions/templates/board.html b/Discussions/templates/board.html index 89cd053..2207024 100644 --- a/Discussions/templates/board.html +++ b/Discussions/templates/board.html @@ -33,6 +33,15 @@

Created {{board.timestamp}} by {{board.user.display_name}}

{% for reply in replies %}
+ {% if reply.deleted %} +

This reply has been deleted by a moderator.

+ ID: {{reply.pk}} + {% if "can_moderate_board" in show_perms or board.user == user %} +
{{reply.body}}
+ Restore + {% endif %} +
+ {% else %}
@@ -42,7 +51,14 @@

Submitted {{board.timestamp}}

{{reply.body|markdown|safe}}
+ {% if user.is_authenticated %} + {% if "can_moderate_board" in show_perms or board.user == user %} + Delete Content + Ban + {% else %} + {% endif %} + {% endif %}
{% csrf_token %} @@ -61,6 +77,7 @@
+ {% endif %}
{% empty %}

Nobody has replied to this board!

diff --git a/Discussions/urls.py b/Discussions/urls.py index f11fab9..a0b8179 100644 --- a/Discussions/urls.py +++ b/Discussions/urls.py @@ -24,6 +24,7 @@ urlpatterns = [ url(r'^board/new$', views.BoardForm), url(r'^board/report/(?P\d{1,4})/?$', views.ReportForm), url(r'^board/pin/(?P\d{1,4})/?$', views.BoardPin), + url(r'^board/delete/reply/(?P\d{1,4})/?$', views.BoardDeleteReply), url(r'^board/delete/(?P\d{1,4})/?$', views.BoardDelete), url(r'^board/lock/(?P\d{1,4})/?$', views.BoardLock), url(r'^board/reply/(?P\d{1,4})/?$', views.BoardReplyForm), diff --git a/Discussions/views.py b/Discussions/views.py index e523363..ebb8d79 100644 --- a/Discussions/views.py +++ b/Discussions/views.py @@ -382,3 +382,14 @@ def BoardDelete(req, abbr, bid): DiscussionBoard.objects.filter(pk=board.pk).delete() return HttpResponseRedirect('%s/discuss' % (showurl)) + +@permission_required_or_403('LandingPage.can_moderate_board', (Show, 'abbr', 'abbr'), accept_global_perms=True) +def BoardDeleteReply(req, abbr, rid): + reply = get_object_or_404(DiscussionReply, pk=rid) + showurl = get_show_url(abbr) + + delete = not reply.deleted + + DiscussionReply.objects.filter(pk=reply.pk).update(deleted=delete) + + return HttpResponseRedirect('%s/discuss/board/%d-%s'%(showurl, reply.board.pk, slugify(reply.board.title)))