24 lines
540 B
Python
24 lines
540 B
Python
|
from django.db import models
|
||
|
|
||
|
from konova.utils.generators import generate_token
|
||
|
|
||
|
|
||
|
class APIUserToken(models.Model):
|
||
|
token = models.CharField(
|
||
|
primary_key=True,
|
||
|
max_length=1000,
|
||
|
default=generate_token,
|
||
|
)
|
||
|
valid_until = models.DateField(
|
||
|
blank=True,
|
||
|
null=True,
|
||
|
help_text="Token is only valid until this date",
|
||
|
)
|
||
|
is_active = models.BooleanField(
|
||
|
default=False,
|
||
|
help_text="Must be activated by an admin"
|
||
|
)
|
||
|
|
||
|
def __str__(self):
|
||
|
return self.token
|