Ejemplo n.º 1
0
def reply(request, url, comment_id):
	user = request.user
	other_user = get_object_or_404(UserProfile, url=url).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)
Ejemplo n.º 2
0
def post(request, url):
	user = request.user
	other_user = request.user.get_profile().user
	if request.method == 'POST':
		if util.can_users_interract(user, other_user):
			comment = Comment.objects.create(
                    author=user,
                    read=False,
                    sent = datetime.datetime.now(),
					twitter_id = 2 #TODO: autogenerate or get from user.profile
                    )
			form = myforms.CommentForm(request.POST, instance=comment)
			comment = form.save()
			other_user.get_profile().comments.add(comment)
	return HttpResponseRedirect('/users/'+other_user.get_profile().url+'/')