diff --git a/requirements.txt b/requirements.txt index 5bb5d2a..0254909 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,8 +1,8 @@ -Django==1.10.7 -docutils==0.13.1 -Pillow==4.0.0 -pytz==2016.7 -six==1.10.0 -sqlparse==0.2.2 -django-reversion==2.0.8 -django-bootstrap3==7.1.0 +Django==1.11.22 +docutils==0.14 +Pillow==5.4.1 +pytz==2019.1 +six==1.12.0 +sqlparse==0.2.4 +django-reversion==3.0.3 +django-bootstrap3==11.1.0 diff --git a/users/admin.py b/users/admin.py index 9d4a61b..b366f9f 100644 --- a/users/admin.py +++ b/users/admin.py @@ -17,7 +17,7 @@ class UserAdmin(admin.ModelAdmin): 'surname', 'pseudo', 'email', - 'state' + 'is_active' ) search_fields = ('name', 'surname', 'pseudo') diff --git a/users/forms.py b/users/forms.py index fe99657..c0047ae 100644 --- a/users/forms.py +++ b/users/forms.py @@ -120,7 +120,7 @@ class PasswordForm(ModelForm): class StateForm(ModelForm): class Meta: model = User - fields = ['state'] + fields = ['is_active'] class ClefForm(ModelForm): diff --git a/users/migrations/0012_auto_20190802_2112.py b/users/migrations/0012_auto_20190802_2112.py new file mode 100644 index 0000000..b390c45 --- /dev/null +++ b/users/migrations/0012_auto_20190802_2112.py @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10.7 on 2019-08-02 19:12 +from __future__ import unicode_literals + +from django.db import migrations +import users.models + + +class Migration(migrations.Migration): + + dependencies = [ + ('users', '0011_auto_20190802_1831'), + ] + + operations = [ + migrations.AlterModelManagers( + name='user', + managers=[ + ('objects', users.models.UserManager()), + ], + ), + migrations.RemoveField( + model_name='user', + name='state', + ), + ] diff --git a/users/models.py b/users/models.py index 5c02881..a4736af 100644 --- a/users/models.py +++ b/users/models.py @@ -14,15 +14,21 @@ from med.settings import MAX_EMPRUNT, REQ_EXPIRE_HRS class UserManager(BaseUserManager): - def _create_user(self, pseudo, name, surname, email, password=None, su=False): - if not pseudo: - raise ValueError('Users must have an username') + use_in_migrations = True + def _create_user(self, username, name, surname, email, password=None, su=False): + """ + Creates and saves a User with the given username, email and password. + """ + if not username: + raise ValueError('The given username must be set') + email = self.normalize_email(email) + username = self.model.normalize_username(username) user = self.model( - pseudo=pseudo, + pseudo=username, name=name, surname=surname, - email=self.normalize_email(email), + email=email, ) user.set_password(password) @@ -48,14 +54,6 @@ class UserManager(BaseUserManager): class User(AbstractBaseUser): PRETTY_NAME = "Utilisateurs" - STATE_ACTIVE = 0 - STATE_DISABLED = 1 - STATE_ARCHIVE = 2 - STATES = ( - (0, 'STATE_ACTIVE'), - (1, 'STATE_DISABLED'), - (2, 'STATE_ARCHIVE'), - ) name = models.CharField(max_length=255) surname = models.CharField(max_length=255) @@ -63,7 +61,6 @@ class User(AbstractBaseUser): telephone = models.CharField(max_length=15, null=True, blank=True) adresse = models.CharField(max_length=255, null=True, blank=True) maxemprunt = models.IntegerField(default=MAX_EMPRUNT, help_text="Maximum d'emprunts autorisés") - state = models.IntegerField(choices=STATES, default=STATE_ACTIVE) pseudo = models.CharField(max_length=32, unique=True, help_text="Doit contenir uniquement des lettres, chiffres, ou tirets. ") comment = models.CharField(help_text="Commentaire, promo", max_length=255, blank=True) diff --git a/users/templates/users/profil.html b/users/templates/users/profil.html index 861bb0c..c345e4a 100644 --- a/users/templates/users/profil.html +++ b/users/templates/users/profil.html @@ -93,12 +93,10 @@ with this program; if not, write to the Free Software Foundation, Inc.,