Пример #1
0
def success(request):
	current_user = request.user
	if request.POST:
		edit_form = EditForm(current_user, request.POST)
	if edit_form.is_valid():
		edit_form.save()
	return render(request, 'SecureWitness/success.html')
Пример #2
0
def editReport(request):
	current_user = request.user
	context = RequestContext(request)
	if request.POST:
		rid = request.POST['rid']
		report = Report.objects.get(pk=rid)
		edit_form = EditForm(current_user, request.POST, instance=report)
		if edit_form.is_valid():
			edit_form.save()
			return render_to_response('SecureWitness/success.html')
	
	try:
		report_id = request.GET['report']
		report = Report.objects.get(pk=report_id)
	except Report.DoesNotExist:
		raise Http404("Report does not exist")
	else:
		edit_form = EditForm(current_user, instance=report)
	delete_report_form = DeleteReportForm(report_id)
	comment_form = CommentForm(initial = {'author':current_user, 'report':report})
	comments = Comment.objects.filter(report = report).order_by('-pub_date')[:10]
	delete_comment_form = DeleteCommentForm(comments)
	shared_groups = report.groups.all()
	group_form = GroupForm()
	return render_to_response('SecureWitness/editReport.html', {'report_id':report_id,'edit_form':edit_form, 'report':report, 'comment_form':comment_form, 'comments': comments, 'shared_groups': shared_groups, 'group_form': group_form, 'delete_report_form': delete_report_form, 'delete_comment_form': delete_comment_form}, context)