Board moderation tools
This commit is contained in:
parent
c3ce46b94a
commit
d006598fe6
@ -3,24 +3,26 @@
|
|||||||
{{board.title}} - {{show.name}} Discussions - Episodes.Community
|
{{board.title}} - {{show.name}} Discussions - Episodes.Community
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
{% load markdown %}
|
{% load markdown %}
|
||||||
|
{% load guardian_tags %}
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
{% get_obj_perms request.user for show as "show_perms" %}
|
||||||
<div class="container mb-5 mt-5">
|
<div class="container mb-5 mt-5">
|
||||||
<nav aria-label="breadcrumb">
|
<nav aria-label="breadcrumb">
|
||||||
<ol class="breadcrumb">
|
<ol class="breadcrumb">
|
||||||
<li class="breadcrumb-item"><a href="/show/{{show.abbr}}">{{show.name}}</a></li>
|
<li class="breadcrumb-item"><a href="{{showurl}}">{{show.name}}</a></li>
|
||||||
<li class="breadcrumb-item"><a href="/show/{{show.abbr}}/discuss">Discussions</a></li>
|
<li class="breadcrumb-item"><a href="{{showurl}}/discuss">Discussions</a></li>
|
||||||
<li class="breadcrumb-item active" aria-current="page">{{board.title}}</li>
|
<li class="breadcrumb-item active" aria-current="page">{{board.title}}</li>
|
||||||
</ol>
|
</ol>
|
||||||
</nav>
|
</nav>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<h1 class="col">{{board.title}}</h1>
|
<h1 class="col">{% if board.locked %}<i class="fa fa-fw fa-lock"></i>{% endif %}{% if board.pinned %}<i class="fa fa-fw fa-thumb-tack"></i>{% endif %}{{board.title}}</h1>
|
||||||
<div class="col-2">
|
<div class="col-2">
|
||||||
<div class="d-flex flex-row-reverse mt-2">
|
<div class="d-flex flex-row-reverse mt-2">
|
||||||
{% if board.locked %}
|
{% if board.locked %}
|
||||||
<p>This board is locked</p>
|
<p>This board is locked</p>
|
||||||
{% else %}
|
{% else %}
|
||||||
{% if user.is_authenticated %}
|
{% if user.is_authenticated %}
|
||||||
<a href="/show/{{show.abbr}}/discuss/board/reply/{{board.pk}}" class="btn btn-primary"><i class="fa fa-fw fa-pencil"></i> Reply</a>
|
<a href="{{showurl}}/discuss/board/reply/{{board.pk}}" class="btn btn-primary"><i class="fa fa-fw fa-pencil"></i> Reply</a>
|
||||||
{% else %}
|
{% else %}
|
||||||
<p><a href="/login">Log in</a> to reply</p>
|
<p><a href="/login">Log in</a> to reply</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
@ -40,15 +42,15 @@
|
|||||||
<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">
|
||||||
<a href="/show/{{show.abbr}}/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>
|
||||||
<div class="vote-btns">
|
<div class="vote-btns">
|
||||||
<form method="POST" class="d-inline" action="/show/{{show.abbr}}/discuss/vote/{{reply.id}}/1">
|
<form method="POST" class="d-inline" action="{{showurl}}/discuss/vote/{{reply.id}}/1">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
<button href="#" class="btn btn-link text-success">
|
<button href="#" class="btn btn-link text-success">
|
||||||
<i class="fa fa-fw fa-thumbs-up"></i> {{reply.positives}}
|
<i class="fa fa-fw fa-thumbs-up"></i> {{reply.positives}}
|
||||||
</button>
|
</button>
|
||||||
</form>
|
</form>
|
||||||
<form method="POST" class="d-inline" action="/show/{{show.abbr}}/discuss/vote/{{reply.id}}/0">
|
<form method="POST" class="d-inline" action="{{showurl}}/discuss/vote/{{reply.id}}/0">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
<button href="#" class="btn btn-link text-danger">
|
<button href="#" class="btn btn-link text-danger">
|
||||||
<i class="fa fa-fw fa-thumbs-down"></i> {{reply.negatives}}
|
<i class="fa fa-fw fa-thumbs-down"></i> {{reply.negatives}}
|
||||||
@ -101,7 +103,7 @@
|
|||||||
{% if user.is_authenticated and not board.locked %}
|
{% if user.is_authenticated and not board.locked %}
|
||||||
<h2>Quick Reply</h2>
|
<h2>Quick Reply</h2>
|
||||||
<div class="reply-box">
|
<div class="reply-box">
|
||||||
<form class="form-horizontal" role="form" action="/show/{{show.abbr}}/discuss/board/reply/{{board.pk}}" method="post">
|
<form class="form-horizontal" role="form" action="{{showurl}}/discuss/board/reply/{{board.pk}}" method="post">
|
||||||
{% include "form.html" %}
|
{% include "form.html" %}
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<button type="submit" class="btn btn-primary">Reply</button>
|
<button type="submit" class="btn btn-primary">Reply</button>
|
||||||
@ -112,5 +114,20 @@
|
|||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% if user.is_authenticated %}
|
||||||
|
<h4>Board Tools</h4>
|
||||||
|
<ul>
|
||||||
|
{% if not board.locked %}
|
||||||
|
<li><a href="{{showurl}}/discuss/board/reply/{{board.pk}}">Reply to the board</a></li>
|
||||||
|
{% endif %}
|
||||||
|
{% if "can_moderate_board" in show_perms or board.user == user and not board.locked %}
|
||||||
|
<li><a href="{{showurl}}/discuss/board/lock/{{board.pk}}">Lock the board from further replies</a></li>
|
||||||
|
{% endif %}
|
||||||
|
{% if "can_moderate_board" in show_perms %}
|
||||||
|
<li><a href="{{showurl}}/discuss/board/pin/{{board.pk}}">{% if board.pinned %}Unpin the board{% else %}Pin the board at the top{% endif %}</a></li>
|
||||||
|
<li><a href="{{showurl}}/discuss/board/delete/{{board.pk}}">Delete the board</a></li>
|
||||||
|
{% endif %}
|
||||||
|
</ul>
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
@ -6,9 +6,9 @@
|
|||||||
<section class="container mt-5 mb-5">
|
<section class="container mt-5 mb-5">
|
||||||
<nav aria-label="breadcrumb">
|
<nav aria-label="breadcrumb">
|
||||||
<ol class="breadcrumb">
|
<ol class="breadcrumb">
|
||||||
<li class="breadcrumb-item"><a href="/show/{{show.abbr}}">{{show.name}}</a></li>
|
<li class="breadcrumb-item"><a href="{{showurl}}">{{show.name}}</a></li>
|
||||||
<li class="breadcrumb-item"><a href="/show/{{show.abbr}}/discuss">Discussions</a></li>
|
<li class="breadcrumb-item"><a href="{{showurl}}/discuss">Discussions</a></li>
|
||||||
<li class="breadcrumb-item"><a href="/show/{{show.abbr}}/discuss/board/{{board.pk}}-{{board.title|slugify}}">{{board.title}}</a></li>
|
<li class="breadcrumb-item"><a href="{{showurl}}/discuss/board/{{board.pk}}-{{board.title|slugify}}">{{board.title}}</a></li>
|
||||||
<li class="breadcrumb-item active" aria-current="page">Reply</li>
|
<li class="breadcrumb-item active" aria-current="page">Reply</li>
|
||||||
</ol>
|
</ol>
|
||||||
</nav>
|
</nav>
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
<div class="container mb-5 mt-5">
|
<div class="container mb-5 mt-5">
|
||||||
<nav aria-label="breadcrumb">
|
<nav aria-label="breadcrumb">
|
||||||
<ol class="breadcrumb">
|
<ol class="breadcrumb">
|
||||||
<li class="breadcrumb-item"><a href="/show/{{show.abbr}}">{{show.name}}</a></li>
|
<li class="breadcrumb-item"><a href="{{showurl}}">{{show.name}}</a></li>
|
||||||
<li class="breadcrumb-item active" aria-current="page">Discussions</li>
|
<li class="breadcrumb-item active" aria-current="page">Discussions</li>
|
||||||
</ol>
|
</ol>
|
||||||
</nav>
|
</nav>
|
||||||
@ -14,7 +14,7 @@
|
|||||||
<p>Discuss {{show.name}} with your fellow community members!</p>
|
<p>Discuss {{show.name}} with your fellow community members!</p>
|
||||||
<div class="d-flex flex-row-reverse mb-4">
|
<div class="d-flex flex-row-reverse mb-4">
|
||||||
{% if user.is_authenticated %}
|
{% if user.is_authenticated %}
|
||||||
<a href="/show/{{show.abbr}}/discuss/board/new" class="btn btn-primary"><i class="fa fa-fw fa-pencil"></i> Create New Board</a>
|
<a href="{{showurl}}/discuss/board/new" class="btn btn-primary"><i class="fa fa-fw fa-pencil"></i> Create New Board</a>
|
||||||
{% else %}
|
{% else %}
|
||||||
<p><a href="/login">Log in</a> to create boards</p>
|
<p><a href="/login">Log in</a> to create boards</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
@ -27,7 +27,7 @@
|
|||||||
<div class="board border-bottom">
|
<div class="board border-bottom">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<h2><a href="/show/{{show.abbr}}/discuss/board/{{board.pk}}-{{board.title|slugify}}">{{board.title}}</a></h2>
|
<h2><a href="{{showurl}}/discuss/board/{{board.pk}}-{{board.title|slugify}}">{% if board.locked %}<i class="fa fa-fw fa-lock"></i>{% endif %}{% if board.pinned %}<i class="fa fa-fw fa-thumb-tack"></i>{% endif %}{{board.title}}</a></h2>
|
||||||
<span class="text-muted font-weight-light">Submitted {{board.timestamp}} by
|
<span class="text-muted font-weight-light">Submitted {{board.timestamp}} by
|
||||||
{% if board.user.is_staff %}
|
{% if board.user.is_staff %}
|
||||||
<span class="mod"><i class="fa fa-fw fa-shield"></i></span>
|
<span class="mod"><i class="fa fa-fw fa-shield"></i></span>
|
||||||
|
@ -6,8 +6,8 @@
|
|||||||
<section class="container mt-5 mb-5">
|
<section class="container mt-5 mb-5">
|
||||||
<nav aria-label="breadcrumb">
|
<nav aria-label="breadcrumb">
|
||||||
<ol class="breadcrumb">
|
<ol class="breadcrumb">
|
||||||
<li class="breadcrumb-item"><a href="/show/{{show.abbr}}">{{show.name}}</a></li>
|
<li class="breadcrumb-item"><a href="{{showurl}}">{{show.name}}</a></li>
|
||||||
<li class="breadcrumb-item"><a href="/show/{{show.abbr}}/discuss">Discussions</a></li>
|
<li class="breadcrumb-item"><a href="{{showurl}}/discuss">Discussions</a></li>
|
||||||
<li class="breadcrumb-item active" aria-current="page">New Board</li>
|
<li class="breadcrumb-item active" aria-current="page">New Board</li>
|
||||||
</ol>
|
</ol>
|
||||||
</nav>
|
</nav>
|
||||||
|
@ -7,8 +7,8 @@
|
|||||||
<nav aria-label="breadcrumb">
|
<nav aria-label="breadcrumb">
|
||||||
<ol class="breadcrumb">
|
<ol class="breadcrumb">
|
||||||
<li class="breadcrumb-item"><a href="/show/{{show.abbr}}">{{show.name}}</a></li>
|
<li class="breadcrumb-item"><a href="/show/{{show.abbr}}">{{show.name}}</a></li>
|
||||||
<li class="breadcrumb-item"><a href="/show/{{show.abbr}}/discuss">Discussions</a></li>
|
<li class="breadcrumb-item"><a href="{{discuss}}">Discussions</a></li>
|
||||||
<li class="breadcrumb-item"><a href="/show/{{show.abbr}}/discuss/board/{{reply.board.pk}}-{{reply.board.title|slugify}}">{{reply.board.title}}</a></li>
|
<li class="breadcrumb-item"><a href="{{discuss}}/board/{{reply.board.pk}}-{{reply.board.title|slugify}}">{{reply.board.title}}</a></li>
|
||||||
<li class="breadcrumb-item active" aria-current="page">Report</li>
|
<li class="breadcrumb-item active" aria-current="page">Report</li>
|
||||||
</ol>
|
</ol>
|
||||||
</nav>
|
</nav>
|
||||||
|
@ -23,6 +23,9 @@ urlpatterns = [
|
|||||||
url(r'^vote/(?P<replyid>\d+)/(?P<positive>[0-1])/?$', views.BoardVoteSubmit.as_view()),
|
url(r'^vote/(?P<replyid>\d+)/(?P<positive>[0-1])/?$', views.BoardVoteSubmit.as_view()),
|
||||||
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/delete/(?P<bid>\d{1,4})/?$', views.BoardDelete),
|
||||||
|
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),
|
||||||
url(r'^board/(?P<bid>\d{1,4})(-[\w-]+)?/?$', views.Board.as_view()),
|
url(r'^board/(?P<bid>\d{1,4})(-[\w-]+)?/?$', views.Board.as_view()),
|
||||||
]
|
]
|
||||||
|
@ -34,12 +34,18 @@ from . import forms
|
|||||||
import datetime
|
import datetime
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
# Append common values to context
|
||||||
|
def get_show_url(abbr):
|
||||||
|
return '/show/%s' % (abbr)
|
||||||
|
|
||||||
class Boards(TemplateView):
|
class Boards(TemplateView):
|
||||||
|
|
||||||
template_name = "boards.html"
|
template_name = "boards.html"
|
||||||
|
|
||||||
def get_context_data(self, abbr, **kwargs):
|
def get_context_data(self, abbr, **kwargs):
|
||||||
ctx = super().get_context_data()
|
ctx = super().get_context_data()
|
||||||
|
ctx['showurl'] = get_show_url(abbr)
|
||||||
|
|
||||||
show = get_object_or_404(Show, abbr=abbr)
|
show = get_object_or_404(Show, abbr=abbr)
|
||||||
|
|
||||||
page = self.request.GET.get('page', 1)
|
page = self.request.GET.get('page', 1)
|
||||||
@ -56,7 +62,7 @@ class Boards(TemplateView):
|
|||||||
then=Max('replies__timestamp')
|
then=Max('replies__timestamp')
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
).order_by('-recency')
|
).order_by('-pinned','-recency')
|
||||||
paginator = Paginator(boards_list, getattr(settings, "DISCUSSIONS_PER_PAGE", 26))
|
paginator = Paginator(boards_list, getattr(settings, "DISCUSSIONS_PER_PAGE", 26))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -77,6 +83,8 @@ class Board(TemplateView):
|
|||||||
|
|
||||||
def get_context_data(self, abbr, bid, **kwargs):
|
def get_context_data(self, abbr, bid, **kwargs):
|
||||||
ctx = super().get_context_data()
|
ctx = super().get_context_data()
|
||||||
|
ctx['showurl'] = get_show_url(abbr)
|
||||||
|
|
||||||
show = get_object_or_404(Show, abbr=abbr)
|
show = get_object_or_404(Show, abbr=abbr)
|
||||||
board = get_object_or_404(DiscussionBoard, pk=bid)
|
board = get_object_or_404(DiscussionBoard, pk=bid)
|
||||||
|
|
||||||
@ -104,7 +112,7 @@ class Board(TemplateView):
|
|||||||
found = DiscussionReply.objects.filter(timestamp__lt=item.timestamp,board=board).count()
|
found = DiscussionReply.objects.filter(timestamp__lt=item.timestamp,board=board).count()
|
||||||
page = int(found / perpage) + 1
|
page = int(found / perpage) + 1
|
||||||
index = int(found % perpage) + 1
|
index = int(found % perpage) + 1
|
||||||
ctx['url'] = '/show/%s/discuss/board/%d-%s?page=%d#reply-%d'%(abbr, board.pk, slugify(board.title), page, index)
|
ctx['url'] = ctx['showurl'] + '/discuss/board/%d-%s?page=%d#reply-%d'%(board.pk, slugify(board.title), page, index)
|
||||||
|
|
||||||
return ctx
|
return ctx
|
||||||
|
|
||||||
@ -139,7 +147,8 @@ def BoardForm(req, abbr):
|
|||||||
# Request context
|
# Request context
|
||||||
ctx = {
|
ctx = {
|
||||||
'form': form,
|
'form': form,
|
||||||
'show': show
|
'show': show,
|
||||||
|
'showurl': get_show_url(abbr)
|
||||||
}
|
}
|
||||||
|
|
||||||
# Get bans for this user regarding this show
|
# Get bans for this user regarding this show
|
||||||
@ -175,7 +184,7 @@ def BoardForm(req, abbr):
|
|||||||
new_post = DiscussionReply(user=user,board=new_board,body=form_data['body'])
|
new_post = DiscussionReply(user=user,board=new_board,body=form_data['body'])
|
||||||
new_post.save()
|
new_post.save()
|
||||||
|
|
||||||
return HttpResponseRedirect('/show/%s/discuss/board/%d-%s'%(abbr, new_board.pk, slugify(form_data['title'])))
|
return HttpResponseRedirect(ctx['showurl'] + '/discuss/board/%d-%s'%(new_board.pk, slugify(form_data['title'])))
|
||||||
else:
|
else:
|
||||||
ctx['error'] = 'Invalid fields!'
|
ctx['error'] = 'Invalid fields!'
|
||||||
|
|
||||||
@ -194,7 +203,8 @@ def BoardReplyForm(req, abbr, bid):
|
|||||||
ctx = {
|
ctx = {
|
||||||
'form': form,
|
'form': form,
|
||||||
'board': board,
|
'board': board,
|
||||||
'show': show
|
'show': show,
|
||||||
|
'showurl': get_show_url(abbr)
|
||||||
}
|
}
|
||||||
|
|
||||||
# Get bans for this user regarding this show
|
# Get bans for this user regarding this show
|
||||||
@ -233,7 +243,7 @@ def BoardReplyForm(req, abbr, bid):
|
|||||||
new_reply.board = board
|
new_reply.board = board
|
||||||
new_reply.save()
|
new_reply.save()
|
||||||
|
|
||||||
return HttpResponseRedirect('/show/%s/discuss/board/%d-%s?findReply=%d'%(abbr, board.pk, slugify(board.title), new_reply.pk))
|
return HttpResponseRedirect(ctx['showurl'] + '/discuss/board/%d-%s?findReply=%d'%(board.pk, slugify(board.title), new_reply.pk))
|
||||||
else:
|
else:
|
||||||
ctx['error'] = 'Invalid fields!'
|
ctx['error'] = 'Invalid fields!'
|
||||||
|
|
||||||
@ -247,6 +257,7 @@ class BoardVoteSubmit(LoginRequiredMixin, View):
|
|||||||
pos_bool = int(positive) == 1
|
pos_bool = int(positive) == 1
|
||||||
|
|
||||||
user = req.user
|
user = req.user
|
||||||
|
showurl = get_show_url(abbr)
|
||||||
|
|
||||||
# Get the reply from the database
|
# Get the reply from the database
|
||||||
reply = get_object_or_404(DiscussionReply, id=replyid)
|
reply = get_object_or_404(DiscussionReply, id=replyid)
|
||||||
@ -254,8 +265,8 @@ class BoardVoteSubmit(LoginRequiredMixin, View):
|
|||||||
# Prevent voting for own reply
|
# Prevent voting for own reply
|
||||||
if reply.user == user:
|
if reply.user == user:
|
||||||
return HttpResponse('<h1>Error</h1><p>You cannot vote for your own reply.</p><p>'
|
return HttpResponse('<h1>Error</h1><p>You cannot vote for your own reply.</p><p>'
|
||||||
'<a href="/show/%s/discuss/board/%d-%s">Return to board</a></p>'
|
'<a href="%s/discuss/board/%d-%s">Return to board</a></p>'
|
||||||
% (abbr, reply.board.pk, slugify(reply.board.title)), status=400)
|
% (showurl, reply.board.pk, slugify(reply.board.title)), status=400)
|
||||||
|
|
||||||
show = reply.board.show
|
show = reply.board.show
|
||||||
|
|
||||||
@ -281,7 +292,7 @@ class BoardVoteSubmit(LoginRequiredMixin, View):
|
|||||||
)
|
)
|
||||||
new_vote.save()
|
new_vote.save()
|
||||||
|
|
||||||
return HttpResponseRedirect('/show/%s/discuss/board/%d-%s?findReply=%d'%(abbr, reply.board.pk, slugify(reply.board.title), reply.pk))
|
return HttpResponseRedirect('%s/discuss/board/%d-%s?findReply=%d'%(showurl, reply.board.pk, slugify(reply.board.title), reply.pk))
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
def ReportForm(req, abbr, rid):
|
def ReportForm(req, abbr, rid):
|
||||||
@ -301,10 +312,11 @@ def ReportForm(req, abbr, rid):
|
|||||||
ctx = {
|
ctx = {
|
||||||
'form': form,
|
'form': form,
|
||||||
'show': show,
|
'show': show,
|
||||||
'reply': reply
|
'reply': reply,
|
||||||
|
'showurl': get_show_url(abbr)
|
||||||
}
|
}
|
||||||
|
|
||||||
url = '/show/%s/discuss/board/%d-%s?findReply=%d'%(abbr, reply.board.pk, slugify(reply.board.title), reply.pk)
|
url = '%s/discuss/board/%d-%s?findReply=%d'%(ctx['showurl'], reply.board.pk, slugify(reply.board.title), reply.pk)
|
||||||
|
|
||||||
# Handle POST
|
# Handle POST
|
||||||
if req.method == 'POST':
|
if req.method == 'POST':
|
||||||
@ -330,8 +342,43 @@ def ReportForm(req, abbr, rid):
|
|||||||
new_report.url = url
|
new_report.url = url
|
||||||
new_report.save()
|
new_report.save()
|
||||||
|
|
||||||
return HttpResponseRedirect('/show/%s/discuss/board/%d-%s'%(abbr, reply.board.pk, slugify(reply.board.title)))
|
return HttpResponseRedirect('%s/discuss/board/%d-%s'%(ctx['showurl'], reply.board.pk, slugify(reply.board.title)))
|
||||||
else:
|
else:
|
||||||
ctx['error'] = 'Invalid fields!'
|
ctx['error'] = 'Invalid fields!'
|
||||||
|
|
||||||
return render(req, "report_reply.html", ctx)
|
return render(req, "report_reply.html", ctx)
|
||||||
|
|
||||||
|
@login_required
|
||||||
|
def BoardLock(req, abbr, bid):
|
||||||
|
user = req.user
|
||||||
|
board = get_object_or_404(DiscussionBoard, pk=bid)
|
||||||
|
showurl = get_show_url(abbr)
|
||||||
|
|
||||||
|
if not user.has_perm('LandingPage.can_moderate_board', board.show) and not board.user == user:
|
||||||
|
return HttpResponse('<h1>Error</h1><p>You do not have permission to lock this show.</p><p>'
|
||||||
|
'<a href="%s/discuss/board/%d-%s">Return to board</a></p>'
|
||||||
|
% (showurl, board.pk, slugify(board.title)), status=400)
|
||||||
|
|
||||||
|
lock = not board.locked
|
||||||
|
DiscussionBoard.objects.filter(pk=board.pk).update(locked=lock)
|
||||||
|
return HttpResponseRedirect('%s/discuss/board/%d-%s'%(showurl, board.pk, slugify(board.title)))
|
||||||
|
|
||||||
|
|
||||||
|
@permission_required_or_403('LandingPage.can_moderate_board', (Show, 'abbr', 'abbr'), accept_global_perms=True)
|
||||||
|
def BoardPin(req, abbr, bid):
|
||||||
|
board = get_object_or_404(DiscussionBoard, pk=bid)
|
||||||
|
showurl = get_show_url(abbr)
|
||||||
|
|
||||||
|
pin = not board.pinned
|
||||||
|
|
||||||
|
DiscussionBoard.objects.filter(pk=board.pk).update(pinned=pin)
|
||||||
|
return HttpResponseRedirect('%s/discuss/board/%d-%s'%(showurl, board.pk, slugify(board.title)))
|
||||||
|
|
||||||
|
@permission_required_or_403('LandingPage.can_moderate_board', (Show, 'abbr', 'abbr'), accept_global_perms=True)
|
||||||
|
def BoardDelete(req, abbr, bid):
|
||||||
|
board = get_object_or_404(DiscussionBoard, pk=bid)
|
||||||
|
showurl = get_show_url(abbr)
|
||||||
|
|
||||||
|
DiscussionBoard.objects.filter(pk=board.pk).delete()
|
||||||
|
|
||||||
|
return HttpResponseRedirect('%s/discuss' % (showurl))
|
||||||
|
Reference in New Issue
Block a user