for (receiver, response) in responses: if response == False: return CommentPostBadRequest( "comment_will_be_posted receiver %r killed the comment" % \ receiver.__name__) domain = request.get_host() try: site = Site.objects.get(domain=domain) except Site.DoesNotExist: raise Http404() comment.site = site # Save the comment and signal that it was saved comment.save() signals.comment_was_posted.send( sender=comment.__class__, comment=comment, request=request ) return redirect(next) comment_done = confirmation_view( template="comments/posted.html", doc="""Display a "comment was posted" success page.""" )
flag, created = comments.models.CommentFlag.objects.get_or_create( comment = comment, user = request.user, flag = 'spam' ) comment.is_removed = True comment.save() signals.comment_was_flagged.send( sender = comment.__class__, comment = comment, flag = flag, created = created, request = request, ) return utils.next_redirect(request.POST.copy(), next, spam_done, c=comment.pk) # Render a form on GET else: return render_to_response('comments/spam.html', {'comment': comment, "next": next}, template.RequestContext(request) ) comments_spam = require_site_admin(comments_spam) spam_done = utils.confirmation_view( template = "comments/spammed.html", doc = 'Displays a "comment was marked as spam" success page.' )
user = request.user, flag = comments.models.CommentFlag.MODERATOR_APPROVAL, ) comment.is_removed = False comment.is_public = True comment.save() signals.comment_was_flagged.send( 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.' ) delete_done = confirmation_view( 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.' )
if form.is_valid(): MODERATOR_EDITED = "moderator edited" flag, created = comments.models.CommentFlag.objects.get_or_create( comment = form.instance, user = request.user, flag = MODERATOR_EDITED ) form.instance.is_removed = False form.save() signals.comment_was_flagged.send( sender = comment.__class__, comment = comment, flag = flag, created = created, request = request ) return next_redirect(request, next, edit_done, c=comment.pk) else: # If we got here, raise Bad Request error. return CommentEditBadRequest("Could not complete request!") edit_done = confirmation_view( template = "comments/edited.html", doc = 'Displays a "comment was edited" success page.' )
comment.is_spam = True comment.is_public = False comment.save() if not originally_spam: signals.comment_was_marked_as_spam.send( sender = comment.__class__, comment = comment, request = request, ) # Confirmation views. flag_done = confirmation_view( template = "comments/flagged.html", doc = 'Displays a "comment was flagged" success page.' ) remove_done = confirmation_view( template = "comments/removed.html", doc = 'Displays a "comment was removed" success page.' ) approve_done = confirmation_view( template = "comments/approved.html", doc = 'Displays a "comment was approved" success page.' ) delete_done = confirmation_view( template="comments/deleted.html", doc = "Displays a 'comment was deleted' success page." )
comment = form.get_comment_object() comment.ip_address = request.META.get("REMOTE_ADDR", None) if request.user.is_authenticated(): comment.user = request.user # Signal that the comment is about to be saved responses = signals.comment_will_be_posted.send(sender=comment.__class__, comment=comment, request=request) for (receiver, response) in responses: if response == False: return CommentPostBadRequest( "comment_will_be_posted receiver %r killed the comment" % receiver.__name__) # Save the comment and signal that it was saved comment.save() signals.comment_was_posted.send(sender=comment.__class__, comment=comment, request=request) return next_redirect(request, fallback=next or 'comments-comment-done', c=comment._get_pk_val()) comment_done = confirmation_view( template="comments/posted.html", doc="""Display a "comment was posted" success page.""")
if request.is_ajax(): return redirect('osl_comments.views.get_comment', comment_id=comment_id) else: return next_redirect(request.POST.copy(), next, delete_by_user_done, c=comment.pk) # Render a form on GET else: return render_to_response('comments/delete_by_user.html', {'comment': comment, "next": next}, RequestContext(request) ) delete_by_user_done = confirmation_view( template = "comments/deleted_by_user.html", doc = 'Displays a "comment was deleted" success page.' ) @login_required @require_POST def edit_comment(request, next=None): # get data data = request.POST.copy() next = data.get('next', next) # see if user wants to cancel cancel = 'cancel' in data if cancel: return redirect(data['cancel_url']) # get comment and raise error if id is wrong