From d478325ae365efda49671aa98334581852c3832f Mon Sep 17 00:00:00 2001 From: frcroth Date: Thu, 9 Nov 2023 17:31:41 +0100 Subject: [PATCH] Add minutes shortcut (#420) --- myhpi/core/context.py | 17 +++++++++- myhpi/core/templatetags/core_extras.py | 5 +++ myhpi/locale/de/LC_MESSAGES/django.po | 46 +++++++++++++++++--------- myhpi/static/scss/myHPI.scss | 6 ++++ myhpi/templates/base.html | 13 +++++++- 5 files changed, 70 insertions(+), 17 deletions(-) diff --git a/myhpi/core/context.py b/myhpi/core/context.py index 891e8016..1ad28c74 100644 --- a/myhpi/core/context.py +++ b/myhpi/core/context.py @@ -1,7 +1,7 @@ from django.db.models import Q from wagtail.core.models import Site -from .models import BasePage +from .models import BasePage, MinutesList from .utils import get_user_groups @@ -31,7 +31,22 @@ def base_context(request): for page in pages_visible_for_user: page_lookup[page.path] = pages_visible_for_user.child_of(page) + minutes_creation_links = {} + for group in request.user.groups.all(): + minutes_creation_links[group.id] = create_minutes_for_group_link(request.user, group) + return { "root_page": root_page, "pages_by_parent": page_lookup, + "minutes_creation_links": minutes_creation_links, } + + +def create_minutes_for_group_link(user, group): + minutes_list = MinutesList.objects.filter(group=group).first() + if not minutes_list: + return None + if minutes_list.permissions_for_user(user).can_add_subpage(): + from django.urls import reverse + + return reverse("wagtailadmin_pages:add_subpage", kwargs={"parent_page_id": minutes_list.id}) diff --git a/myhpi/core/templatetags/core_extras.py b/myhpi/core/templatetags/core_extras.py index e03f497c..4b1724cc 100644 --- a/myhpi/core/templatetags/core_extras.py +++ b/myhpi/core/templatetags/core_extras.py @@ -52,3 +52,8 @@ def tag_external_links(content): @register.filter(name="markdown") def markdown(value): return render_markdown(value) + + +@register.filter(name="get_link_for_group") +def get_link_for_group(minutes_creation_links, group): + return minutes_creation_links[group.id] diff --git a/myhpi/locale/de/LC_MESSAGES/django.po b/myhpi/locale/de/LC_MESSAGES/django.po index d9900fea..c5a95a00 100644 --- a/myhpi/locale/de/LC_MESSAGES/django.po +++ b/myhpi/locale/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-09 16:50+0200\n" +"POT-Creation-Date: 2023-11-09 16:35+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -18,54 +18,60 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" -#: core/markdown/extensions.py:54 +#: core/markdown/extensions.py:55 msgid "Begin of meeting" msgstr "Beginn des Meetings" -#: core/markdown/extensions.py:57 +#: core/markdown/extensions.py:58 msgid "End of meeting" msgstr "Ende des Meetings" -#: core/markdown/extensions.py:71 +#: core/markdown/extensions.py:72 #, python-brace-format msgid "*Meeting break: {time_start_break} – {time_end_break}*" msgstr "*Sitzungspause: {time_start_break} – {time_end_break}*" -#: core/markdown/extensions.py:88 +#: core/markdown/extensions.py:89 msgid "quorate" msgstr "beschlussfähig" -#: core/markdown/extensions.py:88 +#: core/markdown/extensions.py:89 msgid "not quorate" msgstr "nicht beschlussfähig" -#: core/markdown/extensions.py:91 +#: core/markdown/extensions.py:92 #, python-brace-format msgid "*{num_participants}/{max_num_participants} present → {quorate}* " msgstr "*{num_participants}/{max_num_participants} anwesend → {quorate}* " -#: core/markdown/extensions.py:115 +#: core/markdown/extensions.py:116 #, python-brace-format msgid "*{time}: {name} {event} the meeting* " msgstr "*{time}: {name} {event} das Meeting* " -#: core/markdown/extensions.py:120 +#: core/markdown/extensions.py:121 #, python-brace-format msgid "*{time}: {name} {event} the meeting via {mean_of_participation}* " msgstr "*{time}: {name} {event} das Meeting via {mean_of_participation}* " -#: core/markdown/extensions.py:130 +#: core/markdown/extensions.py:131 msgid "enters" msgstr "betritt" -#: core/markdown/extensions.py:133 +#: core/markdown/extensions.py:134 msgid "leaves" msgstr "verlässt" -#: core/markdown/extensions.py:154 +#: core/markdown/extensions.py:155 msgid "[missing link]" msgstr "[link fehlt]" +#: core/markdown/extensions.py:174 +#, fuzzy +#| msgid "[missing link]" +msgid "[missing image]" +msgstr "[link fehlt]" + #: core/templates/core/information_page.html:19 msgid "Last edited" msgstr "Zuletzt bearbeitet" @@ -182,7 +188,7 @@ msgstr " Ergebnisse gefunden." msgid "No results found." msgstr "Keine Ergebnisse gefunden." -#: search/templates/search/search_field.html:6 templates/base.html:157 +#: search/templates/search/search_field.html:6 templates/base.html:168 msgid "Search..." msgstr "Suchen..." @@ -249,14 +255,24 @@ msgstr "Anmelden" msgid "Your groups:" msgstr "Deine Gruppen" -#: templates/base.html:106 +#: templates/base.html:108 +#, fuzzy +#| msgid "Next minutes" +msgid "Create minutes" +msgstr "Protokoll erstellen" + +#: templates/base.html:117 msgid "Sign out" msgstr "Abmelden" -#: templates/base.html:159 +#: templates/base.html:170 msgid "Start search" msgstr "Suche starten" +#: templates/footer.html:14 +msgid "Language" +msgstr "Sprache" + #: templates/login.html:11 msgid "Current user:" msgstr "Aktueller User:" diff --git a/myhpi/static/scss/myHPI.scss b/myhpi/static/scss/myHPI.scss index be70d3d7..29a64017 100644 --- a/myhpi/static/scss/myHPI.scss +++ b/myhpi/static/scss/myHPI.scss @@ -211,6 +211,12 @@ h1.toc-title::after { max-width: 100%; } +.add-minutes { + display: flex; + align-items: flex-end; + flex-direction: column-reverse; +} + @import "./navbar.scss"; @import "./footer.scss"; diff --git a/myhpi/templates/base.html b/myhpi/templates/base.html index a150d676..4901c81f 100644 --- a/myhpi/templates/base.html +++ b/myhpi/templates/base.html @@ -98,7 +98,18 @@ {% translate "Your groups:" %} {% for group in user.groups.all %} - + {% endfor %} {% endif %}