Don't show list of people, scrap "denied"
When the event is full, people can just stay "interested".
This commit is contained in:
parent
80dab2c4e3
commit
84a46989ac
2 changed files with 15 additions and 8 deletions
|
@ -19,19 +19,28 @@ class Event(models.Model):
|
|||
return f"{self.date} {self.TIME_SLOTS[self.time]}"
|
||||
|
||||
|
||||
@property
|
||||
def time_str(self):
|
||||
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):
|
||||
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)
|
||||
|
@ -41,6 +50,5 @@ class EventRegistration(models.Model):
|
|||
return f"Reservation[{self.user.username}:{self.event.date}:{self.state}]"
|
||||
|
||||
|
||||
@property
|
||||
def state_str(self):
|
||||
return EventRegistration.REGISTRATION_STATE[self.state]
|
||||
|
|
|
@ -3,13 +3,12 @@
|
|||
{% block content %}
|
||||
<ul>
|
||||
{% 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">
|
||||
<ul>
|
||||
{% csrf_token %}
|
||||
{% for regi in event.eventregistration_set.all %}
|
||||
<li>{{ regi.user.username }}: {{regi.state_str}}</li>
|
||||
{% endfor %}
|
||||
<li>{{ event.count_admitted }}/{{ event.capacity }} bevestigd</li>
|
||||
<li>{{ event.count_interested }} geïnteresseerd</li>
|
||||
<li><input type="submit" value="Ik wil komen"></li>
|
||||
</ul>
|
||||
</form>
|
||||
|
|
Loading…
Reference in a new issue