예제 #1
0
파일: views.py 프로젝트: shaktipada/social
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]))
예제 #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]))
예제 #3
0
파일: views.py 프로젝트: shaktipada/social
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"))
예제 #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'))