示例#1
0
文件: forms.py 项目: mmesiti/cogs3
 def clean(self):
     if self.cleaned_data.get('is_shibboleth_login_required'):
         try:
             Institution.is_valid_email_address(
                 self.cleaned_data.get('email'))
         except InvalidInstitutionalEmailAddress as e:
             raise forms.ValidationError(str(e))
示例#2
0
 def clean(self):
     cleaned_data = super().clean()
     is_shibboleth_login_required = cleaned_data.get(
         'is_shibboleth_login_required')
     email = cleaned_data.get('email')
     if is_shibboleth_login_required:
         try:
             Institution.is_valid_email_address(email)
         except InvalidInstitution as e:
             raise forms.ValidationError(str(e))
示例#3
0
 def test_invalid_institutional_email_address(self):
     with self.assertRaises(InvalidInstitutionalEmailAddress) as e:
         Institution.is_valid_email_address('*****@*****.**')
     self.assertEqual(str(e.exception),
                      'Email address domain is not supported.')
示例#4
0
 def test_valid_institutional_email_address(self):
     self.assertTrue(
         Institution.is_valid_email_address('*****@*****.**'))