@login_required
@permission_required_or_403('forums_forum.post_delete_forum', (Forum, 'slug__iexact', 'forum_slug'))
def delete_post(request, forum_slug, thread_id, post_id):
 forum = get_object_or_404(Forum, slug=forum_slug)
 thread = get_object_or_404(Thread, pk=thread_id, forum=forum)
 post = get_object_or_404(Post, pk=post_id, thread=thread)
 if (request.method == 'GET'):
  return render(request, 'forums/confirm_post_delete.html', {'forum': forum, 'thread': thread, 'post': post})
 log.warning(('User %s is deleting post with id=%s' % (request.user, post.id)))
 post.delete()
 statsd.incr('forums.delete_post')
 try:
  Thread.objects.get(pk=thread_id)
  goto = reverse('forums.posts', args=[forum_slug, thread_id])
 except Thread.DoesNotExist:
  goto = reverse('forums.threads', args=[forum_slug])
 return HttpResponseRedirect(goto)

@ login_required @ permission_required_or_403 ( 'forums_forum.post_delete_forum' , ( Forum , 'slug__iexact' , 'forum_slug' ) ) def delete_post ( request , forum_slug , thread_id , post_id ) : forum = get_object_or_404 ( Forum , slug = forum_slug ) thread = get_object_or_404 ( Thread , pk = thread_id , forum = forum ) post = get_object_or_404 ( Post , pk = post_id , thread = thread ) if ( request . method == 'GET' ) : return render ( request , 'forums/confirm_post_delete.html' , { 'forum' : forum , 'thread' : thread , 'post' : post } ) log . warning ( ( 'User %s is deleting post with id=%s' % ( request . user , post . id ) ) ) post . delete ( ) statsd . incr ( 'forums.delete_post' ) try : Thread . objects . get ( pk = thread_id ) goto = reverse ( 'forums.posts' , args = [ forum_slug , thread_id ] ) except Thread . DoesNotExist : goto = reverse ( 'forums.threads' , args = [ forum_slug ] ) return HttpResponseRedirect ( goto )
delete a post .