Set default value for validation_slug
This commit is contained in:
		
					parent
					
						
							
								adb0db101d
							
						
					
				
			
			
				commit
				
					
						74f213e1d5
					
				
			
		
					 2 changed files with 31 additions and 2 deletions
				
			
		| 
						 | 
				
			
			@ -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…
	
	Add table
		Add a link
		
	
		Reference in a new issue