def dashboard(request): context = RequestContext(request) if not request.user.is_authenticated(): template = get_template('login.html') return HttpResponse(template.render(context)) context["user"] = request.user try: submission = Submission.objects.get(pk=request.user.id) except: submission = Submission(user=request.user) submission.save() if request.user.is_staff: template = get_template('staff_dashboard.html') return HttpResponse(template.render(context)) else: if request.method == 'POST': # form = SubmissionForm(request.POST, request.FILES) if all((x in request.FILES for x in ['app_form', 'app_info', 'con_form'])): newdoc = Version( application_form=request.FILES['app_form'], applicant_info=request.FILES['app_info'], consent_form=request.FILES['con_form'], submission=submission) newdoc.save() versions = Version.objects.filter(submission=submission) context["versions"] = versions context["submission"] = submission template = get_template('dashboard.html') return HttpResponse(template.render(context))
def list_files(request): # Handle file upload context = RequestContext(request) user = request.user context["user"] = user try: submission = Submission.objects.get(pk=user.id) except: submission = Submission(user=user) submission.save() if request.method == 'POST': # form = SubmissionForm(request.POST, request.FILES) if all((x in request.FILES for x in ['app_form', 'app_info', 'con_form'])): newdoc = Version( application_form=request.FILES['app_form'], applicant_info=request.FILES['app_info'], consent_form=request.FILES['con_form'], submission=submission) newdoc.save() return redirect('dashboard')