activation_required self_protect def confirm_friend request user_id us

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
@activation_required()
@self_protect()
def confirm_friend(request, user_id):
user = get_object_or_404(Profile, pk=user_id)
confirmation = get_object_or_404(FriendConfirmation, recipient=request.user, sender=user)
if not request.user in user.friends.all():
friend = Friend(friend1=user, friend2=request.user, friend_type=False)
friend.save()
confirmation.delete()
flash.notice_next(u"Now you can see yourself in %s friends list" % (user.display_name))
return HttpResponseRedirect(user.show_url())