diff --git a/AKDashboard/locale/de_DE/LC_MESSAGES/django.po b/AKDashboard/locale/de_DE/LC_MESSAGES/django.po index b630ca873d6607cd947ef5ba8ef67cbec7f3844a..feb56e89e977b73e6bc069f546008f063f1fa290 100644 --- a/AKDashboard/locale/de_DE/LC_MESSAGES/django.po +++ b/AKDashboard/locale/de_DE/LC_MESSAGES/django.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2023-08-16 16:30+0200\n" +"POT-Creation-Date: 2025-01-01 17:28+0100\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" @@ -61,17 +61,22 @@ msgstr "Veranstaltung" msgid "Event this button belongs to" msgstr "Veranstaltung, zu der dieser Button gehört" -#: AKDashboard/templates/AKDashboard/dashboard.html:17 +#: AKDashboard/templates/AKDashboard/dashboard.html:18 #: AKDashboard/templates/AKDashboard/dashboard_event.html:29 +#: AKDashboard/templates/AKDashboard/dashboard_row_old_event.html:53 msgid "Write to organizers of this event for questions and comments" msgstr "" "Kontaktiere die Organisator*innen des Events bei Fragen oder Kommentaren" #: AKDashboard/templates/AKDashboard/dashboard.html:24 +msgid "Old events" +msgstr "Frühere Veranstaltungen" + +#: AKDashboard/templates/AKDashboard/dashboard.html:34 msgid "Currently, there are no Events!" msgstr "Aktuell gibt es keine Events!" -#: AKDashboard/templates/AKDashboard/dashboard.html:27 +#: AKDashboard/templates/AKDashboard/dashboard.html:37 msgid "Please contact an administrator if you want to use AKPlanning." msgstr "" "Bitte kontaktiere eine*n Administrator*in, falls du AKPlanning verwenden " @@ -81,46 +86,49 @@ msgstr "" msgid "Recent" msgstr "Kürzlich" -#: AKDashboard/templates/AKDashboard/dashboard_row.html:12 +#: AKDashboard/templates/AKDashboard/dashboard_row.html:18 +#: AKDashboard/templates/AKDashboard/dashboard_row_old_event.html:20 msgid "AK List" msgstr "AK-Liste" -#: AKDashboard/templates/AKDashboard/dashboard_row.html:23 +#: AKDashboard/templates/AKDashboard/dashboard_row.html:29 msgid "Current AKs" msgstr "Aktuelle AKs" -#: AKDashboard/templates/AKDashboard/dashboard_row.html:30 +#: AKDashboard/templates/AKDashboard/dashboard_row.html:36 msgid "AK Wall" msgstr "AK-Wall" -#: AKDashboard/templates/AKDashboard/dashboard_row.html:38 +#: AKDashboard/templates/AKDashboard/dashboard_row.html:44 +#: AKDashboard/templates/AKDashboard/dashboard_row_old_event.html:30 msgid "Schedule" msgstr "AK-Plan" -#: AKDashboard/templates/AKDashboard/dashboard_row.html:49 +#: AKDashboard/templates/AKDashboard/dashboard_row.html:55 msgid "AK Submission" msgstr "AK-Einreichung" -#: AKDashboard/templates/AKDashboard/dashboard_row.html:57 +#: AKDashboard/templates/AKDashboard/dashboard_row.html:63 +#: AKDashboard/templates/AKDashboard/dashboard_row_old_event.html:39 msgid "AK History" msgstr "AK-Verlauf" -#: AKDashboard/views.py:59 +#: AKDashboard/views.py:69 #, python-format msgid "New AK: %(ak)s." msgstr "Neuer AK: %(ak)s." -#: AKDashboard/views.py:62 +#: AKDashboard/views.py:72 #, python-format msgid "AK \"%(ak)s\" edited." msgstr "AK \"%(ak)s\" bearbeitet." -#: AKDashboard/views.py:65 +#: AKDashboard/views.py:75 #, python-format msgid "AK \"%(ak)s\" deleted." msgstr "AK \"%(ak)s\" gelöscht." -#: AKDashboard/views.py:80 +#: AKDashboard/views.py:90 #, python-format msgid "AK \"%(ak)s\" (re-)scheduled." msgstr "AK \"%(ak)s\" (um-)geplant." diff --git a/AKDashboard/static/AKDashboard/style.css b/AKDashboard/static/AKDashboard/style.css index 11027c4a0a17bc56dd4ad5470e50ff736fc6bb1e..c9073ea7521bf96693bead1c315281b4bea3981d 100644 --- a/AKDashboard/static/AKDashboard/style.css +++ b/AKDashboard/static/AKDashboard/style.css @@ -2,6 +2,10 @@ margin-bottom: 5em; } +.dashboard-row-small { + margin-bottom: 3em; +} + .dashboard-row > .row { margin-left: 0; padding-bottom: 1em; diff --git a/AKDashboard/templates/AKDashboard/dashboard.html b/AKDashboard/templates/AKDashboard/dashboard.html index 48925af37dac792918c2952f3f7a22c182563bea..7ce4ef015600a72b63ad1693822e83a99d27fb58 100644 --- a/AKDashboard/templates/AKDashboard/dashboard.html +++ b/AKDashboard/templates/AKDashboard/dashboard.html @@ -9,16 +9,26 @@ {% endblock %} {% block content %} - {% for event in events %} - <div class="dashboard-row"> - {% include "AKDashboard/dashboard_row.html" %} - {% if event.contact_email %} - <p> - <a href="mailto:{{ event.contact_email }}">{% fa6_icon "envelope" "fas" %} {% trans "Write to organizers of this event for questions and comments" %}</a> - </p> - {% endif %} - </div> - {% empty %} + {% if total_event_count > 0 %} + {% for event in active_and_current_events %} + <div class="dashboard-row"> + {% include "AKDashboard/dashboard_row.html" %} + {% if event.contact_email %} + <p> + <a href="mailto:{{ event.contact_email }}">{% fa6_icon "envelope" "fas" %} {% trans "Write to organizers of this event for questions and comments" %}</a> + </p> + {% endif %} + </div> + {% endfor %} + {% if old_event_count > 0 %} + <h2 class="mb-3">{% trans "Old events" %}</h2> + {% for event in old_events %} + <div class="dashboard-row-small"> + {% include "AKDashboard/dashboard_row_old_event.html" %} + </div> + {% endfor %} + {% endif %} + {% else %} <div class="jumbotron"> <h2 class="display-4"> {% trans 'Currently, there are no Events!' %} @@ -27,5 +37,5 @@ {% trans 'Please contact an administrator if you want to use AKPlanning.' %} </p> </div> - {% endfor %} + {% endif %} {% endblock %} diff --git a/AKDashboard/templates/AKDashboard/dashboard_row.html b/AKDashboard/templates/AKDashboard/dashboard_row.html index e06c6af842843e18a09e2cceb681470024c4996e..5492ae77bc9c2bb01f91663ae207a4da5e7c2d58 100644 --- a/AKDashboard/templates/AKDashboard/dashboard_row.html +++ b/AKDashboard/templates/AKDashboard/dashboard_row.html @@ -3,6 +3,12 @@ {% load fontawesome_6 %} <h2><a href="{% url 'dashboard:dashboard_event' slug=event.slug %}">{{ event.name }}</a></h2> +<h4 class="text-muted"> + {% if event.place %} + <b>{{ event.place }} ·</b> + {% endif %} + {{ event | event_month_year }} +</h4> <div class="mt-2"> {% if 'AKSubmission'|check_app_installed %} <a class="dashboard-box btn btn-primary" diff --git a/AKDashboard/templates/AKDashboard/dashboard_row_old_event.html b/AKDashboard/templates/AKDashboard/dashboard_row_old_event.html new file mode 100644 index 0000000000000000000000000000000000000000..2f8f396d40fec63bae78cefc7d49fc41414950ab --- /dev/null +++ b/AKDashboard/templates/AKDashboard/dashboard_row_old_event.html @@ -0,0 +1,56 @@ +{% load i18n %} +{% load tags_AKModel %} +{% load fontawesome_6 %} + +<h3><a href="{% url 'dashboard:dashboard_event' slug=event.slug %}">{{ event.name }}</a> + <span class="text-muted"> + · + {% if event.place %} + {{ event.place }} · + {% endif %} + {{ event | event_month_year }} + </span> +</h3> +<div class="mt-2"> + {% if 'AKSubmission'|check_app_installed %} + <a class="btn btn-primary" + href="{% url 'submit:ak_list' event_slug=event.slug %}"> + <div class="col-sm-12 col-md-3 col-lg-2 dashboard-button"> + <span class="fa fa-list-ul"></span> + <span class='text'>{% trans 'AK List' %}</span> + </div> + </a> + {% endif %} + {% if 'AKPlan'|check_app_installed %} + {% if not event.plan_hidden or user.is_staff %} + <a class="btn btn-primary" + href="{% url 'plan:plan_overview' event_slug=event.slug %}"> + <div class="col-sm-12 col-md-3 col-lg-2 dashboard-button"> + <span class="fa fa-calendar-alt"></span> + <span class='text'>{% trans 'Schedule' %}</span> + </div> + </a> + {% endif %} + {% endif %} + <a class="btn btn-primary" + href="{% url 'dashboard:dashboard_event' slug=event.slug %}#history"> + <div class="col-sm-12 col-md-3 col-lg-2 dashboard-button"> + <span class="fa fa-history"></span> + <span class='text'>{% trans 'AK History' %}</span> + </div> + </a> + {% for button in event.dashboardbutton_set.all %} + <a class="btn btn-{{ button.get_color_display }}" + href="{{ button.url }}"> + <div class="col-sm-12 col-md-3 col-lg-2 dashboard-button"> + {% if button.icon %}<span class="fa">{{ button.icon.as_html }}</span>{% endif %} + <span class='text'>{{ button.text }}</span> + </div> + </a> + {% endfor %} + <a class="btn btn-info" + href=mailto:{{ event.contact_email }}" + title="{% trans 'Write to organizers of this event for questions and comments' %}"> + {% fa6_icon "envelope" "fas" %} + </a> +</div> diff --git a/AKDashboard/tests.py b/AKDashboard/tests.py index f96af9a109cc90df9ebebbb504110e7e7fe6a9fe..6253f8a176171159c5fde612bddbebf1d506d318 100644 --- a/AKDashboard/tests.py +++ b/AKDashboard/tests.py @@ -90,7 +90,8 @@ class DashboardTests(TestCase): self.event.save() response = self.client.get(url_dashboard_index) self.assertEqual(response.status_code, 200) - self.assertFalse(self.event in response.context["events"]) + self.assertFalse(self.event in response.context["active_and_current_events"]) + self.assertFalse(self.event in response.context["old_events"]) response = self.client.get(url_event_dashboard) self.assertEqual(response.status_code, 200) self.assertEqual(response.context["event"], self.event) @@ -100,7 +101,7 @@ class DashboardTests(TestCase): self.event.save() response = self.client.get(url_dashboard_index) self.assertEqual(response.status_code, 200) - self.assertTrue(self.event in response.context["events"]) + self.assertTrue(self.event in response.context["active_and_current_events"]) def test_active(self): """ diff --git a/AKDashboard/views.py b/AKDashboard/views.py index 601edda274cf0a5d893571d6307d001c49affb63..3ba1efeda3a4c7164ba67ab5c4e06ec62acdb2d7 100644 --- a/AKDashboard/views.py +++ b/AKDashboard/views.py @@ -22,7 +22,18 @@ class DashboardView(TemplateView): def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) - context['events'] = Event.objects.filter(public=True).prefetch_related('dashboardbutton_set') + # Load events and split between active and current/featured events and those that should show smaller below + context["active_and_current_events"] = [] + context["old_events"] = [] + events = Event.objects.filter(public=True).order_by("-active", "-pk").prefetch_related('dashboardbutton_set') + for event in events: + if event.active or len(context["active_and_current_events"]) < settings.DASHBOARD_MAX_FEATURED_EVENTS: + context["active_and_current_events"].append(event) + else: + context["old_events"].append(event) + context["active_event_count"] = len(context["active_and_current_events"]) + context["old_event_count"] = len(context["old_events"]) + context["total_event_count"] = context["active_event_count"] + context["old_event_count"] return context diff --git a/AKModel/templatetags/tags_AKModel.py b/AKModel/templatetags/tags_AKModel.py index 5208739cc306d4f8e25a41e2b81efeebb72b155f..9f62dfb471a02b31735ac8722ba59406530c50c1 100644 --- a/AKModel/templatetags/tags_AKModel.py +++ b/AKModel/templatetags/tags_AKModel.py @@ -3,8 +3,11 @@ from django.apps import apps from django.conf import settings from django.utils.html import format_html, mark_safe, conditional_escape from django.templatetags.static import static +from django.template.defaultfilters import date from fontawesome_6.app_settings import get_css +from AKModel.models import Event + register = template.Library() @@ -71,6 +74,21 @@ def wiki_owners_export(owners, event): return ", ".join(to_link(owner) for owner in owners.all()) +@register.filter +def event_month_year(event:Event): + """ + Print rough event date (month and year) + :param event: event to print the date for + :return: string containing rough date information for event + """ + if event.start.month == event.end.month: + return f"{date(event.start, 'F')} {event.start.year}" + event_start_string = date(event.start, 'F') + if event.start.year != event.end.year: + event_start_string = f"{event_start_string} {event.start.year}" + return f"{event_start_string} - {date(event.end, 'F')} {event.end.year}" + + # get list of relevant css fontawesome css files for this instance css = get_css() diff --git a/AKPlanning/settings.py b/AKPlanning/settings.py index 4cb4bb301adca7fd146f681b3c1727e4b8c7676a..7344ae1898243dd2eb1da8ebf1026ac2088958a8 100644 --- a/AKPlanning/settings.py +++ b/AKPlanning/settings.py @@ -217,6 +217,9 @@ PLAN_MAX_HIGHLIGHT_UPDATE_SECONDS = 2 * 60 * 60 DASHBOARD_SHOW_RECENT = True # How many entries max? DASHBOARD_RECENT_MAX = 25 +# How many events should be featured in the dashboard +# (active events will always be featured, even if their number is higher than this threshold) +DASHBOARD_MAX_FEATURED_EVENTS = 3 # Registration/login behavior SIMPLE_BACKEND_REDIRECT_URL = "/user/"