1. David Chambers
  2. Mango

Commits

David Chambers  committed df6f6d6

Changed `moderate` so that comments marked as spam are now also deleted.

  • Participants
  • Parent commits 3384280
  • Branches default

Comments (0)

Files changed (1)

File views.py

View file
 MESSAGES = {
     'approve': {'do': 'Approve comment', 'done': 'Comment approved.'},
     'delete': {'do': 'Delete comment', 'done': 'Comment deleted.'},
-    'spam': {'do': 'Mark comment as spam', 'done': 'Comment marked as spam.'},
+    'spam': {'do': 'Mark comment as spam (and delete it)', 'done': 'Comment marked as spam and deleted.'},
 }
 
 def redirect(request, path):
     if request.GET.get('api_key') != hashlib.sha1(DISQUS['api_key']).hexdigest():
         return HttpResponseBadRequest('Invalid API key.')
 
+    post_id = request.GET.get('post_id')
     dsq = disqus.DisqusService(DISQUS_API_VERSION)
     dsq.login(DISQUS['api_key'])
-    dsq.moderate_post(request.GET.get('post_id'), 'kill' if action == 'delete' else action)
+
+    if action == 'approve':
+        dsq.moderate_post(post_id, 'approve')
+    else:
+        dsq.moderate_post(post_id, 'kill')
+        if action == 'spam':
+            dsq.moderate_post(post_id, 'spam')
+
     return HttpResponse(MESSAGES[action]['done'], content_type='text/plain; charset=utf-8')