def create_application(request): ''' This view function will be used to create a new ethics application. Login is required as the principle investigator for the new application will be set as the logged in user that is creating it. All valid users of the system should be able to create ethics applications. ''' if request.method == 'POST': form = EthicsApplicationForm(request.POST) if (form.is_valid()): new_application = form.instance new_application.principle_investigator = request.user new_application.save() return HttpResponseRedirect( reverse('application_view', kwargs={'application_id': new_application.id})) else: form = EthicsApplicationForm() return render_to_response('ethicsapplication/create.html', {'form': form}, context_instance=RequestContext(request))
def create_application(request): ''' This view function will be used to create a new ethics application. Login is required as the principle investigator for the new application will be set as the logged in user that is creating it. All valid users of the system should be able to create ethics applications. ''' if request.method == 'POST': form = EthicsApplicationForm(request.POST) if (form.is_valid()): new_application = form.instance new_application.principle_investigator = request.user new_application.save() return HttpResponseRedirect(reverse('application_view', kwargs={'application_id':new_application.id})) else: form = EthicsApplicationForm() return render_to_response('ethicsapplication/create.html', {'form':form}, context_instance=RequestContext(request))
def test_EthicsApplication_form_title_must_be_present(self): ''' The form must require a non blank string for the title field. ''' incorrect_data = {'data': {'title': '',}} form = EthicsApplicationForm(incorrect_data) #form.is_valid() #JA - don't think we need this call self.assertFalse(form.is_valid()) self.assertEqual(form.errors['title'], [u'This field is required.'])
def test_EthicsApplication_form_title_must_be_present(self): ''' The form must require a non blank string for the title field. ''' incorrect_data = { 'data': { 'title': '', } } form = EthicsApplicationForm(incorrect_data) #form.is_valid() #JA - don't think we need this call self.assertFalse(form.is_valid()) self.assertEqual(form.errors['title'], [u'This field is required.'])