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>
```
# 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

View File

@ -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 %}
<h1>{% translate "Notfellchen - Vermittlungen finden" %}</h1>
<p>{% translate "Alle Tiere brauchen ein liebendes Zuhause. Damit keins vergessen wird gibt es diese Seite. Entwickelt und betreut von " %}<em><a
href="https://hyteck.de">moanos</a></em>!</p>
{% if introduction %}
<h1>{{ introduction.title }}</h1>
{{ introduction.content | render_markdown }}
{% endif %}
<h2>{% translate "Aktuelle Vermittlungen" %}</h2>
{% include "fellchensammlung/lists/list-adoption-notices.html" %}
{% if how_to %}
<h1>{{ how_to.title }}</h1>
{{ how_to.content | render_markdown }}
{% endif %}
{% endblock %}

View File

@ -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)