コード例 #1
0
        comment.user_img = request.session['profile_image_url']

    # 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 is 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."""
)
コード例 #2
0
ファイル: comments.py プロジェクト: hordechief/zakkabag
        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 is 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."""
)
コード例 #3
0
def perform_dislike(request, comment):
    """Actually set the 'Dislikedit' flag on a comment from a request."""
    flag, created = CommentFlag.objects.get_or_create(comment=comment,
                                                      user=request.user,
                                                      flag=DISLIKEDIT_FLAG)
    if created:
        CommentFlag.objects.filter(comment=comment,
                                   user=request.user,
                                   flag=LIKEDIT_FLAG).delete()
    else:
        flag.delete()
    return created


like_done = confirmation_view(
    template="django_comments_xtd/liked.html",
    doc='Displays a "I liked this comment" success page.'
)

dislike_done = confirmation_view(
    template="django_comments_xtd/disliked.html",
    doc='Displays a "I disliked this comment" success page.'
)


class XtdCommentListView(ListView):
    page_range = 5
    content_types = None  # List of "app_name.model_name" strings.
    template_name = "django_comments_xtd/comment_list.html"

    def get_content_types(self):
        if self.content_types is None:
コード例 #4
0
ファイル: moderation.py プロジェクト: dqnykamp/mathinsight
        )

# The following functions actually perform the various flag/aprove/delete
# actions. They've been broken out into seperate functions to that they
# may be called from admin actions.

def perform_credit(request, comment):
    flag, created = django_comments.models.CommentFlag.objects.get_or_create(
        comment = comment,
        user    = request.user,
        flag    = django_comments.models.CommentFlag.MODERATOR_APPROVAL,
    )

    comment.credit = True
    comment.save()

    signals.comment_was_flagged.send(
        sender  = comment.__class__,
        comment = comment,
        flag    = flag,
        created = created,
        request = request,
    )

# Confirmation views.

credit_done = confirmation_view(
    template = "comments/credited.html",
    doc = 'Displays a "comment was credited" success page.'
)
コード例 #5
0
        user=request.user,
        flag=django_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.'
)
コード例 #6
0
    flag, created = django_comments.models.CommentFlag.objects.get_or_create(
        comment=comment,
        user=request.user,
        flag=django_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.')
コード例 #7
0
ファイル: views.py プロジェクト: danirus/django-comments-xtd
def perform_dislike(request, comment):
    """Actually set the 'Dislikedit' flag on a comment from a request."""
    flag, created = CommentFlag.objects.get_or_create(comment=comment,
                                                      user=request.user,
                                                      flag=DISLIKEDIT_FLAG)
    if created:
        CommentFlag.objects.filter(comment=comment,
                                   user=request.user,
                                   flag=LIKEDIT_FLAG).delete()
    else:
        flag.delete()
    return created


like_done = confirmation_view(
    template="django_comments_xtd/liked.html",
    doc='Displays a "I liked this comment" success page.'
)

dislike_done = confirmation_view(
    template="django_comments_xtd/disliked.html",
    doc='Displays a "I disliked this comment" success page.'
)


class XtdCommentListView(ListView):
    page_range = 5
    content_types = None  # List of "app_name.model_name" strings.
    template_name = "django_comments_xtd/comment_list.html"

    def get_content_types(self):
        if self.content_types is None:
コード例 #8
0
                "next": next,
            }, RequestContext(request, {}))

    # Otherwise, try to save the comment and emit signals
    if form.is_valid():
        MODERATOR_EDITED = "moderator edited"
        flag, created = CommentFlag.objects.get_or_create(
            comment=form.instance, user=request.user, flag=MODERATOR_EDITED)

        form.instance.is_removed = False
        form.save()

        comment_was_flagged.send(sender=comment.__class__,
                                 comment=comment,
                                 flag=flag,
                                 created=created,
                                 request=request)

        return utils.next_redirect(request,
                                   fallback=next or 'comments-comment-done',
                                   c=comment._get_pk_val())

    else:
        # If we got here, raise Bad Request error.
        return CommentEditBadRequest("Could not complete request!")


edit_done = utils.confirmation_view(
    template="comments/edited.html",
    doc='Displays a "comment was edited" success page.')