Exemplo n.º 1
0
def rate_entry_request(request, post_id, user_id):
    """Triggered when a user rates a specific entry"""
    entry = Entry.objects.get(id=post_id)
    user = User.objects.get(id=user_id)
    positive = True

    if request.POST['like']:
        positive = True
    else:
        positive = False

    v = Votes()
    if v.validate_entry_vote(user_id, post_id):
        vote = EntryVotes(entry=entry, user=user, positive=positive)
        vote.save()
        v.set_entry_rate(post_id)

    return HttpResponseRedirect(reverse("singlepost", args=(post_id, )))
Exemplo n.º 2
0
def rate_entry_request(request, post_id, user_id):
    """Triggered when a user rates a specific entry"""
    entry = Entry.objects.get(id=post_id)
    user = User.objects.get(id=user_id)
    positive = True

    if request.POST['like']:
        positive = True
    else:
        positive = False

    v = Votes()
    if v.validate_entry_vote(user_id, post_id):
        vote = EntryVotes(entry=entry,
                          user=user,
                          positive=positive)
        vote.save()
        v.set_entry_rate(post_id)

    return HttpResponseRedirect(reverse("singlepost", args=(post_id,)))
Exemplo n.º 3
0
def rate_comment_request(request, post_id, comment_id, user_id):
    """Triggered when an user rates a specific comment
    from a specific entry
    """
    comment = Comment.objects.get(id=comment_id)
    user = User.objects.get(id=user_id)
    positive = True

    if request.POST['like']:
        positive = True
    else:
        positive = False

    v = Votes()
    if v.validate_comment_vote(user_id, comment_id):
        vote = CommentVotes(comment=comment, user=user, positive=positive)
        vote.save()
        v.set_comment_rate(comment_id)

    return HttpResponseRedirect(reverse("singlepost", args=(post_id, )))
Exemplo n.º 4
0
def rate_comment_request(request, post_id, comment_id, user_id):
    """Triggered when an user rates a specific comment
    from a specific entry
    """
    comment = Comment.objects.get(id=comment_id)
    user = User.objects.get(id=user_id)
    positive = True

    if request.POST['like']:
        positive = True
    else:
        positive = False

    v = Votes()
    if v.validate_comment_vote(user_id, comment_id):
        vote = CommentVotes(comment=comment,
                            user=user,
                            positive=positive)
        vote.save()
        v.set_comment_rate(comment_id)

    return HttpResponseRedirect(reverse("singlepost", args=(post_id,)))