diff --git a/AKModel/models.py b/AKModel/models.py index e581f00d2679cd7972540eca0d543384ddde1d94..a6254aaa1a190cbfed9d420734a7fa43bcf90107 100644 --- a/AKModel/models.py +++ b/AKModel/models.py @@ -336,6 +336,15 @@ class AKSlot(models.Model): return f"{self.ak} @ {self.start_simplified} in {self.room}" return f"{self.ak} @ {self.start_simplified}" + @property + def duration_simplified(self): + """ + Display duration of slot in format hours:minutes, e.g. 1.5 -> "1:30" + """ + hours = int(self.duration) + minutes = (self.duration * 60) % 60 + return '%d:%02d' % (hours, minutes) + @property def start_simplified(self): """ @@ -345,6 +354,21 @@ class AKSlot(models.Model): return _("Not scheduled yet") return self.start.astimezone(self.event.timezone).strftime('%a %H:%M') + @property + def time_simplified(self): + """ + Display start and end time of slot in format weekday + time, e.g. "Fri 14:00 - 15:30" or "Fri 22:00 - Sat 02:00" + """ + if self.start is None: + return _("Not scheduled yet") + result = self.start.astimezone(self.event.timezone).strftime('%a %H:%M') + result += ' - ' + if self.start.astimezone(self.event.timezone).day == self.end.astimezone(self.event.timezone).day: + result += self.end.astimezone(self.event.timezone).strftime('%H:%M') + else: + result += self.end.astimezone(self.event.timezone).strftime('%a %H:%M') + return result + @property def end(self): """ diff --git a/AKSubmission/templates/AKSubmission/ak_detail.html b/AKSubmission/templates/AKSubmission/ak_detail.html index e45444b94e29350d1d3dfbb0fddaa07cb3d93ff7..d9d661ff93366a066fe29082fd22d7ac66552c28 100644 --- a/AKSubmission/templates/AKSubmission/ak_detail.html +++ b/AKSubmission/templates/AKSubmission/ak_detail.html @@ -174,9 +174,11 @@ <table class="table"> <thead> <tr> - <th>{% trans "Duration" %}</th> {% if not ak.event.plan_hidden or user.is_staff %} <th>{% trans "When?" %}</th> + {% endif %} + <th>{% trans "Duration" %}</th> + {% if not ak.event.plan_hidden or user.is_staff %} <th>{% trans "Room" %}</th> {% endif %} <th></th> @@ -185,9 +187,11 @@ <tbody> {% for slot in ak.akslot_set.all %} <tr> - <td>{{ slot.duration }}</td> {% if not ak.event.plan_hidden or user.is_staff %} - <td>{{ slot.start_simplified }}</td> + <td>{{ slot.time_simplified }}</td> + {% endif %} + <td>{{ slot.duration_simplified }}</td> + {% if not ak.event.plan_hidden or user.is_staff %} <td> {% if "AKPlan"|check_app_installed and slot.room %} <a href="{% url 'plan:plan_room' event_slug=ak.event.slug pk=slot.room.pk %}">{{ slot.room }}</a>