From da60d81e9048b486936dccc6b0422c6d9bbdb3fe Mon Sep 17 00:00:00 2001 From: Commander1024 Date: Tue, 6 Oct 2020 17:01:29 +0200 Subject: [PATCH] Addes help_texts and translations. --- django_lostplaces/lostplaces/forms.py | 4 +++- .../locale/de/LC_MESSAGES/django.po | 22 ++++++++++++++++++- .../lostplaces/models/abstract_models.py | 7 ++++-- django_lostplaces/lostplaces/models/place.py | 5 +++-- 4 files changed, 32 insertions(+), 6 deletions(-) diff --git a/django_lostplaces/lostplaces/forms.py b/django_lostplaces/lostplaces/forms.py index 9ce88d3..e630a2e 100644 --- a/django_lostplaces/lostplaces/forms.py +++ b/django_lostplaces/lostplaces/forms.py @@ -4,8 +4,10 @@ ''' (web)forms that can be used elsewhere. ''' from django import forms +from django.db import models from django.contrib.auth.forms import UserCreationForm, UserChangeForm from django.contrib.auth.models import User +from django.utils.translation import ugettext_lazy as _ from lostplaces.models import Place, PlaceImage, Voucher class ExplorerCreationForm(UserCreationForm): @@ -14,7 +16,7 @@ class ExplorerCreationForm(UserCreationForm): fields = ('username', 'email') voucher = forms.CharField( max_length=30, - help_text='The Voucher you got from an administrator' + help_text=_('The Voucher you got from an administrator') ) def is_valid(self): diff --git a/django_lostplaces/lostplaces/locale/de/LC_MESSAGES/django.po b/django_lostplaces/lostplaces/locale/de/LC_MESSAGES/django.po index eb18d60..dd405ef 100644 --- a/django_lostplaces/lostplaces/locale/de/LC_MESSAGES/django.po +++ b/django_lostplaces/lostplaces/locale/de/LC_MESSAGES/django.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-10-05 20:26+0200\n" +"POT-Creation-Date: 2020-10-06 16:59+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -18,6 +18,26 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" +#: forms.py:19 +msgid "The Voucher you got from an administrator" +msgstr "Der Einladungs-Code, den Dir ein Administrator gegeben hat" + +#: models/abstract_models.py:32 +msgid "Latitude in decimal format: e. g. 41.40338" +msgstr "Breitengrad in dezimaler Form: z. B. 51.95021" + +#: models/abstract_models.py:39 +msgid "Longitude in decimal format: e. g. 2.17403" +msgstr "Breitengrad in dezimaler Form: z. B. 7.4840155" + +#: models/place.py:19 +msgid "Location" +msgstr "Ort" + +#: models/place.py:20 +msgid "Description" +msgstr "Beschreibung" + #: templates/403.html:4 msgid "Forbidden" msgstr "Nicht Erlaubt" diff --git a/django_lostplaces/lostplaces/models/abstract_models.py b/django_lostplaces/lostplaces/models/abstract_models.py index c95ce61..e1a2d52 100644 --- a/django_lostplaces/lostplaces/models/abstract_models.py +++ b/django_lostplaces/lostplaces/models/abstract_models.py @@ -1,5 +1,6 @@ from django.db import models +from django.utils.translation import ugettext_lazy as _ from django.core.validators import MaxValueValidator, MinValueValidator from taggit.managers import TaggableManager @@ -27,13 +28,15 @@ class Mapable(models.Model): validators=[ MinValueValidator(-90), MaxValueValidator(90) - ] + ], + help_text=_('Latitude in decimal format: e. g. 41.40338') ) longitude = models.FloatField( validators=[ MinValueValidator(-180), MaxValueValidator(180) - ] + ], + help_text=_('Longitude in decimal format: e. g. 2.17403') ) class Submittable(models.Model): diff --git a/django_lostplaces/lostplaces/models/place.py b/django_lostplaces/lostplaces/models/place.py index 402afdb..a2245b3 100644 --- a/django_lostplaces/lostplaces/models/place.py +++ b/django_lostplaces/lostplaces/models/place.py @@ -4,6 +4,7 @@ from django.db import models from django.urls import reverse from django.dispatch import receiver from django.db.models.signals import post_delete, pre_save +from django.utils.translation import ugettext_lazy as _ from lostplaces.models.abstract_models import Submittable, Taggable, Mapable @@ -15,8 +16,8 @@ class Place(Submittable, Taggable, Mapable): Place defines a lost place (location, name, description etc.). """ - location = models.CharField(max_length=50) - description = models.TextField() + location = models.CharField(max_length=50, help_text=_('Location')) + description = models.TextField(help_text=_('Description')) def get_absolute_url(self): return reverse('place_detail', kwargs={'pk': self.pk})