Skip to content
Snippets Groups Projects
Commit 25aee6f6 authored by Benjamin Hättasch's avatar Benjamin Hättasch
Browse files

Merge branch 'voidptr/akplanning-readable-ak-times'

parents e9a72c21 23d81356
No related branches found
No related tags found
1 merge request!76Readable AK times on details page
Pipeline #13140 passed
...@@ -336,6 +336,14 @@ class AKSlot(models.Model): ...@@ -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} in {self.room}"
return f"{self.ak} @ {self.start_simplified}" 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 @property
def start_simplified(self): def start_simplified(self):
""" """
...@@ -345,6 +353,19 @@ class AKSlot(models.Model): ...@@ -345,6 +353,19 @@ class AKSlot(models.Model):
return _("Not scheduled yet") return _("Not scheduled yet")
return self.start.astimezone(self.event.timezone).strftime('%a %H:%M') 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 @property
def end(self): def end(self):
""" """
......
...@@ -174,9 +174,11 @@ ...@@ -174,9 +174,11 @@
<table class="table"> <table class="table">
<thead> <thead>
<tr> <tr>
<th>{% trans "Duration" %}</th>
{% if not ak.event.plan_hidden or user.is_staff %} {% if not ak.event.plan_hidden or user.is_staff %}
<th>{% trans "When?" %}</th> <th>{% trans "When?" %}</th>
{% endif %}
<th>{% trans "Duration" %}</th>
{% if not ak.event.plan_hidden or user.is_staff %}
<th>{% trans "Room" %}</th> <th>{% trans "Room" %}</th>
{% endif %} {% endif %}
<th></th> <th></th>
...@@ -185,14 +187,20 @@ ...@@ -185,14 +187,20 @@
<tbody> <tbody>
{% for slot in ak.akslot_set.all %} {% for slot in ak.akslot_set.all %}
<tr> <tr>
<td>{{ slot.duration }}</td>
{% if not ak.event.plan_hidden or user.is_staff %} {% 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> <td>
{% if "AKPlan"|check_app_installed and slot.room %} {% if slot.room %}
<a href="{% url 'plan:plan_room' event_slug=ak.event.slug pk=slot.room.pk %}">{{ slot.room }}</a> {% 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 %} {% else %}
{{ slot.room }} -
{% endif %} {% endif %}
</td> </td>
{% endif %} {% endif %}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment