mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-12-23 07:23:46 +00:00
Make the Adherent class the auth class
This commit is contained in:
parent
ef2ddf11de
commit
9381fef889
2 changed files with 35 additions and 21 deletions
|
@ -52,7 +52,7 @@ PASSWORD_HASHERS = (
|
|||
'django.contrib.auth.hashers.PBKDF2PasswordHasher',
|
||||
)
|
||||
|
||||
AUTH_USER_MODEL = 'users.User'
|
||||
AUTH_USER_MODEL = 'users.Adherent'
|
||||
LOGIN_URL = '/login/'
|
||||
LOGIN_REDIRECT_URL = '/'
|
||||
|
||||
|
|
|
@ -140,6 +140,7 @@ class UserManager(BaseUserManager):
|
|||
def _create_user(
|
||||
self,
|
||||
pseudo,
|
||||
name,
|
||||
surname,
|
||||
email,
|
||||
password=None,
|
||||
|
@ -152,6 +153,7 @@ class UserManager(BaseUserManager):
|
|||
raise ValueError('Username shall only contain [a-z0-9-]')
|
||||
|
||||
user = self.model(
|
||||
name=name,
|
||||
pseudo=pseudo,
|
||||
surname=surname,
|
||||
email=self.normalize_email(email),
|
||||
|
@ -163,19 +165,19 @@ class UserManager(BaseUserManager):
|
|||
user.make_admin()
|
||||
return user
|
||||
|
||||
def create_user(self, pseudo, surname, email, password=None):
|
||||
def create_user(self, pseudo, name, surname, email, password=None):
|
||||
"""
|
||||
Creates and saves a User with the given pseudo, name, surname, email,
|
||||
and password.
|
||||
"""
|
||||
return self._create_user(pseudo, surname, email, password, False)
|
||||
return self._create_user(pseudo, name, surname, email, password, False)
|
||||
|
||||
def create_superuser(self, pseudo, surname, email, password):
|
||||
def create_superuser(self, pseudo, name, surname, email, password):
|
||||
"""
|
||||
Creates and saves a superuser with the given pseudo, name, surname,
|
||||
email, and password.
|
||||
"""
|
||||
return self._create_user(pseudo, surname, email, password, True)
|
||||
return self._create_user(pseudo, name, surname, email, password, True)
|
||||
|
||||
|
||||
class User(AbstractBaseUser):
|
||||
|
@ -630,6 +632,7 @@ class User(AbstractBaseUser):
|
|||
'welcome_mail_en': mailmessageoptions.welcome_mail_en,
|
||||
'pseudo': self.pseudo,
|
||||
})
|
||||
try :
|
||||
send_mail(
|
||||
'Bienvenue au %(name)s / Welcome to %(name)s' % {
|
||||
'name': assooptions.name
|
||||
|
@ -639,6 +642,8 @@ class User(AbstractBaseUser):
|
|||
[self.email],
|
||||
html_message=template.render(context)
|
||||
)
|
||||
except:
|
||||
pass
|
||||
return
|
||||
|
||||
def reset_passwd_mail(self, request):
|
||||
|
@ -718,6 +723,7 @@ class User(AbstractBaseUser):
|
|||
'asso_email': assooptions.contact,
|
||||
'pseudo': self.pseudo,
|
||||
})
|
||||
try:
|
||||
send_mail(
|
||||
"Ajout automatique d'une machine / New machine autoregistered",
|
||||
'',
|
||||
|
@ -725,6 +731,8 @@ class User(AbstractBaseUser):
|
|||
[self.email],
|
||||
html_message=template.render(context)
|
||||
)
|
||||
except:
|
||||
pass
|
||||
return
|
||||
|
||||
def set_user_password(self, password):
|
||||
|
@ -761,6 +769,12 @@ class User(AbstractBaseUser):
|
|||
|
||||
class Adherent(User):
|
||||
PRETTY_NAME = "Adhérents"
|
||||
|
||||
USERNAME_FIELD = 'pseudo'
|
||||
REQUIRED_FIELDS = ['name', 'surname', 'email']
|
||||
|
||||
objects = UserManager()
|
||||
|
||||
name = models.CharField(max_length=255)
|
||||
room = models.OneToOneField(
|
||||
'topologie.Room',
|
||||
|
|
Loading…
Reference in a new issue