From 478636bd982f18dc843cc40e52d6f6ef0889aad3 Mon Sep 17 00:00:00 2001 From: moanos Date: Sat, 10 May 2025 13:12:58 +0200 Subject: [PATCH] feat: add bulma about --- .../fellchensammlung/bulma-about.html | 27 +++++++++++++++++++ src/fellchensammlung/tools/i18n.py | 16 +++++++++++ src/fellchensammlung/urls.py | 1 + src/fellchensammlung/views.py | 23 +++++++++------- 4 files changed, 58 insertions(+), 9 deletions(-) create mode 100644 src/fellchensammlung/templates/fellchensammlung/bulma-about.html create mode 100644 src/fellchensammlung/tools/i18n.py diff --git a/src/fellchensammlung/templates/fellchensammlung/bulma-about.html b/src/fellchensammlung/templates/fellchensammlung/bulma-about.html new file mode 100644 index 0000000..f9a6625 --- /dev/null +++ b/src/fellchensammlung/templates/fellchensammlung/bulma-about.html @@ -0,0 +1,27 @@ +{% extends "fellchensammlung/base_bulma.html" %} +{% load i18n %} +{% load custom_tags %} + +{% block title %}{% translate "Über uns" %}{% endblock %} + +{% block content %} + {% if about_us %} +
+
+

{{ about_us.title }}

+
+
+ {{ about_us.content | render_markdown }} +
+
+ {% endif %} + + {% if faq %} +
+

{{ faq.title }}

+

+ {{ faq.content | render_markdown }} +

+
+ {% endif %} +{% endblock %} \ No newline at end of file diff --git a/src/fellchensammlung/tools/i18n.py b/src/fellchensammlung/tools/i18n.py new file mode 100644 index 0000000..b1c21fe --- /dev/null +++ b/src/fellchensammlung/tools/i18n.py @@ -0,0 +1,16 @@ +from django.utils import translation + +from fellchensammlung.models import Language, Text + + +def get_texts_by_language(text_codes): + language_code = translation.get_language() + lang = Language.objects.get(languagecode=language_code) + + texts = {} + for text_code in text_codes: + try: + texts[text_code] = Text.objects.get(text_code=text_code, language=lang, ) + except Text.DoesNotExist: + texts[text_code] = None + return texts diff --git a/src/fellchensammlung/urls.py b/src/fellchensammlung/urls.py index f94ec7d..fa192c8 100644 --- a/src/fellchensammlung/urls.py +++ b/src/fellchensammlung/urls.py @@ -55,6 +55,7 @@ urlpatterns = [ path("vermitteln/", views.add_adoption_notice, name="add-adoption"), path("ueber-uns/", views.about, name="about"), + path("bulma/ueber-uns/", views.about_bulma, name="about-bulma"), ################ ## Moderation ## diff --git a/src/fellchensammlung/views.py b/src/fellchensammlung/views.py index eba7311..5b9bddc 100644 --- a/src/fellchensammlung/views.py +++ b/src/fellchensammlung/views.py @@ -24,6 +24,7 @@ from .forms import AdoptionNoticeForm, AdoptionNoticeFormWithDateWidget, ImageFo CommentForm, ReportCommentForm, AnimalForm, \ AdoptionNoticeSearchForm, AnimalFormWithDateWidget, AdoptionNoticeFormWithDateWidgetAutoAnimal from .models import Language, Announcement +from .tools import i18n from .tools.geo import GeoAPI, zoom_level_for_radius from .tools.metrics import gather_metrics_data from .tools.admin import clean_locations, get_unchecked_adoption_notices, deactivate_unchecked_adoption_notices, \ @@ -97,6 +98,8 @@ def change_language(request): return response else: return render(request, 'fellchensammlung/index.html') + else: + return render(request, 'fellchensammlung/index.html') def adoption_notice_detail(request, adoption_notice_id, template=None): @@ -415,15 +418,7 @@ def animal_edit(request, animal_id): def about(request): rules = Rule.objects.all() - language_code = translation.get_language() - lang = Language.objects.get(languagecode=language_code) - - legal = {} - for text_code in ["terms_of_service", "privacy_statement", "imprint", "about_us", "faq"]: - try: - legal[text_code] = Text.objects.get(text_code=text_code, language=lang, ) - except Text.DoesNotExist: - legal[text_code] = None + legal = i18n.get_texts_by_language(["terms_of_service", "privacy_statement", "imprint", "about_us", "faq"]) context = {"rules": rules, } context.update(legal) @@ -434,6 +429,16 @@ def about(request): ) +def about_bulma(request): + context = i18n.get_texts_by_language(["about_us", "faq"]) + + return render( + request, + "fellchensammlung/bulma-about.html", + context=context + ) + + def report_adoption(request, adoption_notice_id): """ Form to report adoption notices