Verified Commit b541f702 authored by erdnaxe's avatar erdnaxe 🎇

Remove user states

parent 0ff7a1ea
Pipeline #1390 failed with stage
in 3 minutes and 8 seconds
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
......@@ -17,7 +17,7 @@ class UserAdmin(admin.ModelAdmin):
'surname',
'pseudo',
'email',
'state'
'is_active'
)
search_fields = ('name', 'surname', 'pseudo')
......
......@@ -120,7 +120,7 @@ class PasswordForm(ModelForm):
class StateForm(ModelForm):
class Meta:
model = User
fields = ['state']
fields = ['is_active']
class ClefForm(ModelForm):
......
# -*- 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',
),
]
......@@ -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)
......
......@@ -93,12 +93,10 @@ with this program; if not, write to the Free Software Foundation, Inc.,
</tr>
<tr>
<th>Statut</th>
{% if user.state == 0 %}
{% if user.is_active %}
<td><font color="green">Actif</font></td>
{% elif user.state == 1 %}
<td><font color="red">Désactivé</font></td>
{% else %}
<td><font color="orange">Archivé</font></td>
<td><font color="red">Désactivé</font></td>
{% endif %}
<th>Dernière connexion</th>
<td>{{ user.last_login }}</td>
......
......@@ -377,7 +377,7 @@ def index_adhesion(request):
@permission_required('perm')
def index(request):
""" Affiche l'ensemble des users, need droit admin """
users_list = User.objects.order_by('state', 'name')
users_list = User.objects.order_by('name')
paginator = Paginator(users_list, PAGINATION_NUMBER)
page = request.GET.get('page')
try:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment