Fix display of time of day
This commit is contained in:
parent
53a7e23b4f
commit
32b443cc81
2 changed files with 13 additions and 2 deletions
|
@ -14,10 +14,16 @@ class Event(models.Model):
|
|||
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]}"
|
||||
|
||||
|
||||
@property
|
||||
def time_str(self):
|
||||
return self.TIME_SLOTS[self.time]
|
||||
|
||||
|
||||
class EventRegistration(models.Model):
|
||||
INTERESTED = "I"
|
||||
ADMITTED = "A"
|
||||
|
@ -33,3 +39,8 @@ class EventRegistration(models.Model):
|
|||
|
||||
def __str__(self):
|
||||
return f"Reservation[{self.user.username}:{self.event.date}:{self.state}]"
|
||||
|
||||
|
||||
@property
|
||||
def state_str(self):
|
||||
return self.TIME_SLOTS[self.time]
|
||||
|
|
|
@ -3,12 +3,12 @@
|
|||
{% block content %}
|
||||
<ul>
|
||||
{% for event in events %}
|
||||
<li>{{ event.date }} {{ event.time }} (maximum {{ event.capacity }} mensen)
|
||||
<li>{{ event.date }} {{ event.time_str }} (maximum {{ event.capacity }} mensen)
|
||||
<ul>
|
||||
<form action="{% url 'events:register' event.id %}" method="post">
|
||||
{% csrf_token %}
|
||||
{% for regi in event.registration %}
|
||||
{{ regi.user.username }}: {{regi.state}}
|
||||
{{ regi.user.username }}: {{regi.state_str}}
|
||||
{% endfor %}
|
||||
<li><input type="submit" value="Ik wil komen"></li>
|
||||
</form>
|
||||
|
|
Loading…
Reference in a new issue