Exemplo n.º 1
0
def user_addasfriend_view(request, id):
    current_user = request.user
    request_to_user = User.objects.get(id=id)
    Friend.add_friend(current_user, request_to_user)
    friend = Friend.objects.get(request_from=current_user, request_to=request_to_user, accepted=False)
    Notification.notify(friend, request_to_user)
    return redirect(reverse("user", args=[id]))
Exemplo n.º 2
0
def user_addasfriend_view(request, id):
    current_user = request.user
    request_to_user = User.objects.get(id=id)
    Friend.add_friend(current_user, request_to_user)
    friend = Friend.objects.get(request_from=current_user,
                                request_to=request_to_user,
                                accepted=False)
    Notification.notify(friend, request_to_user)
    return redirect(reverse('user', args=[id]))
Exemplo n.º 3
0
def comment_view(request, id=None):

    if request.method == "POST":
        form = CommentForm(request.POST)
        if form.is_valid():
            post = Post.objects.get(id=id)
            current_user = request.user
            comment = form.save(current_user, post)
            if post.posted_by != current_user:
                Notification.notify(comment, post.posted_by)
            return redirect(reverse("posts"))
        else:
            print form.errors

    return redirect(reverse("posts"))
Exemplo n.º 4
0
def comment_view(request, id=None):

    if request.method == 'POST':
        form = CommentForm(request.POST)
        if form.is_valid():
            post = Post.objects.get(id=id)
            current_user = request.user
            comment = form.save(current_user, post)
            if post.posted_by != current_user:
                Notification.notify(comment, post.posted_by)
            return redirect(reverse('posts'))
        else:
            print form.errors

    return redirect(reverse('posts'))