diff --git a/events/models.py b/events/models.py index 2fdd95b..a11360a 100644 --- a/events/models.py +++ b/events/models.py @@ -45,6 +45,32 @@ class TimeSlot(models.Model): def count_admitted(self): return self.count_with_status(EventRegistration.ADMITTED) + + def precision(self): + # TODO put this in a database field? + return 10 + + def lower_round(self, n): + return (n // self.precision()) * self.precision() + + def upper_round(self, n): + return ((n + self.precision()) // self.precision()) * self.precision() + + # Unfortunately, Django doesn't support arguments in templates + + def lower_interested(self): + return self.lower_round(self.count_interested()) + + def upper_interested(self): + return self.upper_round(self.count_interested()) + + def lower_admitted(self): + return self.lower_round(self.count_admitted()) + + def upper_admitted(self): + return self.upper_round(self.count_admitted()) + + def registration_of(self, user): if not user.is_authenticated: return None diff --git a/events/templates/events/registrations.html b/events/templates/events/registrations.html index c8591a6..a6331e7 100644 --- a/events/templates/events/registrations.html +++ b/events/templates/events/registrations.html @@ -4,8 +4,8 @@
{% endif %} {% csrf_token %} -

{{ timeslot.time_str }}, {{ timeslot.count_admitted }}/{{ event.capacity }} bevestigd{% if timeslot.count_interested %}, - {{ timeslot.count_interested }} op wachtlijst +

{{ timeslot.time_str }}, tussen {{ timeslot.lower_admitted }} en {{ timeslot.upper_admitted }} van de mogelijke {{ event.capacity }} aanwezigheden bevestigd{% if timeslot.count_interested %}, + tussen {{ timeslot.lower_interested }} en {{ timeslot.upper_interested }} mensen op wachtlijst {% endif %}