From 32b443cc81509c6d0f51ca4de1304cf2634bfeed Mon Sep 17 00:00:00 2001 From: Midgard Date: Wed, 22 Jul 2020 04:24:01 +0200 Subject: [PATCH] Fix display of time of day --- events/models.py | 11 +++++++++++ events/templates/events/index.html | 4 ++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/events/models.py b/events/models.py index 92c3b59..6dceccb 100644 --- a/events/models.py +++ b/events/models.py @@ -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] diff --git a/events/templates/events/index.html b/events/templates/events/index.html index 2a03009..850bc6c 100644 --- a/events/templates/events/index.html +++ b/events/templates/events/index.html @@ -3,12 +3,12 @@ {% block content %}