feat: Allow new custom texts

This commit is contained in:
moanos [he/him] 2024-08-08 10:50:11 +02:00
parent 739418feb6
commit ac139af706
3 changed files with 33 additions and 5 deletions

View File

@ -39,6 +39,19 @@ Query location data to debug
nf query_location <query> nf query_location <query>
``` ```
# 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 # Developer Notes

View File

@ -1,15 +1,23 @@
{% extends "fellchensammlung/base_generic.html" %} {% extends "fellchensammlung/base_generic.html" %}
{% load i18n %} {% load i18n %}
{% load custom_tags %}
{% block content %} {% block content %}
{% for announcement in announcements %} {% for announcement in announcements %}
{% include "fellchensammlung/partials/partial-announcement.html" %} {% include "fellchensammlung/partials/partial-announcement.html" %}
{% endfor %} {% endfor %}
<h1>{% translate "Notfellchen - Vermittlungen finden" %}</h1> {% if introduction %}
<p>{% translate "Alle Tiere brauchen ein liebendes Zuhause. Damit keins vergessen wird gibt es diese Seite. Entwickelt und betreut von " %}<em><a <h1>{{ introduction.title }}</h1>
href="https://hyteck.de">moanos</a></em>!</p> {{ introduction.content | render_markdown }}
{% endif %}
<h2>{% translate "Aktuelle Vermittlungen" %}</h2> <h2>{% translate "Aktuelle Vermittlungen" %}</h2>
{% include "fellchensammlung/lists/list-adoption-notices.html" %} {% include "fellchensammlung/lists/list-adoption-notices.html" %}
{% if how_to %}
<h1>{{ how_to.title }}</h1>
{{ how_to.content | render_markdown }}
{% endif %}
{% endblock %} {% endblock %}

View File

@ -43,7 +43,13 @@ def index(request):
language_code = translation.get_language() language_code = translation.get_language()
lang = Language.objects.get(languagecode=language_code) lang = Language.objects.get(languagecode=language_code)
active_announcements = Announcement.get_active_announcements(lang) active_announcements = Announcement.get_active_announcements(lang)
context = {"adoption_notices": active_adoptions, "announcements": active_announcements} 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) return render(request, 'fellchensammlung/index.html', context=context)
@ -96,7 +102,8 @@ def adoption_notice_detail(request, adoption_notice_id):
raise PermissionDenied raise PermissionDenied
else: else:
comment_form = CommentForm(instance=adoption_notice) 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) return render(request, 'fellchensammlung/details/detail_adoption_notice.html', context=context)