Browse Source

Force email, first_name and last_name to be required by member model.

Fabs 10 years ago
parent
commit
39418af4da
1 changed files with 13 additions and 1 deletions
  1. 13 1
      coin/members/models.py

+ 13 - 1
coin/members/models.py

@@ -65,7 +65,7 @@ class Member(CoinLdapSyncMixin, AbstractUser):
 
     # Following fields are managed by the parent class AbstractUser :
     # username, first_name, last_name, email
-
+    
     # This property is used to change password in LDAP. Used in sync_to_ldap.
     # Should not be defined manually. Prefer use set_password method that hash
     # passwords for both ldap and local db
@@ -123,6 +123,9 @@ class Member(CoinLdapSyncMixin, AbstractUser):
         Calcul le username / ldap cn automatiquement en fonction
         du nom et du prénom
         """
+
+        print Member.REQUIRED_FIELDS
+
         # Première lettre de chaque partie du prénom
         first_name_letters = ''.join(
             [c[0] for c in self.first_name.split('-')]
@@ -203,6 +206,15 @@ class Member(CoinLdapSyncMixin, AbstractUser):
         verbose_name = 'membre'
 
 
+Member._meta.get_field('email')._unique = True
+Member._meta.get_field('email').blank = False
+Member._meta.get_field('email').null = False
+Member._meta.get_field('first_name').blank = False
+Member._meta.get_field('first_name').null = False
+Member._meta.get_field('last_name').blank = False
+Member._meta.get_field('last_name').null = False
+
+
 class CryptoKey(models.Model):
 
     KEY_TYPE_CHOICES = (('RSA', 'RSA'), ('GPG', 'GPG'))