Пример #1
0
def flag_comment(request, comment_id):
    """
    Flag a comment. 
    """
    if not request.user.is_active:
        raise PermissionDenied
    comment = get_object_or_404(Comment, pk=comment_id)
    form = FlagForm(request.POST or None)
    if form.is_valid():
        if handle_flag_spam(request.user, form.cleaned_data['reason']):
            messages.info(request, _(u"Your account has been suspended due to behavior that looks like spam. If this is an error, please contact us using the contact link at the bottom of the page."))
            logout(request)
            return redirect("/")
        ticket, created = Note.objects.get_or_create(
            creator=request.user,
            text="FLAG from user. \n %s" % form.cleaned_data['reason'],
            resolved=None,
            important=form.cleaned_data['urgent'],
            comment=comment,
        )
        # Queue up an async process to send notification email in 2 minutes (we
        # delay to trap spam floods).
        if created:
             send_flag_notification_email.apply_async(
                     args=[ticket.pk], countdown=120)
        messages.info(request, _(u"A moderator will review that comment shortly. Thanks for helping us run a tight ship."))
        return redirect(comment.document.get_absolute_url())

        # redirect to confirmation.
    return render(request, "scanning/flag.html", {
            'form': form,
        })
Пример #2
0
def flag_document(request, document_id):
    """
    Flag a post. 
    """
    if not request.user.is_active:
        raise PermissionDenied
    doc = get_object_or_404(Document, pk=document_id)
    form = FlagForm(request.POST or None)
    if form.is_valid():
        if handle_flag_spam(request.user, form.cleaned_data['reason']):
            messages.info(request, _(u"Your account has been suspended due to behavior that looks like spam. If this is an error, please contact us using the contact link at the bottom of the page."))
            logout(request)
            return redirect("/")
        ticket, created = Note.objects.get_or_create(
            creator=request.user,
            text="FLAG from user. \n %s" % form.cleaned_data['reason'],
            resolved=None,
            important=form.cleaned_data['urgent'],
            document=doc,
        )
        # Queue up an async process to send notification email in 2 minutes (we
        # delay to trap spam floods).
        if created:
            send_flag_notification_email.apply_async(
                    args=[ticket.pk], countdown=120)
        messages.info(request, _(u"A moderator will review that post shortly. Thanks for helping us run a tight ship."))
        return redirect(doc.get_absolute_url())

        # redirect to confirmation.
    return render(request, "scanning/flag.html", {
            'form': form,
        })
Пример #3
0
def flag_document(request, document_id):
    """
    Flag a post. 
    """
    doc = get_object_or_404(Document, pk=document_id)
    form = FlagForm(request.POST or None)
    if form.is_valid():
        ticket, created = Note.objects.get_or_create(
            creator=request.user,
            text="FLAG from user. \n %s" % form.cleaned_data['reason'],
            resolved=None,
            important=form.cleaned_data['urgent'],
            document=doc,
        )
        messages.info(request, _(u"A moderator will review that post shortly. Thanks for helping us run a tight ship."))
        return redirect(doc.get_absolute_url())

        # redirect to confirmation.
    return render(request, "scanning/flag.html", {
            'form': form,
        })