示例#1
0
文件: views.py 项目: ala23/Openethics
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))
示例#2
0
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))
示例#3
0
 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.'])
示例#4
0
文件: forms.py 项目: ala23/Openethics
    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.'])