Ejemplo n.º 1
0
    return render_to_response("comments/moderation_queue.html", {
        'comments' : comments_per_page.object_list,
        'empty' : page == 1 and paginator.count == 0,
        'is_paginated': paginator.num_pages > 1,
        'results_per_page': 100,
        'has_next': comments_per_page.has_next(),
        'has_previous': comments_per_page.has_previous(),
        'page': page,
        'next': page + 1,
        'previous': page - 1,
        'pages': paginator.num_pages,
        'hits' : paginator.count,
        'page_range' : paginator.page_range
    }, context_instance=template.RequestContext(request))

moderation_queue = permission_required("comments.can_moderate")(moderation_queue)

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.'
)
Ejemplo n.º 2
0
        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(data, next, comment_done, c=comment._get_pk_val())


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=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.')
Ejemplo n.º 4
0
    Actually perform the checking of a story from a request.
    """
    story = get_object_or_404(Story, pk=object_id)
    model.objects.get_or_create(story=story, user=request.user)

def perform_uncheck(request, model, object_id):
    """
    Actually perform the unchecking of a story from a request.
    """
    story = get_object_or_404(Story, pk=object_id)
    get_object_or_404(model, story=story, user=request.user).delete()

# Confirmation views.
check_save = confirmation_view(
    model = Save,
    perform_func = perform_check,
    message = _("The %(verbose_name)s was created successfully."),
    doc = 'Displays a "story was saved" success message.'
)

uncheck_save = confirmation_view(
    model = Save,
    perform_func = perform_uncheck,
    message = _("The %(verbose_name)s was deleted."),
    doc = 'Displays a "story was unsaved" success message.'
)

check_watch = confirmation_view(
    model = Watch,
    perform_func = perform_check,
    message = _("The %(verbose_name)s was created successfully."),
    doc = 'Displays a "story was watched" success message.'
Ejemplo n.º 5
0
    # Otherwise create the comment
    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(data, next, comment_done, c=comment._get_pk_val())


comment_done = confirmation_view(
    template="comments/posted.html",
    doc="""Display a "comment was posted" success page.""")