models.py 900 B

123456789101112131415161718192021222324
  1. from datetime import timedelta
  2. import random
  3. from django.db import models
  4. def generate_random_url():
  5. # a-z, A-Z, 0-9, -, _
  6. characters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_'
  7. return ''.join(random.choice(characters) for i in range(6))
  8. class Event(models.Model):
  9. url = models.CharField(max_length=6, default=generate_random_url, unique=True)
  10. name = models.CharField(max_length=255)
  11. slot_interval = models.DurationField(default=timedelta(minutes=15))
  12. created_at = models.DateTimeField(auto_now_add=True)
  13. class Date(models.Model):
  14. event = models.ForeignKey(Event, on_delete=models.CASCADE)
  15. date = models.DateField()
  16. class Participant(models.Model):
  17. event = models.ForeignKey(Event, on_delete=models.CASCADE)
  18. name = models.CharField(max_length=255)
  19. pw_hash = models.CharField(max_length=255)
  20. slots = models.BinaryField()