X-Git-Url: https://git.mdrn.pl/edumed.git/blobdiff_plain/b154d06ff9d6b7fa711607bc02d03fb9db5c6d33..61bff0638c1eba23b9bee153eafa1d9c05749be5:/wtem/models.py diff --git a/wtem/models.py b/wtem/models.py index 4a42c30..30539b2 100644 --- a/wtem/models.py +++ b/wtem/models.py @@ -6,6 +6,8 @@ from django.db import models from contact.models import Contact +DEBUG_KEY = '12345' + class Submission(models.Model): contact = models.ForeignKey(Contact, null = True) key = models.CharField(max_length = 30, unique = True) @@ -17,7 +19,7 @@ class Submission(models.Model): @classmethod def generate_key(cls): key = '' - while not key and key in [record['key'] for record in cls.objects.values('key')]: + while not key or key in [record['key'] for record in cls.objects.values('key')]: key = ''.join(random.choice(string.ascii_uppercase + string.ascii_lowercase + string.digits) for i in range(30)) return key