Set default value for validation_slug
This commit is contained in:
parent
adb0db101d
commit
74f213e1d5
2 changed files with 31 additions and 2 deletions
21
membership/migrations/0007_auto_20180213_0128.py
Normal file
21
membership/migrations/0007_auto_20180213_0128.py
Normal file
|
@ -0,0 +1,21 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.9.4 on 2018-02-13 01:28
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
import membership.models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('membership', '0006_auto_20160526_0445'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='customuser',
|
||||
name='validation_slug',
|
||||
field=models.CharField(db_index=True, default=membership.models.get_validation_slug, max_length=50, unique=True),
|
||||
),
|
||||
]
|
|
@ -59,6 +59,10 @@ class MyUserManager(BaseUserManager):
|
|||
return user
|
||||
|
||||
|
||||
def get_validation_slug():
|
||||
return make_password(None)
|
||||
|
||||
|
||||
class CustomUser(AbstractBaseUser, PermissionsMixin):
|
||||
VALIDATED_CHOICES = ((0, 'Not validated'), (1, 'Validated'))
|
||||
site = models.ForeignKey(Site, default=1)
|
||||
|
@ -66,8 +70,12 @@ class CustomUser(AbstractBaseUser, PermissionsMixin):
|
|||
email = models.EmailField(unique=True)
|
||||
|
||||
validated = models.IntegerField(choices=VALIDATED_CHOICES, default=0)
|
||||
validation_slug = models.CharField(db_index=True, unique=True,
|
||||
max_length=50)
|
||||
# By default, we initialize the validation_slug with appropriate value
|
||||
# This is required for User(page) admin
|
||||
validation_slug = models.CharField(
|
||||
db_index=True, unique=True, max_length=50,
|
||||
default=get_validation_slug
|
||||
)
|
||||
is_admin = models.BooleanField(
|
||||
_('staff status'),
|
||||
default=False,
|
||||
|
|
Loading…
Reference in a new issue