From 4d2ee8cf7710aefeb425c066a828124fbf1b76e4 Mon Sep 17 00:00:00 2001 From: PCoder Date: Wed, 20 Feb 2019 00:25:51 +0100 Subject: [PATCH] Add UserAccountValidationDetail model --- dal/models.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/dal/models.py b/dal/models.py index 7dee319..676b103 100644 --- a/dal/models.py +++ b/dal/models.py @@ -1,4 +1,6 @@ from django.db import models +from django.contrib.auth.hashers import make_password +from django.contrib.auth.models import User # Basic DB to correlate tokens, users and creation time @@ -13,3 +15,18 @@ class ResetToken(models.Model): # creation time in epoch (UTC) # BigInt just so we are save for the next few decades ;) creation = models.BigIntegerField() + + +def get_validation_slug(): + return make_password(None) + + +class UserAccountValidationDetail(models.Model): + user = models.OneToOneField(User, on_delete=models.CASCADE) + VALIDATED_CHOICES = ((0, 'Not validated'), (1, 'Validated')) + validated = models.IntegerField(choices=VALIDATED_CHOICES, default=0) + validation_slug = models.CharField( + db_index=True, unique=True, max_length=50, + default=get_validation_slug + ) + date_validation_started = models.DateTimeField(auto_now_add=True)