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 ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\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"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
......@@ -102,7 +102,7 @@ msgid "History"
msgstr "Versionsgeschichte"
#: 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_table.html:53
msgid "Edit"
......@@ -114,89 +114,112 @@ msgstr "Bearbeiten"
msgid "AK Wish"
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
msgid "Who?"
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_table.html:11
msgid "Category"
msgstr "Kategorie"
#: AKSubmission/templates/AKSubmission/ak_detail.html:81
#: AKSubmission/templates/AKSubmission/ak_detail.html:105
#: AKSubmission/templates/AKSubmission/ak_history.html:37
msgid "Track"
msgstr "Track"
#: AKSubmission/templates/AKSubmission/ak_detail.html:86
#: AKSubmission/templates/AKSubmission/ak_detail.html:110
msgid "Present this AK"
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
msgid "Tags"
msgstr "Tags"
#: AKSubmission/templates/AKSubmission/ak_detail.html:96
#: AKSubmission/templates/AKSubmission/ak_detail.html:120
msgid "Reso?"
msgstr "Reso?"
#: AKSubmission/templates/AKSubmission/ak_detail.html:103
#: AKSubmission/templates/AKSubmission/ak_detail.html:127
msgid "Requirements"
msgstr "Anforderungen"
#: AKSubmission/templates/AKSubmission/ak_detail.html:116
#: AKSubmission/templates/AKSubmission/ak_detail.html:140
msgid "Conflicting AKs"
msgstr "AK Konflikte"
#: AKSubmission/templates/AKSubmission/ak_detail.html:124
#: AKSubmission/templates/AKSubmission/ak_detail.html:148
msgid "Prerequisite AKs"
msgstr "AK Voraussetzungen"
#: AKSubmission/templates/AKSubmission/ak_detail.html:132
#: AKSubmission/templates/AKSubmission/ak_detail.html:156
msgid "Notes"
msgstr "Notizen"
#: AKSubmission/templates/AKSubmission/ak_detail.html:149
#: AKSubmission/templates/AKSubmission/ak_detail.html:173
#: AKSubmission/templates/AKSubmission/akslot_delete.html:35
msgid "Duration"
msgstr "Dauer"
#: AKSubmission/templates/AKSubmission/ak_detail.html:151
#: AKSubmission/templates/AKSubmission/ak_detail.html:175
msgid "When?"
msgstr "Wann?"
#: AKSubmission/templates/AKSubmission/ak_detail.html:152
#: AKSubmission/templates/AKSubmission/ak_detail.html:176
msgid "Room"
msgstr "Raum"
#: AKSubmission/templates/AKSubmission/ak_detail.html:177
#: AKSubmission/templates/AKSubmission/ak_detail.html:201
msgid "Delete"
msgstr "Löschen"
#: AKSubmission/templates/AKSubmission/ak_detail.html:182
msgid "Go to virtual room"
msgstr "Zum virtuellen Raum"
#: AKSubmission/templates/AKSubmission/ak_detail.html:188
#: AKSubmission/templates/AKSubmission/ak_detail.html:212
msgid "Schedule"
msgstr "Schedule"
#: AKSubmission/templates/AKSubmission/ak_detail.html:200
#: AKSubmission/templates/AKSubmission/ak_detail.html:224
msgid "Add another slot"
msgstr "Einen neuen AK-Slot hinzufügen"
#: AKSubmission/templates/AKSubmission/ak_detail.html:204
#: AKSubmission/templates/AKSubmission/ak_detail.html:228
msgid "Possible Times"
msgstr "Mögliche Zeiten"
#: AKSubmission/templates/AKSubmission/ak_detail.html:208
#: AKSubmission/templates/AKSubmission/ak_detail.html:232
msgid "Start"
msgstr "Start"
#: AKSubmission/templates/AKSubmission/ak_detail.html:209
#: AKSubmission/templates/AKSubmission/ak_detail.html:233
msgid "End"
msgstr "Ende"
......@@ -228,7 +251,7 @@ msgstr "Diesen AK vorstellen"
msgid "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"
msgstr "Alle AKs"
......@@ -348,60 +371,60 @@ msgstr ""
msgid "Submit"
msgstr "Eintragen"
#: AKSubmission/views.py:65
#: AKSubmission/views.py:70
msgid "Wishes"
msgstr "Wünsche"
#: AKSubmission/views.py:65
#: AKSubmission/views.py:70
msgid "AKs one would like to have"
msgstr ""
"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"
#: AKSubmission/views.py:81
#: AKSubmission/views.py:86
msgid "Currently planned AKs"
msgstr "Aktuell geplante AKs"
#: AKSubmission/views.py:157
#: AKSubmission/views.py:184
msgid "Event inactive. Cannot create or update."
msgstr "Event inaktiv. Hinzufügen/Bearbeiten nicht möglich."
#: AKSubmission/views.py:173
#: AKSubmission/views.py:200
msgid "AK successfully created"
msgstr "AK erfolgreich angelegt"
#: AKSubmission/views.py:231
#: AKSubmission/views.py:258
msgid "AK successfully updated"
msgstr "AK erfolgreich aktualisiert"
#: AKSubmission/views.py:261
#: AKSubmission/views.py:288
msgid "Interest saved"
msgstr "Interesse gespeichert"
#: AKSubmission/views.py:310
#: AKSubmission/views.py:337
msgid "Person Info successfully updated"
msgstr "Personen-Info erfolgreich aktualisiert"
#: AKSubmission/views.py:330
#: AKSubmission/views.py:357
msgid "No user selected"
msgstr "Keine Person ausgewählt"
#: AKSubmission/views.py:356
#: AKSubmission/views.py:383
msgid "AK Slot successfully added"
msgstr "AK-Slot erfolgreich angelegt"
#: AKSubmission/views.py:370
#: AKSubmission/views.py:397
msgid "You cannot edit a slot that has already been scheduled"
msgstr "Bereits geplante AK-Slots können nicht mehr bearbeitet werden"
#: AKSubmission/views.py:380
#: AKSubmission/views.py:407
msgid "AK Slot successfully updated"
msgstr "AK-Slot erfolgreich aktualisiert"
#: AKSubmission/views.py:393
#: AKSubmission/views.py:420
msgid "You cannot delete a slot that has already been scheduled"
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"
msgstr "AK-Slot erfolgreich angelegt"
......@@ -63,6 +63,30 @@
<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">
<tr>
<td>{% trans "Who?" %}</td>
......
from datetime import timedelta
from math import floor
from django.apps import apps
from django.conf import settings
from django.contrib import messages
from django.http import HttpResponseRedirect
from django.shortcuts import get_object_or_404, redirect
from django.urls import reverse_lazy
from django.utils.translation import gettext_lazy as _
from django.utils.datetime_safe import datetime
from django.views import View
from django.views.generic import ListView, DetailView, CreateView, UpdateView, DeleteView, RedirectView, TemplateView
......@@ -130,6 +135,28 @@ class AKDetailView(EventSlugMixin, DetailView):
def get_context_data(self, *, object_list=None, **kwargs):
context = super().get_context_data(object_list=object_list, **kwargs)
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
......
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