2020-07-21 22:24:45 +02:00
|
|
|
from django.db import models
|
|
|
|
|
2020-07-22 00:51:40 +02:00
|
|
|
from users.models import CustomUser
|
2020-07-21 22:24:45 +02:00
|
|
|
|
|
|
|
|
|
|
|
class Event(models.Model):
|
2020-07-22 04:08:30 +02:00
|
|
|
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]}"
|
2020-07-21 22:24:45 +02:00
|
|
|
|
|
|
|
|
|
|
|
class EventRegistration(models.Model):
|
2020-07-22 04:08:30 +02:00
|
|
|
INTERESTED = "I"
|
|
|
|
ADMITTED = "A"
|
|
|
|
DENIED = "D"
|
2020-07-21 22:24:45 +02:00
|
|
|
REGISTRATION_STATE = (
|
2020-07-22 04:08:30 +02:00
|
|
|
(INTERESTED, "Interested"),
|
|
|
|
(ADMITTED, "Admitted"),
|
|
|
|
(DENIED, "Denied"),
|
2020-07-21 22:24:45 +02:00
|
|
|
)
|
2020-07-22 04:02:13 +02:00
|
|
|
event = models.ForeignKey(Event, on_delete=models.CASCADE)
|
|
|
|
user = models.ForeignKey(CustomUser, on_delete=models.CASCADE)
|
2020-07-22 01:44:14 +02:00
|
|
|
state = models.CharField(max_length=1, choices=REGISTRATION_STATE)
|
2020-07-22 04:02:13 +02:00
|
|
|
|
|
|
|
def __str__(self):
|
2020-07-22 04:13:20 +02:00
|
|
|
return f"Reservation[{self.user.username}:{self.event.date}:{self.state}]"
|