Set default value for validation_slug

This commit is contained in:
M.Ravi 2018-02-13 02:37:03 +01:00
parent adb0db101d
commit 74f213e1d5
2 changed files with 31 additions and 2 deletions

View 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),
),
]

View file

@ -59,6 +59,10 @@ class MyUserManager(BaseUserManager):
return user return user
def get_validation_slug():
return make_password(None)
class CustomUser(AbstractBaseUser, PermissionsMixin): class CustomUser(AbstractBaseUser, PermissionsMixin):
VALIDATED_CHOICES = ((0, 'Not validated'), (1, 'Validated')) VALIDATED_CHOICES = ((0, 'Not validated'), (1, 'Validated'))
site = models.ForeignKey(Site, default=1) site = models.ForeignKey(Site, default=1)
@ -66,8 +70,12 @@ class CustomUser(AbstractBaseUser, PermissionsMixin):
email = models.EmailField(unique=True) email = models.EmailField(unique=True)
validated = models.IntegerField(choices=VALIDATED_CHOICES, default=0) validated = models.IntegerField(choices=VALIDATED_CHOICES, default=0)
validation_slug = models.CharField(db_index=True, unique=True, # By default, we initialize the validation_slug with appropriate value
max_length=50) # 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( is_admin = models.BooleanField(
_('staff status'), _('staff status'),
default=False, default=False,