diff --git a/README.md b/README.md index c792624..56b3e15 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,19 @@ Query location data to debug nf query_location ``` +# Texts + +There is a system for customizing texts in Notfellchen. Not every change of a tet should mean an update of the software. But this should also not become a CMS. +Therefore, a solution is used where a number of predefined texts per site are supported. These markdown texts will then be included in the site, if defined. + +| Textcode | Location | +|---------------------|----------| +| `how_to` | Index | +| `introduction` | Index | +| `privacy_statement` | About | +| `terms_of_service` | About | +| `imprint` | About | +| Any rule | About | # Developer Notes diff --git a/src/fellchensammlung/templates/fellchensammlung/index.html b/src/fellchensammlung/templates/fellchensammlung/index.html index 4ee1ac0..5320e3d 100644 --- a/src/fellchensammlung/templates/fellchensammlung/index.html +++ b/src/fellchensammlung/templates/fellchensammlung/index.html @@ -1,15 +1,23 @@ {% extends "fellchensammlung/base_generic.html" %} {% load i18n %} +{% load custom_tags %} {% block content %} {% for announcement in announcements %} {% include "fellchensammlung/partials/partial-announcement.html" %} {% endfor %} -

{% translate "Notfellchen - Vermittlungen finden" %}

-

{% translate "Alle Tiere brauchen ein liebendes Zuhause. Damit keins vergessen wird gibt es diese Seite. Entwickelt und betreut von " %}moanos!

+ {% if introduction %} +

{{ introduction.title }}

+ {{ introduction.content | render_markdown }} + {% endif %} +

{% translate "Aktuelle Vermittlungen" %}

{% include "fellchensammlung/lists/list-adoption-notices.html" %} + {% if how_to %} +

{{ how_to.title }}

+ {{ how_to.content | render_markdown }} + {% endif %} + {% endblock %} \ No newline at end of file diff --git a/src/fellchensammlung/views.py b/src/fellchensammlung/views.py index f59a20e..fe8c00f 100644 --- a/src/fellchensammlung/views.py +++ b/src/fellchensammlung/views.py @@ -28,7 +28,7 @@ def user_is_trust_level_or_above(user, trust_level=User.MODERATOR): def user_is_owner_or_trust_level(user, django_object, trust_level=User.MODERATOR): return user.is_authenticated and ( - user.trust_level == User.TRUST_LEVEL[trust_level] or django_object.owner == user) + user.trust_level == User.TRUST_LEVEL[trust_level] or django_object.owner == user) def fail_if_user_not_owner_or_trust_level(user, django_object, trust_level=User.MODERATOR): @@ -43,7 +43,13 @@ def index(request): language_code = translation.get_language() lang = Language.objects.get(languagecode=language_code) active_announcements = Announcement.get_active_announcements(lang) + context = {"adoption_notices": active_adoptions, "announcements": active_announcements} + for text_code in ["how_to", "introduction"]: + try: + context[text_code] = Text.objects.get(text_code=text_code, language=lang, ) + except Text.DoesNotExist: + context[text_code] = None return render(request, 'fellchensammlung/index.html', context=context) @@ -96,7 +102,8 @@ def adoption_notice_detail(request, adoption_notice_id): raise PermissionDenied else: comment_form = CommentForm(instance=adoption_notice) - context = {"adoption_notice": adoption_notice, "comment_form": comment_form, "user": request.user, "has_edit_permission": has_edit_permission} + context = {"adoption_notice": adoption_notice, "comment_form": comment_form, "user": request.user, + "has_edit_permission": has_edit_permission} return render(request, 'fellchensammlung/details/detail_adoption_notice.html', context=context)