summaryrefslogtreecommitdiff
path: root/app/lib/django_comments/views/moderation.py
diff options
context:
space:
mode:
Diffstat (limited to 'app/lib/django_comments/views/moderation.py')
-rw-r--r--app/lib/django_comments/views/moderation.py89
1 files changed, 42 insertions, 47 deletions
diff --git a/app/lib/django_comments/views/moderation.py b/app/lib/django_comments/views/moderation.py
index b35626a..4460569 100644
--- a/app/lib/django_comments/views/moderation.py
+++ b/app/lib/django_comments/views/moderation.py
@@ -1,15 +1,15 @@
from __future__ import absolute_import
-from django import template
from django.conf import settings
from django.contrib.auth.decorators import login_required, permission_required
-from django.shortcuts import get_object_or_404, render_to_response
+from django.shortcuts import get_object_or_404, render
from django.views.decorators.csrf import csrf_protect
import django_comments
from django_comments import signals
from django_comments.views.utils import next_redirect, confirmation_view
+
@csrf_protect
@login_required
def flag(request, comment_id, next=None):
@@ -27,14 +27,12 @@ def flag(request, comment_id, next=None):
if request.method == 'POST':
perform_flag(request, comment)
return next_redirect(request, fallback=next or 'comments-flag-done',
- c=comment.pk)
+ c=comment.pk)
# Render a form on GET
else:
- return render_to_response('comments/flag.html',
- {'comment': comment, "next": next},
- template.RequestContext(request)
- )
+ return render(request, 'comments/flag.html', {'comment': comment, "next": next})
+
@csrf_protect
@permission_required("django_comments.can_moderate")
@@ -55,14 +53,12 @@ def delete(request, comment_id, next=None):
# Flag the comment as deleted instead of actually deleting it.
perform_delete(request, comment)
return next_redirect(request, fallback=next or 'comments-delete-done',
- c=comment.pk)
+ c=comment.pk)
# Render a form on GET
else:
- return render_to_response('comments/delete.html',
- {'comment': comment, "next": next},
- template.RequestContext(request)
- )
+ return render(request, 'comments/delete.html', {'comment': comment, "next": next})
+
@csrf_protect
@permission_required("django_comments.can_moderate")
@@ -83,14 +79,12 @@ def approve(request, comment_id, next=None):
# Flag the comment as approved.
perform_approve(request, comment)
return next_redirect(request, fallback=next or 'comments-approve-done',
- c=comment.pk)
+ c=comment.pk)
# Render a form on GET
else:
- return render_to_response('comments/approve.html',
- {'comment': comment, "next": next},
- template.RequestContext(request)
- )
+ return render(request, 'comments/approve.html', {'comment': comment, "next": next})
+
# The following functions actually perform the various flag/aprove/delete
# actions. They've been broken out into separate functions to that they
@@ -101,40 +95,41 @@ def perform_flag(request, comment):
Actually perform the flagging of a comment from a request.
"""
flag, created = django_comments.models.CommentFlag.objects.get_or_create(
- comment = comment,
- user = request.user,
- flag = django_comments.models.CommentFlag.SUGGEST_REMOVAL
+ comment=comment,
+ user=request.user,
+ flag=django_comments.models.CommentFlag.SUGGEST_REMOVAL
)
signals.comment_was_flagged.send(
- sender = comment.__class__,
- comment = comment,
- flag = flag,
- created = created,
- request = request,
+ sender=comment.__class__,
+ comment=comment,
+ flag=flag,
+ created=created,
+ request=request,
)
+
def perform_delete(request, comment):
flag, created = django_comments.models.CommentFlag.objects.get_or_create(
- comment = comment,
- user = request.user,
- flag = django_comments.models.CommentFlag.MODERATOR_DELETION
+ comment=comment,
+ user=request.user,
+ flag=django_comments.models.CommentFlag.MODERATOR_DELETION
)
comment.is_removed = True
comment.save()
signals.comment_was_flagged.send(
- sender = comment.__class__,
- comment = comment,
- flag = flag,
- created = created,
- request = request,
+ sender=comment.__class__,
+ comment=comment,
+ flag=flag,
+ created=created,
+ request=request,
)
def perform_approve(request, comment):
flag, created = django_comments.models.CommentFlag.objects.get_or_create(
- comment = comment,
- user = request.user,
- flag = django_comments.models.CommentFlag.MODERATOR_APPROVAL,
+ comment=comment,
+ user=request.user,
+ flag=django_comments.models.CommentFlag.MODERATOR_APPROVAL,
)
comment.is_removed = False
@@ -142,24 +137,24 @@ def perform_approve(request, comment):
comment.save()
signals.comment_was_flagged.send(
- sender = comment.__class__,
- comment = comment,
- flag = flag,
- created = created,
- request = request,
+ sender=comment.__class__,
+ comment=comment,
+ flag=flag,
+ created=created,
+ request=request,
)
# Confirmation views.
flag_done = confirmation_view(
- template = "comments/flagged.html",
- doc = 'Displays a "comment was flagged" success page.'
+ template="comments/flagged.html",
+ doc='Displays a "comment was flagged" success page.'
)
delete_done = confirmation_view(
- template = "comments/deleted.html",
- doc = 'Displays a "comment was deleted" success page.'
+ template="comments/deleted.html",
+ doc='Displays a "comment was deleted" success page.'
)
approve_done = confirmation_view(
- template = "comments/approved.html",
- doc = 'Displays a "comment was approved" success page.'
+ template="comments/approved.html",
+ doc='Displays a "comment was approved" success page.'
)