Example #1
0
def comment_detail(request, comment_id):
	if int(comment_id) > 0:
		comment_model=get_object_or_404(Comment, pk=comment_id)
	else:
		comment_model=Comment()
		comment_model.id = 0
	return render(request,'comp461app/comment_detail.html',{'comment_model':comment_model})
Example #2
0
def save_comment(request, comment_id):
	if not request.user.is_authenticated():
		return render(request,'comp461app/login.html',{})

	if not request.POST.get('note'):
		return_url_error = request.GET.get('return_url','/comment/%s' % comment_id)+'?errormessage=You must give a comment'
		return HttpResponseRedirect(return_url_error)

	comment_model = Comment()
	comment_model.id=comment_id
	comment_model.CreatedAt = request.POST.get('CreatedAt',datetime.now())
	comment_model.Note=request.POST.get('note','')
	comment_model.Picture_id= request.POST.get('picture_id')
	comment_model.CreatedBy_id=request.user.id
	comment_model.save()
	return HttpResponseRedirect(request.GET.get('return_url','/comment/%s' % comment_model.id))