def unfollow(request, username): """ Removes a "following" edge from the authenticated user to the user specified by the username in the URL. """ user = get_object_or_404(User, username=username) try: ul = UserLink.objects.get(from_user=request.user, to_user=user) ul.delete() deleted = True except UserLink.DoesNotExist: deleted = False next = get_next(request) if next and next != request.path: # request.user.message_set.create( # message=_('You are no longer following %s') % user.username) return HttpResponseRedirect(next) context = { 'other_user': user, 'deleted': deleted, } return render_to_response( 'followers/unfollowed.html', context, context_instance=RequestContext(request) )
def follow(request, username): """ Adds a "following" edge from the authenticated user to the user specified by the username in the URL. """ user = get_object_or_404(User, username=username) ul, created = UserLink.objects.get_or_create(from_user=request.user, to_user=user) next = get_next(request) if next and next != request.path: # request.user.message_set.create( # message=_('You are now following %s') % user.username) return HttpResponseRedirect(next) context = { 'other_user': user, 'created': created, } return render_to_response( 'followers/followed.html', context, context_instance=RequestContext(request) )