28 lines
795 B
Python
28 lines
795 B
Python
from piccolo.table import Table
|
|
from piccolo.columns import ForeignKey, Timestamptz, Boolean, UUID, Bytea, Integer
|
|
from piccolo.columns.defaults.timestamptz import TimestamptzNow
|
|
from enum import Enum, auto
|
|
|
|
|
|
from .users import User
|
|
|
|
|
|
class EmailVerificationType(Enum):
|
|
"""
|
|
Enumeration of email verification
|
|
types
|
|
"""
|
|
|
|
PASSWORD_RESET: int = auto()
|
|
CHANGE_EMAIL: int = auto()
|
|
OTHER: int = auto()
|
|
|
|
|
|
class EmailVerification(Table, tablename="email_verifications"):
|
|
id = UUID(primary_key=True, null=False)
|
|
user = ForeignKey(references=User, null=False)
|
|
kind = Integer(choices=EmailVerificationType)
|
|
creation_date = Timestamptz(default=TimestamptzNow(), null=False)
|
|
pending = Boolean(default=True, null=False)
|
|
data = Bytea(default=None, null=True)
|