kers/events/models.py

23 lines
629 B
Python
Raw Normal View History

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):
date = models.DateTimeField()
capacity = models.IntegerField()
class EventRegistration(models.Model):
REGISTRATION_STATE = (
('I', 'Interested'),
('A', 'Admitted'),
('D', 'Denied'),
)
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):
return f'Reservation[{self.user.username}:{self.event.date}:{self.state}]'