from django.db import models from users.models import CustomUser class Event(models.Model): MORNING, AFTERNOON, EVENING = range(3) TIME_SLOTS = { MORNING: "Voormiddag", AFTERNOON: "Namiddag", EVENING: "Avond", } date = models.DateField() time = models.IntegerField(choices=TIME_SLOTS.items(), default=MORNING) capacity = models.IntegerField(default=6) def __str__(self): return f"{self.date} {self.TIME_SLOTS[self.time]}" class EventRegistration(models.Model): INTERESTED = "I" ADMITTED = "A" DENIED = "D" REGISTRATION_STATE = ( (INTERESTED, "Interested"), (ADMITTED, "Admitted"), (DENIED, "Denied"), ) event = models.ForeignKey(Event, on_delete=models.CASCADE) user = models.ForeignKey(CustomUser, on_delete=models.CASCADE) state = models.CharField(max_length=1, choices=REGISTRATION_STATE) def __str__(self): return f"Reservation[{self.user.username}:{self.event.date}:{self.state}]"