verification/api/models.py

19 lines
713 B
Python

from django.db.models import Model, ForeignKey, UUIDField, CharField, DateTimeField, CASCADE
from django.contrib.auth.models import User
from uuid import uuid4
from api.helpers import generate_token
# Create your models here.
class APIKey(Model):
user = ForeignKey(User, on_delete=CASCADE)
key = UUIDField(primary_key=True, default=uuid4, editable=False)
project = CharField(max_length=64)
class Mailing(Model):
uuid = UUIDField(primary_key=True, default=uuid4, editable=False)
user = ForeignKey(User, on_delete=CASCADE)
token = CharField(max_length=32, default=generate_token, editable=False)
reference = CharField(max_length=256)
timestamp = DateTimeField(auto_now_add=True)