123456789101112131415161718192021222324 |
- from datetime import timedelta
- import random
- from django.db import models
- def generate_random_url():
- # a-z, A-Z, 0-9, -, _
- characters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_'
- return ''.join(random.choice(characters) for i in range(6))
- class Event(models.Model):
- url = models.CharField(max_length=6, default=generate_random_url, unique=True)
- name = models.CharField(max_length=255)
- slot_interval = models.DurationField(default=timedelta(minutes=15))
- created_at = models.DateTimeField(auto_now_add=True)
- class Date(models.Model):
- event = models.ForeignKey(Event, on_delete=models.CASCADE)
- date = models.DateField()
- class Participant(models.Model):
- event = models.ForeignKey(Event, on_delete=models.CASCADE)
- name = models.CharField(max_length=255)
- pw_hash = models.CharField(max_length=255)
- slots = models.BinaryField()
|