From 97b5469ac7a97b60b35f497a84cd17bfd54c0ca7 Mon Sep 17 00:00:00 2001 From: Alexandre Iooss Date: Fri, 2 Aug 2019 18:37:54 +0200 Subject: [PATCH] Add is_staff and is_active to User --- .gitignore | 3 -- med/urls.py | 8 ++---- media/migrations/0009_auto_20190802_1455.py | 31 +++++++++++++++++++++ users/migrations/0010_auto_20190802_1455.py | 19 +++++++++++++ users/migrations/0011_auto_20190802_1831.py | 25 +++++++++++++++++ users/models.py | 21 ++++++++------ 6 files changed, 90 insertions(+), 17 deletions(-) create mode 100644 media/migrations/0009_auto_20190802_1455.py create mode 100644 users/migrations/0010_auto_20190802_1455.py create mode 100644 users/migrations/0011_auto_20190802_1831.py diff --git a/.gitignore b/.gitignore index 3ca9f00..8c98779 100644 --- a/.gitignore +++ b/.gitignore @@ -37,6 +37,3 @@ static_files/* env/ venv/ db.sqlite3 - -# Ignore migrations during first phase dev -migrations/ diff --git a/med/urls.py b/med/urls.py index 7912e7a..b728fe8 100644 --- a/med/urls.py +++ b/med/urls.py @@ -4,6 +4,7 @@ from django.conf.urls import include, url from django.contrib import admin +from django.contrib.auth.views import password_reset from django.shortcuts import render from django.views.generic import RedirectView @@ -25,13 +26,8 @@ urlpatterns = [ url(r'^logs/', include('logs.urls', namespace='logs')), # Include Django Contrib and Core routers - # TODO: fix django contrib auth password reset - # from django.contrib.auth.views import password_reset - # url(r'^accounts/password_reset/$', - # password_reset, name='admin_password_reset'), url(r'^accounts/password_reset/$', - RedirectView.as_view(pattern_name='users:reset-password'), - name='admin_password_reset'), + password_reset, name='admin_password_reset'), url(r'^i18n/', include('django.conf.urls.i18n')), url(r'^accounts/', include('django.contrib.auth.urls')), url(r'^accounts/profile/', diff --git a/media/migrations/0009_auto_20190802_1455.py b/media/migrations/0009_auto_20190802_1455.py new file mode 100644 index 0000000..d5843c7 --- /dev/null +++ b/media/migrations/0009_auto_20190802_1455.py @@ -0,0 +1,31 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10.7 on 2019-08-02 12:55 +from __future__ import unicode_literals + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('media', '0008_auto_20170704_2047'), + ] + + operations = [ + migrations.AlterModelOptions( + name='auteur', + options={'verbose_name': 'author', 'verbose_name_plural': 'authors'}, + ), + migrations.AlterModelOptions( + name='emprunt', + options={'verbose_name': 'borrowed item', 'verbose_name_plural': 'borrowed items'}, + ), + migrations.AlterModelOptions( + name='jeu', + options={'verbose_name': 'game', 'verbose_name_plural': 'games'}, + ), + migrations.AlterModelOptions( + name='media', + options={'verbose_name': 'medium', 'verbose_name_plural': 'media'}, + ), + ] diff --git a/users/migrations/0010_auto_20190802_1455.py b/users/migrations/0010_auto_20190802_1455.py new file mode 100644 index 0000000..20571a6 --- /dev/null +++ b/users/migrations/0010_auto_20190802_1455.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10.7 on 2019-08-02 12:55 +from __future__ import unicode_literals + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('users', '0009_auto_20171114_2303'), + ] + + operations = [ + migrations.AlterModelOptions( + name='right', + options={'verbose_name': 'right', 'verbose_name_plural': 'rights'}, + ), + ] diff --git a/users/migrations/0011_auto_20190802_1831.py b/users/migrations/0011_auto_20190802_1831.py new file mode 100644 index 0000000..b00e0e8 --- /dev/null +++ b/users/migrations/0011_auto_20190802_1831.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10.7 on 2019-08-02 16:31 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('users', '0010_auto_20190802_1455'), + ] + + operations = [ + migrations.AddField( + model_name='user', + name='is_active', + field=models.BooleanField(default=True, help_text='Designates whether this user should be treated as active. Unselect this instead of deleting accounts.', verbose_name='active'), + ), + migrations.AddField( + model_name='user', + name='is_staff', + field=models.BooleanField(default=False, help_text='Designates whether the user can log into this admin site.', verbose_name='staff status'), + ), + ] diff --git a/users/models.py b/users/models.py index 6895b24..5c02881 100644 --- a/users/models.py +++ b/users/models.py @@ -67,6 +67,19 @@ class User(AbstractBaseUser): 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) + is_staff = models.BooleanField( + _('staff status'), + default=False, + help_text=_('Designates whether the user can log into this admin site.'), + ) + is_active = models.BooleanField( + _('active'), + default=True, + help_text=_( + 'Designates whether this user should be treated as active. ' + 'Unselect this instead of deleting accounts.' + ), + ) registered = models.DateTimeField(auto_now_add=True) USERNAME_FIELD = 'pseudo' @@ -74,14 +87,6 @@ class User(AbstractBaseUser): objects = UserManager() - @property - def is_active(self): - return self.state == self.STATE_ACTIVE - - @property - def is_staff(self): - return self.is_admin - @property def is_admin(self): try: