Delete reply contents and add ban button to replies

This commit is contained in:
Evert Prants 2018-03-01 19:36:34 +02:00
parent d006598fe6
commit ed720adbc5
Signed by: evert
GPG Key ID: 1688DA83D222D0B5
3 changed files with 29 additions and 0 deletions

View File

@ -33,6 +33,15 @@
<p class="timestamp text-muted font-weight-light">Created {{board.timestamp}} by {{board.user.display_name}}</p> <p class="timestamp text-muted font-weight-light">Created {{board.timestamp}} by {{board.user.display_name}}</p>
{% for reply in replies %} {% for reply in replies %}
<div class="reply border-bottom mb-4" id="reply-{{forloop.counter}}"> <div class="reply border-bottom mb-4" id="reply-{{forloop.counter}}">
{% if reply.deleted %}
<h3 class="font-weight-light">This reply has been deleted by a moderator.</h1>
<span class="font-weight-light text-muted">ID: {{reply.pk}}</span>
{% if "can_moderate_board" in show_perms or board.user == user %}
<div class="alert alert-warning"><div class="font-weight-light">{{reply.body}}</div></div>
<a href="{{showurl}}/discuss/board/delete/reply/{{reply.id}}" class="btn btn-warning ml-1">Restore</a>
{% endif %}
<div class="w-100 mb-4"></div>
{% else %}
<div class="row"> <div class="row">
<div class="avatar"> <div class="avatar">
<img src="https://icynet.eu/api/avatar/{{reply.user.icy_id}}" class="m-auto d-block"> <img src="https://icynet.eu/api/avatar/{{reply.user.icy_id}}" class="m-auto d-block">
@ -42,7 +51,14 @@
<p class="timestamp text-muted font-weight-light">Submitted {{board.timestamp}}</p> <p class="timestamp text-muted font-weight-light">Submitted {{board.timestamp}}</p>
<div class="user-content mb-auto">{{reply.body|markdown|safe}}</div> <div class="user-content mb-auto">{{reply.body|markdown|safe}}</div>
<div class="actions d-flex flex-row-reverse"> <div class="actions d-flex flex-row-reverse">
{% if user.is_authenticated %}
{% if "can_moderate_board" in show_perms or board.user == user %}
<a href="{{showurl}}/discuss/board/delete/reply/{{reply.id}}" class="btn btn-warning ml-1">Delete Content</a>
<a href="{{showurl}}/create_ban?user={{reply.user.username}}" class="btn btn-warning ml-1">Ban</a>
{% else %}
<a href="{{showurl}}/discuss/board/report/{{reply.id}}" class="btn btn-secondary ml-1" title="Report" aria-label="Report"><i class="fa fa-fw fa-flag"></i></a> <a href="{{showurl}}/discuss/board/report/{{reply.id}}" class="btn btn-secondary ml-1" title="Report" aria-label="Report"><i class="fa fa-fw fa-flag"></i></a>
{% endif %}
{% endif %}
<div class="vote-btns"> <div class="vote-btns">
<form method="POST" class="d-inline" action="{{showurl}}/discuss/vote/{{reply.id}}/1"> <form method="POST" class="d-inline" action="{{showurl}}/discuss/vote/{{reply.id}}/1">
{% csrf_token %} {% csrf_token %}
@ -61,6 +77,7 @@
</div> </div>
</div> </div>
</div> </div>
{% endif %}
</div> </div>
{% empty %} {% empty %}
<h3>Nobody has replied to this board!</h3> <h3>Nobody has replied to this board!</h3>

View File

@ -24,6 +24,7 @@ urlpatterns = [
url(r'^board/new$', views.BoardForm), url(r'^board/new$', views.BoardForm),
url(r'^board/report/(?P<rid>\d{1,4})/?$', views.ReportForm), url(r'^board/report/(?P<rid>\d{1,4})/?$', views.ReportForm),
url(r'^board/pin/(?P<bid>\d{1,4})/?$', views.BoardPin), url(r'^board/pin/(?P<bid>\d{1,4})/?$', views.BoardPin),
url(r'^board/delete/reply/(?P<rid>\d{1,4})/?$', views.BoardDeleteReply),
url(r'^board/delete/(?P<bid>\d{1,4})/?$', views.BoardDelete), url(r'^board/delete/(?P<bid>\d{1,4})/?$', views.BoardDelete),
url(r'^board/lock/(?P<bid>\d{1,4})/?$', views.BoardLock), url(r'^board/lock/(?P<bid>\d{1,4})/?$', views.BoardLock),
url(r'^board/reply/(?P<bid>\d{1,4})/?$', views.BoardReplyForm), url(r'^board/reply/(?P<bid>\d{1,4})/?$', views.BoardReplyForm),

View File

@ -382,3 +382,14 @@ def BoardDelete(req, abbr, bid):
DiscussionBoard.objects.filter(pk=board.pk).delete() DiscussionBoard.objects.filter(pk=board.pk).delete()
return HttpResponseRedirect('%s/discuss' % (showurl)) 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)))