def unfollow_view(request, the_creep): if request.method == 'POST': luser = UserProfile.get_user_by_id(request.user.username) try: ruser = UserProfile.get_user_by_id(the_creep) except UserProfile.DoesNotExist: raise Http404 unfollow(follower=luser, followee=ruser) return redirect('/%s/' % the_creep)
def follow_view(request, to_follow): print(request.method) if request.method == 'POST': luser = UserProfile.get_user_by_id(request.user.username) try: ruser = UserProfile.get_user_by_id(to_follow) except UserProfile.DoesNotExist: raise Http404 follow(follower=luser, followee=ruser) return redirect('/%s/' % to_follow)
def status(request, username, tweet_id): try: tweet = Post.get_post_by_id(tweet_id) ruser = UserProfile.get_user_by_id(username) except: raise Http404 luser = UserProfile.get_user_by_id(request.user.username) tpl_vars = { 'luser': luser, 'ruser': ruser, 'all_users': UserProfile.objects.all(), 'header': 'page', 'logged': luser.is_authenticated(), 'tweet': tweet } return render_to_response('twtapp/single.html', RequestContext(request, tpl_vars))
def post(request): '''The view that makes the tweet happen!''' if request.method == 'POST': user = UserProfile.get_user_by_id(request.user.username) if request.POST.get('content', None): tweet = user.add_post(request.POST['content']) user.add_to_timeline(tweet) # Now let the followers know for follower in user.get_followers(): follower.add_to_timeline(tweet) return redirect('/home/')