diff options
Diffstat (limited to 'models.py')
-rw-r--r-- | models.py | 8 |
1 files changed, 8 insertions, 0 deletions
@@ -2,6 +2,9 @@ from django.db import models from django.db.models import Q from django.utils.text import slugify +import hashlib +import os + class Timetable(models.Model): name = models.CharField(max_length=64, unique=True, verbose_name="nom") @@ -75,6 +78,11 @@ class Subscription(models.Model): active = models.BooleanField(verbose_name="activé", default=False) token = models.CharField(max_length=64, unique=True, default="") + def save(self): + if self.token == "": + self.token = hashlib.sha1(os.urandom(128)).hexdigest() + super(Subscription, self).save() + class Meta: index_together = ("group", "active",) |