diff --git a/opentech/apply/users/migrations/0004_drop_first_last_names.py b/opentech/apply/users/migrations/0004_drop_first_last_names.py index ec7153baa24162992048f4b14eae6066be2cbc10..19a541f53a5bc945fc4b06d3c243549481e9abb2 100644 --- a/opentech/apply/users/migrations/0004_drop_first_last_names.py +++ b/opentech/apply/users/migrations/0004_drop_first_last_names.py @@ -12,10 +12,6 @@ class Migration(migrations.Migration): ] operations = [ - migrations.AlterModelOptions( - name='user', - options={'ordering': ['id']}, - ), migrations.RemoveField( model_name='user', name='first_name', @@ -29,9 +25,4 @@ class Migration(migrations.Migration): name='full_name', field=models.CharField(blank=True, max_length=255, verbose_name='Full name'), ), - migrations.AlterField( - model_name='user', - name='email', - field=models.EmailField(max_length=255, unique=True, verbose_name='email address'), - ), ] diff --git a/opentech/apply/users/models.py b/opentech/apply/users/models.py index 1ab13471d2e7e45a79317063e9bfc0a1d5078720..a2e867bef9a866c028dbb5f02014f4f87baf9518 100644 --- a/opentech/apply/users/models.py +++ b/opentech/apply/users/models.py @@ -1,7 +1,5 @@ from django.db import models -from django.contrib.auth.models import AbstractBaseUser, BaseUserManager, PermissionsMixin -from django.core.mail import send_mail -from django.utils import timezone +from django.contrib.auth.models import AbstractUser, BaseUserManager from django.utils.translation import gettext_lazy as _ from .utils import send_activation_email @@ -46,32 +44,20 @@ class UserManager(BaseUserManager): return user, created -class User(AbstractBaseUser, PermissionsMixin): - email = models.EmailField(_('email address'), max_length=255, unique=True) +class User(AbstractUser): + email = models.EmailField(_('email address'), unique=True) full_name = models.CharField(verbose_name='Full name', max_length=255, blank=True) - is_staff = models.BooleanField( - verbose_name='staff status', - default=False, - help_text='Designates whether the user can log into this admin site.', - ) - is_active = models.BooleanField( - verbose_name='active', - default=True, - help_text='Designates whether this user should be treated as active. ' - 'Unselect this instead of deleting accounts.', - ) - date_joined = models.DateTimeField(verbose_name='date joined', default=timezone.now) USERNAME_FIELD = 'email' REQUIRED_FIELDS = [] - # Remove the username field which is no longer used + # Remove the username/first/last name field which is no longer used. username = None + first_name = None + last_name = None objects = UserManager() - class Meta: - ordering = ['id'] def __str__(self): return self.get_full_name() @@ -81,7 +67,3 @@ class User(AbstractBaseUser, PermissionsMixin): def get_short_name(self): return self.email - - def email_user(self, subject, message, from_email=None, **kwargs): - """Send an email to this user.""" - send_mail(subject, message, from_email, [self.email], **kwargs)