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

Display current/upcoming AK slots on top of detail page

Implements #89
This will show a box with information (room and remaining time) about AKs currently going on or starting in less than 2 hours.
parent 13ee619b
No related branches found
No related tags found
No related merge requests found
...@@ -8,7 +8,7 @@ msgid "" ...@@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-07-12 16:17+0000\n" "POT-Creation-Date: 2020-10-05 22:32+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
...@@ -102,7 +102,7 @@ msgid "History" ...@@ -102,7 +102,7 @@ msgid "History"
msgstr "Versionsgeschichte" msgstr "Versionsgeschichte"
#: AKSubmission/templates/AKSubmission/ak_detail.html:59 #: AKSubmission/templates/AKSubmission/ak_detail.html:59
#: AKSubmission/templates/AKSubmission/ak_detail.html:174 #: AKSubmission/templates/AKSubmission/ak_detail.html:198
#: AKSubmission/templates/AKSubmission/ak_edit.html:16 #: AKSubmission/templates/AKSubmission/ak_edit.html:16
#: AKSubmission/templates/AKSubmission/ak_table.html:53 #: AKSubmission/templates/AKSubmission/ak_table.html:53
msgid "Edit" msgid "Edit"
...@@ -114,89 +114,112 @@ msgstr "Bearbeiten" ...@@ -114,89 +114,112 @@ msgstr "Bearbeiten"
msgid "AK Wish" msgid "AK Wish"
msgstr "AK-Wunsch" msgstr "AK-Wunsch"
#: AKSubmission/templates/AKSubmission/ak_detail.html:68 #: AKSubmission/templates/AKSubmission/ak_detail.html:71
#, python-format
msgid ""
"\n"
" This AK currently takes place for another "
"%(featured_slot_remaining)s minute(s) in %(room)s.&nbsp;\n"
" "
msgstr ""
"Dieser AK findet noch %(featured_slot_remaining)s Minute(n) in %(room)s "
"statt.&nbsp;\n"
#: AKSubmission/templates/AKSubmission/ak_detail.html:76
#, python-format
msgid ""
"\n"
" This AK starts in %(featured_slot_remaining)s "
"minute(s) in %(room)s.&nbsp;\n"
" "
msgstr ""
" This AK beginnt in %(featured_slot_remaining)s Minute(n) in %(room)s."
"&nbsp;\n"
#: AKSubmission/templates/AKSubmission/ak_detail.html:83
#: AKSubmission/templates/AKSubmission/ak_detail.html:206
msgid "Go to virtual room"
msgstr "Zum virtuellen Raum"
#: AKSubmission/templates/AKSubmission/ak_detail.html:92
#: AKSubmission/templates/AKSubmission/ak_table.html:10 #: AKSubmission/templates/AKSubmission/ak_table.html:10
msgid "Who?" msgid "Who?"
msgstr "Wer?" msgstr "Wer?"
#: AKSubmission/templates/AKSubmission/ak_detail.html:74 #: AKSubmission/templates/AKSubmission/ak_detail.html:98
#: AKSubmission/templates/AKSubmission/ak_history.html:36 #: AKSubmission/templates/AKSubmission/ak_history.html:36
#: AKSubmission/templates/AKSubmission/ak_table.html:11 #: AKSubmission/templates/AKSubmission/ak_table.html:11
msgid "Category" msgid "Category"
msgstr "Kategorie" msgstr "Kategorie"
#: AKSubmission/templates/AKSubmission/ak_detail.html:81 #: AKSubmission/templates/AKSubmission/ak_detail.html:105
#: AKSubmission/templates/AKSubmission/ak_history.html:37 #: AKSubmission/templates/AKSubmission/ak_history.html:37
msgid "Track" msgid "Track"
msgstr "Track" msgstr "Track"
#: AKSubmission/templates/AKSubmission/ak_detail.html:86 #: AKSubmission/templates/AKSubmission/ak_detail.html:110
msgid "Present this AK" msgid "Present this AK"
msgstr "Diesen AK vorstellen" msgstr "Diesen AK vorstellen"
#: AKSubmission/templates/AKSubmission/ak_detail.html:90 #: AKSubmission/templates/AKSubmission/ak_detail.html:114
#: AKSubmission/templates/AKSubmission/ak_table.html:12 #: AKSubmission/templates/AKSubmission/ak_table.html:12
msgid "Tags" msgid "Tags"
msgstr "Tags" msgstr "Tags"
#: AKSubmission/templates/AKSubmission/ak_detail.html:96 #: AKSubmission/templates/AKSubmission/ak_detail.html:120
msgid "Reso?" msgid "Reso?"
msgstr "Reso?" msgstr "Reso?"
#: AKSubmission/templates/AKSubmission/ak_detail.html:103 #: AKSubmission/templates/AKSubmission/ak_detail.html:127
msgid "Requirements" msgid "Requirements"
msgstr "Anforderungen" msgstr "Anforderungen"
#: AKSubmission/templates/AKSubmission/ak_detail.html:116 #: AKSubmission/templates/AKSubmission/ak_detail.html:140
msgid "Conflicting AKs" msgid "Conflicting AKs"
msgstr "AK Konflikte" msgstr "AK Konflikte"
#: AKSubmission/templates/AKSubmission/ak_detail.html:124 #: AKSubmission/templates/AKSubmission/ak_detail.html:148
msgid "Prerequisite AKs" msgid "Prerequisite AKs"
msgstr "AK Voraussetzungen" msgstr "AK Voraussetzungen"
#: AKSubmission/templates/AKSubmission/ak_detail.html:132 #: AKSubmission/templates/AKSubmission/ak_detail.html:156
msgid "Notes" msgid "Notes"
msgstr "Notizen" msgstr "Notizen"
#: AKSubmission/templates/AKSubmission/ak_detail.html:149 #: AKSubmission/templates/AKSubmission/ak_detail.html:173
#: AKSubmission/templates/AKSubmission/akslot_delete.html:35 #: AKSubmission/templates/AKSubmission/akslot_delete.html:35
msgid "Duration" msgid "Duration"
msgstr "Dauer" msgstr "Dauer"
#: AKSubmission/templates/AKSubmission/ak_detail.html:151 #: AKSubmission/templates/AKSubmission/ak_detail.html:175
msgid "When?" msgid "When?"
msgstr "Wann?" msgstr "Wann?"
#: AKSubmission/templates/AKSubmission/ak_detail.html:152 #: AKSubmission/templates/AKSubmission/ak_detail.html:176
msgid "Room" msgid "Room"
msgstr "Raum" msgstr "Raum"
#: AKSubmission/templates/AKSubmission/ak_detail.html:177 #: AKSubmission/templates/AKSubmission/ak_detail.html:201
msgid "Delete" msgid "Delete"
msgstr "Löschen" msgstr "Löschen"
#: AKSubmission/templates/AKSubmission/ak_detail.html:182 #: AKSubmission/templates/AKSubmission/ak_detail.html:212
msgid "Go to virtual room"
msgstr "Zum virtuellen Raum"
#: AKSubmission/templates/AKSubmission/ak_detail.html:188
msgid "Schedule" msgid "Schedule"
msgstr "Schedule" msgstr "Schedule"
#: AKSubmission/templates/AKSubmission/ak_detail.html:200 #: AKSubmission/templates/AKSubmission/ak_detail.html:224
msgid "Add another slot" msgid "Add another slot"
msgstr "Einen neuen AK-Slot hinzufügen" msgstr "Einen neuen AK-Slot hinzufügen"
#: AKSubmission/templates/AKSubmission/ak_detail.html:204 #: AKSubmission/templates/AKSubmission/ak_detail.html:228
msgid "Possible Times" msgid "Possible Times"
msgstr "Mögliche Zeiten" msgstr "Mögliche Zeiten"
#: AKSubmission/templates/AKSubmission/ak_detail.html:208 #: AKSubmission/templates/AKSubmission/ak_detail.html:232
msgid "Start" msgid "Start"
msgstr "Start" msgstr "Start"
#: AKSubmission/templates/AKSubmission/ak_detail.html:209 #: AKSubmission/templates/AKSubmission/ak_detail.html:233
msgid "End" msgid "End"
msgstr "Ende" msgstr "Ende"
...@@ -228,7 +251,7 @@ msgstr "Diesen AK vorstellen" ...@@ -228,7 +251,7 @@ msgstr "Diesen AK vorstellen"
msgid "Reso" msgid "Reso"
msgstr "Reso" msgstr "Reso"
#: AKSubmission/templates/AKSubmission/ak_list.html:6 AKSubmission/views.py:34 #: AKSubmission/templates/AKSubmission/ak_list.html:6 AKSubmission/views.py:39
msgid "All AKs" msgid "All AKs"
msgstr "Alle AKs" msgstr "Alle AKs"
...@@ -348,60 +371,60 @@ msgstr "" ...@@ -348,60 +371,60 @@ msgstr ""
msgid "Submit" msgid "Submit"
msgstr "Eintragen" msgstr "Eintragen"
#: AKSubmission/views.py:65 #: AKSubmission/views.py:70
msgid "Wishes" msgid "Wishes"
msgstr "Wünsche" msgstr "Wünsche"
#: AKSubmission/views.py:65 #: AKSubmission/views.py:70
msgid "AKs one would like to have" msgid "AKs one would like to have"
msgstr "" msgstr ""
"AKs die sich gewünscht wurden, aber bei denen noch nicht klar ist, wer sie " "AKs die sich gewünscht wurden, aber bei denen noch nicht klar ist, wer sie "
"macht. Falls du dir das vorstellen kannst, trag dich einfach ein" "macht. Falls du dir das vorstellen kannst, trag dich einfach ein"
#: AKSubmission/views.py:81 #: AKSubmission/views.py:86
msgid "Currently planned AKs" msgid "Currently planned AKs"
msgstr "Aktuell geplante AKs" msgstr "Aktuell geplante AKs"
#: AKSubmission/views.py:157 #: AKSubmission/views.py:184
msgid "Event inactive. Cannot create or update." msgid "Event inactive. Cannot create or update."
msgstr "Event inaktiv. Hinzufügen/Bearbeiten nicht möglich." msgstr "Event inaktiv. Hinzufügen/Bearbeiten nicht möglich."
#: AKSubmission/views.py:173 #: AKSubmission/views.py:200
msgid "AK successfully created" msgid "AK successfully created"
msgstr "AK erfolgreich angelegt" msgstr "AK erfolgreich angelegt"
#: AKSubmission/views.py:231 #: AKSubmission/views.py:258
msgid "AK successfully updated" msgid "AK successfully updated"
msgstr "AK erfolgreich aktualisiert" msgstr "AK erfolgreich aktualisiert"
#: AKSubmission/views.py:261 #: AKSubmission/views.py:288
msgid "Interest saved" msgid "Interest saved"
msgstr "Interesse gespeichert" msgstr "Interesse gespeichert"
#: AKSubmission/views.py:310 #: AKSubmission/views.py:337
msgid "Person Info successfully updated" msgid "Person Info successfully updated"
msgstr "Personen-Info erfolgreich aktualisiert" msgstr "Personen-Info erfolgreich aktualisiert"
#: AKSubmission/views.py:330 #: AKSubmission/views.py:357
msgid "No user selected" msgid "No user selected"
msgstr "Keine Person ausgewählt" msgstr "Keine Person ausgewählt"
#: AKSubmission/views.py:356 #: AKSubmission/views.py:383
msgid "AK Slot successfully added" msgid "AK Slot successfully added"
msgstr "AK-Slot erfolgreich angelegt" msgstr "AK-Slot erfolgreich angelegt"
#: AKSubmission/views.py:370 #: AKSubmission/views.py:397
msgid "You cannot edit a slot that has already been scheduled" msgid "You cannot edit a slot that has already been scheduled"
msgstr "Bereits geplante AK-Slots können nicht mehr bearbeitet werden" msgstr "Bereits geplante AK-Slots können nicht mehr bearbeitet werden"
#: AKSubmission/views.py:380 #: AKSubmission/views.py:407
msgid "AK Slot successfully updated" msgid "AK Slot successfully updated"
msgstr "AK-Slot erfolgreich aktualisiert" msgstr "AK-Slot erfolgreich aktualisiert"
#: AKSubmission/views.py:393 #: AKSubmission/views.py:420
msgid "You cannot delete a slot that has already been scheduled" msgid "You cannot delete a slot that has already been scheduled"
msgstr "Bereits geplante AK-Slots können nicht mehr gelöscht werden" msgstr "Bereits geplante AK-Slots können nicht mehr gelöscht werden"
#: AKSubmission/views.py:403 #: AKSubmission/views.py:430
msgid "AK Slot successfully deleted" msgid "AK Slot successfully deleted"
msgstr "AK-Slot erfolgreich angelegt" msgstr "AK-Slot erfolgreich angelegt"
...@@ -63,6 +63,30 @@ ...@@ -63,6 +63,30 @@
<h2>{% if ak.wish %}{% trans "AK Wish" %}: {% endif %}{{ ak.name }}</h2> <h2>{% if ak.wish %}{% trans "AK Wish" %}: {% endif %}{{ ak.name }}</h2>
{# Show current or upcoming slot featured in a box on top of the plage #}
{% if featured_slot_type != "NONE" %}
<div class="card border-success mt-3 mb-3">
<div class="card-body font-weight-bold">
{% if featured_slot_type == "CURRENT" %}
{% blocktrans with room=featured_slot.room %}
This AK currently takes place for another {{ featured_slot_remaining }} minute(s) in {{ room }}.&nbsp;
{% endblocktrans %}
{% elif featured_slot_type == "UPCOMING" %}
{% blocktrans with room=featured_slot.room %}
This AK starts in {{ featured_slot_remaining }} minute(s) in {{ room }}.&nbsp;
{% endblocktrans %}
{% endif %}
{% if "AKOnline"|check_app_installed and featured_slot.room.virtualroom and featured_slot.room.virtualroom.url != '' %}
<a class="btn btn-success" href="{{ featured_slot.room.virtualroom.url }}">
{% fa5_icon 'external-link-alt' 'fas' %} {% trans "Go to virtual room" %}
</a>
{% endif %}
</div>
</div>
{% endif %}
<table class="table table-borderless"> <table class="table table-borderless">
<tr> <tr>
<td>{% trans "Who?" %}</td> <td>{% trans "Who?" %}</td>
......
from datetime import timedelta
from math import floor
from django.apps import apps
from django.conf import settings from django.conf import settings
from django.contrib import messages from django.contrib import messages
from django.http import HttpResponseRedirect from django.http import HttpResponseRedirect
from django.shortcuts import get_object_or_404, redirect from django.shortcuts import get_object_or_404, redirect
from django.urls import reverse_lazy from django.urls import reverse_lazy
from django.utils.translation import gettext_lazy as _ from django.utils.translation import gettext_lazy as _
from django.utils.datetime_safe import datetime
from django.views import View from django.views import View
from django.views.generic import ListView, DetailView, CreateView, UpdateView, DeleteView, RedirectView, TemplateView from django.views.generic import ListView, DetailView, CreateView, UpdateView, DeleteView, RedirectView, TemplateView
...@@ -130,6 +135,28 @@ class AKDetailView(EventSlugMixin, DetailView): ...@@ -130,6 +135,28 @@ class AKDetailView(EventSlugMixin, DetailView):
def get_context_data(self, *, object_list=None, **kwargs): def get_context_data(self, *, object_list=None, **kwargs):
context = super().get_context_data(object_list=object_list, **kwargs) context = super().get_context_data(object_list=object_list, **kwargs)
context["availabilities"] = Availability.objects.filter(ak=context["ak"]) context["availabilities"] = Availability.objects.filter(ak=context["ak"])
# Is this AK taking place now or soon (used for top page visualization)
context["featured_slot_type"] = "NONE"
if apps.is_installed("AKPlan"):
current_timestamp = datetime.now().astimezone(self.event.timezone)
in_two_hours = current_timestamp + timedelta(hours=2)
slots = context["ak"].akslot_set.filter(start__isnull=False, room__isnull=False)
for slot in slots:
if slot.end > current_timestamp:
if slot.start <= current_timestamp:
context["featured_slot_type"] = "CURRENT"
remaining = slot.end - current_timestamp
elif slot.start <= in_two_hours:
context["featured_slot_type"] = "UPCOMING"
remaining = slot.start - current_timestamp
else:
continue
context["featured_slot"] = slot
context["featured_slot_remaining"] = floor(remaining.days * 24 * 60 + remaining.seconds / 60)
break
return context return context
......
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