comparison gpp/forums/views/main.py @ 460:2ff5f4c1476d

Fixing #221. Found some additional cases where the forum moderator check was failing. Replaced this code with calls to the new permissions module.
author Brian Neal <bgneal@gmail.com>
date Sun, 03 Jul 2011 19:35:09 +0000
parents 9d3bd7304050
children 3b30286adba5
comparison
equal deleted inserted replaced
459:9d3bd7304050 460:2ff5f4c1476d
477 if id is None: 477 if id is None:
478 return HttpResponseBadRequest('No post id') 478 return HttpResponseBadRequest('No post id')
479 479
480 post = get_object_or_404(Post.objects.select_related(), pk=id) 480 post = get_object_or_404(Post.objects.select_related(), pk=id)
481 481
482 can_delete = request.user.is_superuser or \ 482 if not perms.can_moderate(post.topic.forum, request.user):
483 request.user in post.topic.forum.moderators.all()
484
485 if not can_delete:
486 return HttpResponseForbidden("You don't have permission to delete that post.") 483 return HttpResponseForbidden("You don't have permission to delete that post.")
487 484
488 delete_single_post(post) 485 delete_single_post(post)
489 return HttpResponse("The post has been deleted.") 486 return HttpResponse("The post has been deleted.")
490 487