def profile(request, url): user = request.user prof = get_object_or_404(UserProfile, url=url) other_user = prof.user form = None age = None invited = False if user.is_authenticated(): #check if we've invited the user to be our friend try: inv = other_user.get_profile().invites.get(sender=user) invited = True except Invite.DoesNotExist: invited = False age = util.get_age(other_user.get_profile().birthdate) # post a comment if util.can_users_interract(user, other_user): form = myforms.CommentForm() else: form = None return render_to_response('profile/profile.html', {'other_user': other_user, 'form': form, 'invited': invited, 'age': age}, context_instance=RequestContext(request))
def profile(request, url): user = request.user prof = get_object_or_404(UserProfile, url=url) other_user = prof.user form = None age = None invited = False if user.is_authenticated(): #check if we've invited the user to be our friend try: inv = other_user.get_profile().invites.get(sender=user) invited = True except Invite.DoesNotExist: invited = False age = util.get_age(other_user.get_profile().birthdate) # post a comment if util.can_users_interract(user, other_user): form = myforms.CommentForm() else: form = None return render_to_response('profile/profile.html', { 'other_user': other_user, 'form': form, 'invited': invited, 'age': age }, context_instance=RequestContext(request))
def view_friends(request, url): user = request.user prof = get_object_or_404(UserProfile, url=url) other_user = prof.user if util.can_users_interract(user, other_user): return render_to_response('profile/friends.html', {'other_user': other_user}, context_instance=RequestContext(request))
def post(request, url): user = request.user prof = get_object_or_404(UserProfile, url=url) other_user = prof.user if util.can_users_interract(user, other_user): if request.method == 'POST': comment = Comment.objects.create(author=user, read=False, sent=datetime.datetime.now()) form = myforms.CommentForm(request.POST, instance=comment) comment = form.save() other_user.get_profile().comments.add(comment) return HttpResponseRedirect('/profile/' + other_user.get_profile().url + '/')
def comment_img(request, url, img_id): user = request.user prof = UserProfile.objects.get(url=url) other_user = prof.user img = get_object_or_404(Picture, id=img_id) if util.can_users_interract(user, other_user): if request.method == 'POST': comment = Comment.objects.create(author=user, read=False, sent=datetime.datetime.now()) form = myforms.CommentForm(request.POST, instance=comment) comment = form.save() img.comments.add(comment) return HttpResponseRedirect('/profile/' + url + '/images/' + str(img_id) + '/view/')
def comment_img(request, url, img_id): user = request.user prof = UserProfile.objects.get(url=url) other_user = prof.user img = get_object_or_404(Picture, id=img_id) if util.can_users_interract(user, other_user): if request.method == 'POST': comment = Comment.objects.create( author=user, read=False, sent = datetime.datetime.now() ) form = myforms.CommentForm(request.POST, instance=comment) comment = form.save() img.comments.add(comment) return HttpResponseRedirect('/profile/'+url+'/images/'+str(img_id)+'/view/')
def post_comment(request, url): user = request.user prof = get_object_or_404(UserProfile, url=url) other_user = prof.user if util.can_users_interract(user, other_user): if request.method == 'POST': comment = Comment.objects.create( author=user, read=False, sent = datetime.datetime.now() ) form = myforms.CommentForm(request.POST, instance=comment) comment = form.save() other_user.get_profile().comments.add(comment) return HttpResponseRedirect('/profile/'+other_user.get_profile().url+'/')
def reply(request, url, comment_id): user = request.user prof = get_object_or_404(UserProfile, url=url) other_user = prof.user if request.method == 'POST': if util.can_users_interract(user, other_user): comment = get_object_or_404(Comment, id=comment_id) subcomment = SubComment.objects.create( author=user, post=request.POST['post'], read=False, sent=datetime.datetime.now(), parent=comment, ) comment.subcomments.add(subcomment) return HttpResponseRedirect('/profile/' + other_user.get_profile().url)
def reply_to_comment(request, url, comment_id): user = request.user prof = get_object_or_404(UserProfile, url=url) other_user = prof.user if request.method == 'POST': if util.can_users_interract(user, other_user): comment = get_object_or_404(Comment, id=comment_id) subcomment = SubComment.objects.create( author=user, post=request.POST['post'], read=False, sent=datetime.datetime.now(), parent=comment, ) comment.subcomments.add(subcomment) return HttpResponseRedirect('/profile/'+other_user.get_profile().url)