def application_save(request, app_id): application = get_object_or_404(Application, id=app_id, profile=request.user.get_profile()) # application no longer valid? if not application.session.active: request.user.message_set.create( message= 'The application session has ended; you cannot edit your application any more.' ) return HttpResponseRedirect(reverse('applications')) if request.method == 'POST' and request.is_ajax(): form = ApplicationForm(request.POST, instance=application) if form.is_valid(): app = form.save() return HttpResponse("success") return render_to_response('apply/application/form.html', { 'application': application, 'form': form }, context_instance=RequestContext(request)) return HttpResponseForbidden()
def apply(request): ''' To avoid creating Users, Families and Students before a family is accepted, and to closely mimic the PDF application form, we store everything flat here. Later, if people are accepted, we copy fields from an app record into the appropriate models. ''' # Submit a new application if request.POST: form = ApplicationForm(request.POST, files=request.FILES) if form.is_valid(): # Don't commit the save until we've added in the fields we need to set app = form.save(commit=False) app.appdate = datetime.now() # If user is logged in, they are already a Crestmont family and this # app should be associated with that family if request.user.is_authenticated(): app.family = request.user.profile.family app.save() # Upon successful submit, redirect to the app fee view for this applicant. return HttpResponseRedirect(reverse('app_fee', args=[app.id])) else: # print form.errors pass else: form = ApplicationForm() return render_to_response('apply/apply.html', locals(), context_instance=RequestContext(request), )
def apply(request): """Display the form to add a new Application to the database.""" if request.method == 'POST': form = ApplicationForm(request.POST) if form.is_valid(): # All validation rules pass; form is savable. form.save() return http.HttpResponseRedirect(reverse('thanks')) else: form = ApplicationForm() return jingo.render(request, 'apply/apply.html', {'form': form})
def apply(request): if request.method == 'POST': form = ApplicationForm(request.POST) if form.is_valid(): p = form.save(commit=False) p.date = datetime.now() form.save() else: form = ApplicationForm() args = { 'form': form } return render(request, 'apply/apply.html', args)
def application_save(request, app_id): application = get_object_or_404(Application, id=app_id, profile=request.user.get_profile()) # application no longer valid? if not application.session.active: request.user.message_set.create(message='The application session has ended; you cannot edit your application any more.') return HttpResponseRedirect(reverse('applications')) if request.method == 'POST' and request.is_ajax(): form = ApplicationForm(request.POST, instance=application) if form.is_valid(): app = form.save() return HttpResponse("success") return render_to_response('apply/application/form.html', {'application': application, 'form': form }, context_instance=RequestContext(request)) return HttpResponseForbidden()