diff --git a/src/fellchensammlung/models.py b/src/fellchensammlung/models.py index 956b7d2..5b3cc1f 100644 --- a/src/fellchensammlung/models.py +++ b/src/fellchensammlung/models.py @@ -180,20 +180,6 @@ class Animal(models.Model): return reverse('animal-detail', args=[str(self.id)]) -class MarkdownContent(models.Model): - """ - Base class to store markdown content - """ - title = models.CharField(max_length=100) - content = models.TextField() - - class Meta: - verbose_name_plural = "Markdown content" - - def __str__(self): - return self.title - - class Rule(models.Model): """ Class to store rules @@ -339,3 +325,19 @@ class Member(models.Model): def get_absolute_url(self): return reverse("member-detail", args=[str(self.user.id)]) + + +class Text(models.Model): + """ + Base class to store markdown content + """ + title = models.CharField(max_length=100) + content = models.TextField() + language = models.OneToOneField(Language, on_delete=models.PROTECT) + text_code = models.CharField(max_length=24, verbose_name="text_code", blank=True) + + class Meta: + verbose_name_plural = "Markdown content" + + def __str__(self): + return self.title diff --git a/src/fellchensammlung/views.py b/src/fellchensammlung/views.py index bc8229f..8aa83ba 100644 --- a/src/fellchensammlung/views.py +++ b/src/fellchensammlung/views.py @@ -5,9 +5,10 @@ from django.contrib.auth.decorators import login_required from .mail import mail_admins_new_report from notfellchen import settings -from fellchensammlung.models import AdoptionNotice, MarkdownContent, Animal, Rule, Image, Report, ModerationAction, \ +from fellchensammlung.models import AdoptionNotice, Text, Animal, Rule, Image, Report, ModerationAction, \ Member from .forms import AdoptionNoticeForm, AnimalForm, ImageForm, ReportForm +from .models import Language def index(request): @@ -98,6 +99,12 @@ def add_animal_to_adoption(request, adoption_notice_id): def about(request): rules = Rule.objects.all() + if request.user.is_authenticated: + lang = request.user.member.preferred_language + else: + lang = Language.objects.get(languagecode="de") + terms_of_service = Text.objects.get(text_code="terms_of_service", language=lang) + imprint = Text.objects.get(text_code="imprint", language=lang) context = {"rules": rules} return render( request,