2017-09-13 01:57:31 +02:00
|
|
|
from django.db import models
|
2017-09-25 17:16:19 +02:00
|
|
|
from django.utils.crypto import get_random_string
|
|
|
|
|
|
|
|
|
|
|
|
class GenericTeamTokenManager(models.Manager):
|
|
|
|
|
|
|
|
def create_token(self):
|
|
|
|
token = get_random_string(50)
|
|
|
|
while self.filter(token=token).exists():
|
|
|
|
token = get_random_string(50)
|
|
|
|
return self.create(token=token)
|
2017-09-13 01:57:31 +02:00
|
|
|
|
|
|
|
|
|
|
|
class GenericTeamToken(models.Model):
|
|
|
|
token = models.CharField(max_length=50, unique=True)
|
2017-09-25 17:16:19 +02:00
|
|
|
|
|
|
|
objects = GenericTeamTokenManager()
|