diff --git a/AKModel/models.py b/AKModel/models.py index 9c7b0091e004ddf5d6495d6b78563788542c9d96..e614ea0b540bf9a3dae51baa59cf8233e1e636c0 100644 --- a/AKModel/models.py +++ b/AKModel/models.py @@ -336,6 +336,14 @@ 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, minutes = divmod(self.duration * 60, 60) + return f"{hours}:{minutes:2.0f}" + @property def start_simplified(self): """ @@ -345,6 +353,19 @@ 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") + + start = self.start.astimezone(self.event.timezone) + end = self.end.astimezone(self.event.timezone) + + return f"{start.strftime('%a %H:%M')} - {end.strftime('%H:%M') if start.day == end.day else end.strftime('%a %H:%M')}" + @property def end(self): """ diff --git a/AKSubmission/templates/AKSubmission/ak_detail.html b/AKSubmission/templates/AKSubmission/ak_detail.html index 379ad63c940e99742062365b60c70a67236e3a0b..defc5eafe5a38e4027729f921f2196f07a9998c2 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,14 +187,20 @@ <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> + {% if slot.room %} + {% if "AKPlan"|check_app_installed %} + <a href="{% url 'plan:plan_room' event_slug=ak.event.slug pk=slot.room.pk %}">{{ slot.room }}</a> + {% else %} + {{ slot.room }} + {% endif %} {% else %} - {{ slot.room }} + - {% endif %} </td> {% endif %}