def report_new(request): """ The user files a report for a task to which they were not previously assigned. """ if request.method == "GET": form = AssignmentForm() elif request.method == "POST": form = AssignmentForm(request.POST) if form.is_valid(): a = form.save(commit=False) a.user = request.user a.save() messages.success(request, 'You have filed your report, thanks!') return HttpResponseRedirect(reverse('home')) return render_to_response('report_form.html', locals(), context_instance=RequestContext(request))
def report_edit(request, reportid): """ Users file a report for what they did. """ try: a = Assignment.objects.get(id=reportid) except: message.error(request, 'There was a problem finding the requested report (id=%d)' % reportid) return HttpResponseRedirect(reverse('report_list')) if request.method == "GET": form = AssignmentForm(instance=a) elif request.method == "POST": form = AssignmentForm(request.POST, instance=a) if form.is_valid(): form.save() messages.success(request, 'You have filed your report, thanks!') return HttpResponseRedirect(reverse('home')) return render_to_response('report_form.html', locals(), context_instance=RequestContext(request))