trentpalmerdotorg/accounts/models.py

27 lines
759 B
Python
Raw Normal View History

2021-02-24 20:13:54 -08:00
from django.db import models
from tp.models import UUIDAsIDModel
from django.contrib.auth.models import User
from django.core.exceptions import ValidationError
def twitter_handle_validator(x):
if x[0] != '@':
raise ValidationError('twitter_handle must begin with "@"')
2021-02-24 20:13:54 -08:00
2021-03-05 17:19:28 -08:00
class EmailWhiteList(UUIDAsIDModel):
email = models.EmailField(unique=True)
def __str__(self):
return self.email
2021-02-24 20:13:54 -08:00
class Account(UUIDAsIDModel):
user = models.OneToOneField(User, on_delete=models.CASCADE, unique=True)
totp_key = models.CharField(max_length=16, null=True)
use_totp = models.BooleanField(default=False)
2021-03-28 15:51:55 -07:00
twitter_handle = models.CharField(max_length=64, default='@Twitter')
2021-02-24 20:13:54 -08:00
def __str__(self):
return str(self.user)