Don't show list of people, scrap "denied"

When the event is full, people can just stay "interested".
This commit is contained in:
Midgard 2020-07-22 05:32:48 +02:00
parent 80dab2c4e3
commit 84a46989ac
Signed by: midgard
GPG key ID: 511C112F1331BBB4
2 changed files with 15 additions and 8 deletions

View file

@ -19,19 +19,28 @@ class Event(models.Model):
return f"{self.date} {self.TIME_SLOTS[self.time]}" return f"{self.date} {self.TIME_SLOTS[self.time]}"
@property
def time_str(self): def time_str(self):
return Event.TIME_SLOTS[self.time] return Event.TIME_SLOTS[self.time]
def count_with_status(self, status):
return self.eventregistration_set.filter(state=status).count()
def count_interested(self):
return self.count_with_status(EventRegistration.INTERESTED)
def count_admitted(self):
return self.count_with_status(EventRegistration.ADMITTED)
class EventRegistration(models.Model): class EventRegistration(models.Model):
INTERESTED = "I" INTERESTED = "I"
ADMITTED = "A" ADMITTED = "A"
DENIED = "D"
REGISTRATION_STATE = { REGISTRATION_STATE = {
INTERESTED: "Interested", INTERESTED: "Interested",
ADMITTED: "Admitted", ADMITTED: "Admitted",
DENIED: "Denied",
} }
event = models.ForeignKey(Event, on_delete=models.CASCADE) event = models.ForeignKey(Event, on_delete=models.CASCADE)
user = models.ForeignKey(CustomUser, on_delete=models.CASCADE) user = models.ForeignKey(CustomUser, on_delete=models.CASCADE)
@ -41,6 +50,5 @@ class EventRegistration(models.Model):
return f"Reservation[{self.user.username}:{self.event.date}:{self.state}]" return f"Reservation[{self.user.username}:{self.event.date}:{self.state}]"
@property
def state_str(self): def state_str(self):
return EventRegistration.REGISTRATION_STATE[self.state] return EventRegistration.REGISTRATION_STATE[self.state]

View file

@ -3,13 +3,12 @@
{% block content %} {% block content %}
<ul> <ul>
{% for event in events %} {% for event in events %}
<li id="{{event.id}}">{{ event.date }} {{ event.time_str }} (maximum {{ event.capacity }} mensen) <li id="{{event.id}}">{{ event.date }} {{ event.time_str }}
<form action="{% url 'events:register' event.id %}" method="post"> <form action="{% url 'events:register' event.id %}" method="post">
<ul> <ul>
{% csrf_token %} {% csrf_token %}
{% for regi in event.eventregistration_set.all %} <li>{{ event.count_admitted }}/{{ event.capacity }} bevestigd</li>
<li>{{ regi.user.username }}: {{regi.state_str}}</li> <li>{{ event.count_interested }} geïnteresseerd</li>
{% endfor %}
<li><input type="submit" value="Ik wil komen"></li> <li><input type="submit" value="Ik wil komen"></li>
</ul> </ul>
</form> </form>