예제 #1
0
파일: tests.py 프로젝트: nbailey/quark
 def test_get_ldap_user_class(self):
     """Check that get_ldap_user returns an LDAPUser instance of the given
     user, without modifying the original object.
     """
     self.assertNotIsInstance(self.user, LDAPUser)
     make_ldap_user(self.user)
     self.assertIsInstance(self.user, LDAPUser)
     self.assertEqual(self.user.get_username(), self.username)
예제 #2
0
 def test_get_ldap_user_class(self):
     """Check that get_ldap_user returns an LDAPUser instance of the given
     user, without modifying the original object.
     """
     self.assertNotIsInstance(self.user, LDAPUser)
     make_ldap_user(self.user)
     self.assertIsInstance(self.user, LDAPUser)
     self.assertEqual(self.user.get_username(), self.username)
예제 #3
0
 def test_num_sql_queries(self):
     """Ensure that the method leads to no additional SQL queries changing
     the user to an instance of LDAPUser.
     """
     # pylint: disable=E1103
     with self.assertNumQueries(0):
         make_ldap_user(self.user)
         self.assertIsInstance(self.user, LDAPUser)
         self.assertEqual(self.user.get_username(), self.username)
예제 #4
0
파일: tests.py 프로젝트: nbailey/quark
 def test_num_sql_queries(self):
     """Ensure that the method leads to no additional SQL queries changing
     the user to an instance of LDAPUser.
     """
     # pylint: disable=E1103
     with self.assertNumQueries(0):
         make_ldap_user(self.user)
         self.assertIsInstance(self.user, LDAPUser)
         self.assertEqual(self.user.get_username(), self.username)
예제 #5
0
파일: forms.py 프로젝트: ochan1/quark
 def save(self, commit=True):
     # Call the ModelForm save method directly, since we are overriding the
     # Django UserCreationForm save() functionality here
     user = forms.ModelForm.save(self, commit=False)
     if USE_LDAP:
         # Create an entry in LDAP for this new user:
         ldap_utils.create_user(user.get_username(),
                                self.cleaned_data['password1'], user.email,
                                user.first_name, user.last_name)
         # Use the LDAPUser proxy model for this object
         make_ldap_user(user)
     user.set_password(self.cleaned_data['password1'])
     if commit:
         user.save()
     return user
예제 #6
0
파일: forms.py 프로젝트: nbailey/quark
 def save(self, commit=True):
     # Call the ModelForm save method directly, since we are overriding the
     # Django UserCreationForm save() functionality here
     user = forms.ModelForm.save(self, commit=False)
     if USE_LDAP:
         # Create an entry in LDAP for this new user:
         ldap_utils.create_user(
             user.get_username(), self.cleaned_data['password1'], user.email,
             user.first_name, user.last_name)
         # Use the LDAPUser proxy model for this object
         make_ldap_user(user)
     user.set_password(self.cleaned_data['password1'])
     if commit:
         user.save()
     return user
예제 #7
0
파일: forms.py 프로젝트: ochan1/quark
 def __init__(self, *args, **kwargs):
     super(MakeLDAPUserMixin, self).__init__(*args, **kwargs)
     if USE_LDAP and self.user:
         make_ldap_user(self.user)
예제 #8
0
파일: forms.py 프로젝트: nbailey/quark
 def __init__(self, *args, **kwargs):
     super(MakeLDAPUserMixin, self).__init__(*args, **kwargs)
     if USE_LDAP and self.user:
         make_ldap_user(self.user)