From 04db4e4e7f1d1a6ef399a3a0588e7c5429607c8e Mon Sep 17 00:00:00 2001 From: mipel Date: Tue, 3 Aug 2021 17:22:41 +0200 Subject: [PATCH] Fixes and improvements * moves diff_states message back to table top for direct presentation in compensation/detail/view.html * removes diff_states rendering in deadline card in compensation/detail/view.html * fixes before_state adding based on GET parameter * refactors UserActionlogEntryEnum into a UserAction TextChoice (Django 3.x) * adds ordering of compensation states depending on surface value * refactors ServerMessageImportance from enum into TextChoice (Django 3.x) * adds/updates translations --- compensation/forms.py | 51 ++++- compensation/models.py | 7 +- .../detail/includes/deadlines.html | 5 - .../detail/includes/states-after.html | 12 +- .../detail/includes/states-before.html | 12 +- compensation/views.py | 16 +- intervention/forms.py | 5 +- intervention/models.py | 5 +- konova/enums.py | 19 -- konova/forms.py | 13 +- konova/models.py | 2 +- konova/settings.py | 7 - konova/templatetags/ksp_filters.py | 10 +- locale/de/LC_MESSAGES/django.mo | Bin 13180 -> 13328 bytes locale/de/LC_MESSAGES/django.po | 188 ++++++++++-------- news/models.py | 13 +- user/models.py | 14 +- 17 files changed, 215 insertions(+), 164 deletions(-) diff --git a/compensation/forms.py b/compensation/forms.py index 9b443de5..ea446d10 100644 --- a/compensation/forms.py +++ b/compensation/forms.py @@ -6,14 +6,18 @@ Created on: 04.12.20 """ from django import forms +from django.contrib import messages from django.db import transaction +from django.http import HttpRequest +from django.shortcuts import redirect, render from django.utils.translation import gettext_lazy as _ from compensation.models import Payment, CompensationState -from konova.enums import UserActionLogEntryEnum +from konova.contexts import BaseContext from konova.forms import BaseForm, BaseModalForm from konova.models import Deadline, DeadlineType -from user.models import UserActionLogEntry +from konova.utils.message_templates import FORM_INVALID +from user.models import UserActionLogEntry, UserAction class NewCompensationForm(BaseForm): @@ -61,7 +65,7 @@ class NewPaymentForm(BaseModalForm): with transaction.atomic(): action = UserActionLogEntry.objects.create( user=self.user, - action=UserActionLogEntryEnum.CREATED.value, + action=UserAction.CREATED, ) pay = Payment.objects.create( created=action, @@ -106,6 +110,45 @@ class NewStateModalForm(BaseModalForm): self.instance.after_states.add(state) return state + def process_request(self, request: HttpRequest, msg_success: str = _("Object removed"), msg_error: str = FORM_INVALID, redirect_url: str = None): + """ Generic processing of request + + Wraps the request processing logic, so we don't need the same code everywhere a RemoveModalForm is being used + + Args: + request (HttpRequest): The incoming request + msg_success (str): The message in case of successful removing + msg_error (str): The message in case of an error + + Returns: + + """ + redirect_url = redirect_url if redirect_url is not None else request.META.get("HTTP_REFERER", "home") + template = self.template + if request.method == "POST": + if self.is_valid(): + is_before_state = bool(request.GET.get("before", False)) + self.save(is_before_state=is_before_state) + messages.success( + request, + msg_success + ) + return redirect(redirect_url) + else: + messages.info( + request, + msg_error + ) + return redirect(redirect_url) + elif request.method == "GET": + context = { + "form": self, + } + context = BaseContext(request, context).context + return render(request, template, context) + else: + raise NotImplementedError + class NewDeadlineModalForm(BaseModalForm): type = forms.ChoiceField( @@ -150,7 +193,7 @@ class NewDeadlineModalForm(BaseModalForm): with transaction.atomic(): action = UserActionLogEntry.objects.create( user=self.user, - action=UserActionLogEntryEnum.CREATED.value + action=UserAction.CREATED.value ) deadline = Deadline.objects.create( type=self.cleaned_data["type"], diff --git a/compensation/models.py b/compensation/models.py index 0031bd98..4d54af41 100644 --- a/compensation/models.py +++ b/compensation/models.py @@ -14,11 +14,10 @@ from django.utils.timezone import now from compensation.settings import COMPENSATION_IDENTIFIER_LENGTH, COMPENSATION_IDENTIFIER_TEMPLATE from intervention.models import Intervention, ResponsibilityData -from konova.enums import UserActionLogEntryEnum from konova.models import BaseObject, BaseResource, Geometry, UuidModel from konova.utils.generators import generate_random_string from organisation.models import Organisation -from user.models import UserActionLogEntry +from user.models import UserActionLogEntry, UserAction class Payment(BaseResource): @@ -156,11 +155,9 @@ class Compensation(AbstractCompensation): action = UserActionLogEntry.objects.create( user=_user, timestamp=_now, - action=UserActionLogEntryEnum.DELETED.value + action=UserAction.DELETED ) self.deleted = action - #self.deleted_on = _now - #self.deleted_by = _user self.save() def save(self, *args, **kwargs): diff --git a/compensation/templates/compensation/detail/includes/deadlines.html b/compensation/templates/compensation/detail/includes/deadlines.html index 7cdcd383..5764edda 100644 --- a/compensation/templates/compensation/detail/includes/deadlines.html +++ b/compensation/templates/compensation/detail/includes/deadlines.html @@ -57,10 +57,5 @@ {% endfor %} - {% if sum_before_states > sum_after_states %} -
- {% trans 'Missing surfaces: ' %}{{ diff_states|floatformat:2 }} m² -
- {% endif %} \ No newline at end of file diff --git a/compensation/templates/compensation/detail/includes/states-after.html b/compensation/templates/compensation/detail/includes/states-after.html index 5c93f549..d9374093 100644 --- a/compensation/templates/compensation/detail/includes/states-after.html +++ b/compensation/templates/compensation/detail/includes/states-after.html @@ -21,6 +21,11 @@
+ {% if sum_before_states > sum_after_states %} +
+ {% trans 'Missing surfaces: ' %}{{ diff_states|floatformat:2 }} m² +
+ {% endif %} @@ -36,7 +41,7 @@ - {% for state in comp.after_states.all %} + {% for state in after_states %}
{{ state.biotope_type }} @@ -53,10 +58,5 @@ {% endfor %}
- {% if sum_before_states > sum_after_states %} -
- {% trans 'Missing surfaces: ' %}{{ diff_states|floatformat:2 }} m² -
- {% endif %}
\ No newline at end of file diff --git a/compensation/templates/compensation/detail/includes/states-before.html b/compensation/templates/compensation/detail/includes/states-before.html index b2910041..266b067f 100644 --- a/compensation/templates/compensation/detail/includes/states-before.html +++ b/compensation/templates/compensation/detail/includes/states-before.html @@ -21,6 +21,11 @@
+ {% if sum_before_states < sum_after_states %} +
+ {% trans 'Missing surfaces: ' %}{{ diff_states|floatformat:2 }} m² +
+ {% endif %} @@ -36,7 +41,7 @@ - {% for state in comp.before_states.all %} + {% for state in before_states %}
{{ state.biotope_type }} @@ -53,10 +58,5 @@ {% endfor %}
- {% if sum_before_states < sum_after_states %} -
- {% trans 'Missing surfaces: ' %}{{ diff_states|floatformat:2 }} m² -
- {% endif %}
\ No newline at end of file diff --git a/compensation/views.py b/compensation/views.py index 6064c621..98fe64c7 100644 --- a/compensation/views.py +++ b/compensation/views.py @@ -76,22 +76,28 @@ def open_view(request: HttpRequest, id: str): _user = request.user is_data_shared = comp.intervention.is_shared_with(_user) + # Order states according to surface + before_states = comp.before_states.all().order_by("-surface") + after_states = comp.after_states.all().order_by("-surface") + # Precalculate logical errors between before- and after-states # Sum() returns None in case of no states, so we catch that and replace it with 0 for easier handling - sum_before_states = comp.before_states.all().aggregate(Sum("surface"))["surface__sum"] or 0 - sum_after_states = comp.after_states.all().aggregate(Sum("surface"))["surface__sum"] or 0 + sum_before_states = before_states.aggregate(Sum("surface"))["surface__sum"] or 0 + sum_after_states = after_states.aggregate(Sum("surface"))["surface__sum"] or 0 diff_states = abs(sum_before_states - sum_after_states) context = { "comp": comp, "geom_form": geom_form, "has_access": is_data_shared, - "is_default_member": in_group(_user, _(DEFAULT_GROUP)), - "is_zb_member": in_group(_user, _(ZB_GROUP)), - "is_ets_member": in_group(_user, _(ETS_GROUP)), + "before_states": before_states, + "after_states": after_states, "sum_before_states": sum_before_states, "sum_after_states": sum_after_states, "diff_states": diff_states, + "is_default_member": in_group(_user, _(DEFAULT_GROUP)), + "is_zb_member": in_group(_user, _(ZB_GROUP)), + "is_ets_member": in_group(_user, _(ETS_GROUP)), } context = BaseContext(request, context).context return render(request, template, context) diff --git a/intervention/forms.py b/intervention/forms.py index 107ea906..aa7e0d3b 100644 --- a/intervention/forms.py +++ b/intervention/forms.py @@ -15,13 +15,12 @@ from django.urls import reverse from django.utils.translation import gettext_lazy as _ from intervention.models import Intervention -from konova.enums import UserActionLogEntryEnum from konova.forms import BaseForm, BaseModalForm from konova.models import Document from konova.settings import DEFAULT_LAT, DEFAULT_LON, DEFAULT_ZOOM, ZB_GROUP, ETS_GROUP from konova.utils.user_checks import in_group from organisation.models import Organisation -from user.models import UserActionLogEntry +from user.models import UserActionLogEntry, UserAction class NewInterventionForm(BaseForm): @@ -120,7 +119,7 @@ class NewInterventionForm(BaseForm): action = UserActionLogEntry.objects.create( user=user, - action=UserActionLogEntryEnum.CREATED.value, + action=UserAction.CREATED, ) intervention = Intervention( identifier=identifier, diff --git a/intervention/models.py b/intervention/models.py index a9406390..53b8b0bf 100644 --- a/intervention/models.py +++ b/intervention/models.py @@ -12,12 +12,11 @@ from django.utils import timezone from django.utils.timezone import now from intervention.settings import INTERVENTION_IDENTIFIER_LENGTH, INTERVENTION_IDENTIFIER_TEMPLATE -from konova.enums import UserActionLogEntryEnum from konova.models import BaseObject, Geometry, UuidModel from konova.utils import generators from konova.utils.generators import generate_random_string from organisation.models import Organisation -from user.models import UserActionLogEntry +from user.models import UserActionLogEntry, UserAction class ResponsibilityData(UuidModel): @@ -139,7 +138,7 @@ class Intervention(BaseObject): action = UserActionLogEntry.objects.create( user=_user, timestamp=_now, - action=UserActionLogEntryEnum.DELETED.value + action=UserAction.DELETED ) for com in coms: com.deleted = action diff --git a/konova/enums.py b/konova/enums.py index 90faaa02..70938b11 100644 --- a/konova/enums.py +++ b/konova/enums.py @@ -38,22 +38,3 @@ class UnitEnum(BaseEnum): ha = "ha" st = "St." # pieces - - -class ServerMessageImportance(BaseEnum): - """ - Defines importance levels for server messages - """ - DEFAULT = "DEFAULT" - INFO = "INFO" - WARNING = "WARNING" - - -class UserActionLogEntryEnum(BaseEnum): - """ - Defines different possible user actions for UserActionLogEntry - """ - CHECKED = "Checked" - RECORDED = "Recorded" - CREATED = "Created" - DELETED = "Deleted" \ No newline at end of file diff --git a/konova/forms.py b/konova/forms.py index c626c79b..c774e91b 100644 --- a/konova/forms.py +++ b/konova/forms.py @@ -21,10 +21,9 @@ from django.utils import timezone from django.utils.translation import gettext_lazy as _ from konova.contexts import BaseContext -from konova.enums import UserActionLogEntryEnum from konova.models import Document from konova.utils.message_templates import FORM_INVALID -from user.models import UserActionLogEntry +from user.models import UserActionLogEntry, UserAction class BaseForm(forms.Form): @@ -117,11 +116,9 @@ class RemoveForm(BaseForm): action = UserActionLogEntry.objects.create( user=user, timestamp=timezone.now(), - action=UserActionLogEntryEnum.DELETED.value + action=UserAction.DELETED ) self.object_to_remove.deleted = action - #self.object_to_remove.deleted_on = timezone.now() - #self.object_to_remove.deleted_by = user self.object_to_remove.save() return self.object_to_remove @@ -229,11 +226,9 @@ class RemoveModalForm(BaseModalForm): action = UserActionLogEntry.objects.create( user=self.user, timestamp=timezone.now(), - action=UserActionLogEntryEnum.DELETED.value, + action=UserAction.DELETED, ) self.instance.deleted = action - #self.instance.deleted_on = timezone.now() - #self.instance.deleted_by = self.user self.instance.save() else: # If the class does not provide restorable delete functionality, we must delete the entry finally @@ -297,7 +292,7 @@ class NewDocumentForm(BaseModalForm): with transaction.atomic(): action = UserActionLogEntry.objects.create( user=self.user, - action=UserActionLogEntryEnum.CREATED.value, + action=UserAction.CREATED, ) doc = Document.objects.create( created=action, diff --git a/konova/models.py b/konova/models.py index f0ad64dc..7c75273a 100644 --- a/konova/models.py +++ b/konova/models.py @@ -12,7 +12,6 @@ from django.utils.translation import gettext_lazy as _ from django.contrib.gis.db.models import MultiPolygonField from django.db import models -from konova.settings import DEFAULT_SRID from user.models import UserActionLogEntry @@ -120,4 +119,5 @@ class Geometry(BaseResource): """ Outsourced geometry model so multiple versions of the same object can refer to the same geometry if it is not changed """ + from konova.settings import DEFAULT_SRID geom = MultiPolygonField(null=True, blank=True, srid=DEFAULT_SRID) diff --git a/konova/settings.py b/konova/settings.py index d2f71fc5..4ea10255 100644 --- a/konova/settings.py +++ b/konova/settings.py @@ -12,7 +12,6 @@ https://docs.djangoproject.com/en/3.1/ref/settings/ from django.utils.translation import gettext_lazy as _ # Load other settings -from konova.enums import ServerMessageImportance from konova.sub_settings.django_settings import * # Num of days if user enables Remember-me on login @@ -55,12 +54,6 @@ DEFAULT_GROUP = "Default" ZB_GROUP = "Registration office" ETS_GROUP = "Conservation office" -# ServerMessageImportance bootstrap resolver -SVI_BOOTSTRAP_CLS_MAP = { - ServerMessageImportance.DEFAULT.value: "", - ServerMessageImportance.WARNING.value: "alert-danger", - ServerMessageImportance.INFO.value: "alert-info", -} # HELP PAGE LINK HELP_LINK = "https://dienste.naturschutz.rlp.de/doku/doku.php?id=ksp:start" \ No newline at end of file diff --git a/konova/templatetags/ksp_filters.py b/konova/templatetags/ksp_filters.py index 6ee3dd34..490799fd 100644 --- a/konova/templatetags/ksp_filters.py +++ b/konova/templatetags/ksp_filters.py @@ -6,11 +6,19 @@ Created on: 05.07.21 """ from django import template -from konova.settings import SVI_BOOTSTRAP_CLS_MAP # Create custom library +from news.models import ServerMessageImportance + register = template.Library() +# ServerMessageImportance bootstrap resolver +SVI_BOOTSTRAP_CLS_MAP = { + ServerMessageImportance.DEFAULT.name: "", + ServerMessageImportance.WARNING.name: "alert-danger", + ServerMessageImportance.INFO.name: "alert-info", +} + @register.filter("bootstrap_cls") def bootstrap_cls(value): diff --git a/locale/de/LC_MESSAGES/django.mo b/locale/de/LC_MESSAGES/django.mo index b900614c8c5db3097043386173bfe3ed17cfc00d..5a3a96b2b155ecc82e8ee2a9bca6459aa09b3add 100644 GIT binary patch delta 4616 zcmYk=2~btl1IO_r`yvX@R7%AM3MpWTBAJPrX|9$Wlozd-`~4Or#t-K=iKw|y=T48{{M@)OY)r4o}d+m z<2dO^)`u8#Wea0cqf~3mk{DxZa4A+|qQ@Bi%x3F;}XJY3hc zN8R5QdteGC(7u^KK|OyABe4>>*DSI1>roHbg8Z31e5k==sQXT#uK(Je|Bhjto3`%v z;i!Scpsq_pCesYX5ZX86DCj|xP(9B@HSiGfXB<9)aD}aZ7BvGKQ8QML;rK4RL^*b8;x5Y!AzM9t7NREK7uu6r0Y_0^~j ztVK2SGIqdisOyhlFn(yi|D+xBuPHfAg*L@6*c}7fyB$eI-PqgO7d1nf=*8jK3G-1M zoQKT5S&r)XCe%zGv>rvx)aUm6oA%7VHrIJ7H1gk2J^u$)9~$dEI1*JKiyCP>s$=PR z6<&|J{ti?}#-keYp_Zt~p3g?zSB*4b7CRI)@(rjP>rpqnZ7=u)HIg4tBMH3H9bpV= z>5@%;m4?vbz}!>#u8DRGX=FrGEhr50yXu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!B#^|=_9(1Bd(2AeO z#tEdlC#A_o)=jtpeL!hEJ_KD{W6%LqqLrG9cDN8-6Se3ne+4b|2F%0l=m7tKR^k#i z!!$7A7aUqYt<(?w6t+4MpGSedx@dK))qbXa~#D0dK@Kd=p*$JF!0=LI-{o zT_YJilj};ch2Q@&8qGN|Jf64*xi*YNe~9K|I&MLK(RQGV=_oqj^JoPxMz2M)dnK== z0Mj{Ngsz#}(E$%p`VS*$IHS?%jLXph%|sW?P}mNA%U5Lo0C+)9{mTcW>mU?5&ae>h5SNgg-`9oYEjtY{Vb zfK_pSE!xp`bjC-pCDx+@KZAa|{*G<1CFSzD9a1zbRS&du{qgHK6}@mX+R-j-jR(*H zoUVOG(HEdXn*v+k?6q2q63+NuBip+^HQs6c*7=iM0?TF)?-_IAAMIB zF%KK!`5Z>;OuJz=_KKFGi}h}_gHf1)CA*+MJVodl8I6tq|7X%@!hyHQBC>?I zO(D+`p4Yg|;d5kc%eTl~WFhgDjVC^MC2?TY#O-Nvrwz9I$*+jNkbVV!&iV^$iQ9BC zpA?gO$@hrcaN-OfAy&xkXhQfAJ{a51av(WL_(FxJ$R4tfY$hy~Fp1QXp=1|H`L3yW zT*7SrGSGN{w4nK67Hb7Y>N+!O_n-LI2@3 za^&+PxQ@I*D&w&?@t5RP(mx(^rN0x~h4>^{PaY<-$PDsL@&ocBnLtL6?~o$0k+`KE zPYf?a4`F+%Mv?B-OF=;`Dk?rn$VS72Yzx;(`zo7k_WPd{PU5zKl zVyD>t9j1{gvWW~KJIPC=JLyZ@UQYje1-gs+(dp&+_ofy3Y<;m#{E!N-R`|+HPdq|v!+$dsR%, YEAR. # #: compensation/forms.py:34 compensation/forms.py:39 compensation/forms.py:52 -#: compensation/forms.py:138 intervention/filters.py:26 +#: compensation/forms.py:177 intervention/filters.py:26 #: intervention/filters.py:40 intervention/filters.py:47 -#: intervention/filters.py:48 konova/forms.py:85 konova/forms.py:216 -#: konova/forms.py:249 konova/forms.py:254 konova/forms.py:266 -#: konova/forms.py:277 konova/forms.py:290 user/forms.py:38 +#: intervention/filters.py:48 konova/forms.py:84 konova/forms.py:213 +#: konova/forms.py:244 konova/forms.py:249 konova/forms.py:261 +#: konova/forms.py:272 konova/forms.py:285 user/forms.py:38 #, fuzzy msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2021-08-03 12:54+0200\n" +"POT-Creation-Date: 2021-08-03 17:21+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -67,8 +67,8 @@ msgid "Select the biotope type" msgstr "Biotoptyp wählen" #: compensation/forms.py:90 -#: compensation/templates/compensation/detail/includes/states-after.html:31 -#: compensation/templates/compensation/detail/includes/states-before.html:31 +#: compensation/templates/compensation/detail/includes/states-after.html:36 +#: compensation/templates/compensation/detail/includes/states-before.html:36 msgid "Surface" msgstr "Fläche" @@ -84,45 +84,49 @@ msgstr "Neuer Zustand" msgid "Insert data for the new state" msgstr "Geben Sie die Daten des neuen Zustandes ein" -#: compensation/forms.py:116 +#: compensation/forms.py:113 konova/forms.py:134 +msgid "Object removed" +msgstr "Objekt entfernt" + +#: compensation/forms.py:155 msgid "Deadline Type" msgstr "Fristart" -#: compensation/forms.py:119 +#: compensation/forms.py:158 msgid "Select the deadline type" msgstr "Fristart wählen" -#: compensation/forms.py:123 +#: compensation/forms.py:162 #: compensation/templates/compensation/detail/includes/deadlines.html:31 msgid "Date" msgstr "Datum" -#: compensation/forms.py:126 +#: compensation/forms.py:165 msgid "Select date" msgstr "Datum wählen" -#: compensation/forms.py:137 +#: compensation/forms.py:176 #: compensation/templates/compensation/detail/includes/deadlines.html:34 #: compensation/templates/compensation/detail/includes/documents.html:31 #: intervention/templates/intervention/detail/includes/documents.html:31 -#: konova/forms.py:276 +#: konova/forms.py:271 msgid "Comment" msgstr "Kommentar" -#: compensation/forms.py:139 +#: compensation/forms.py:178 msgid "Additional comment" msgstr "Zusätzlicher Kommentar" -#: compensation/forms.py:150 +#: compensation/forms.py:189 msgid "New deadline" msgstr "Neue Frist" -#: compensation/forms.py:151 +#: compensation/forms.py:190 msgid "Insert data for the new deadline" msgstr "Geben Sie die Daten der neuen Frist ein" #: compensation/tables.py:24 compensation/tables.py:164 -#: intervention/forms.py:29 intervention/tables.py:23 +#: intervention/forms.py:28 intervention/tables.py:23 #: intervention/templates/intervention/detail/includes/compensations.html:30 msgid "Identifier" msgstr "Kennung" @@ -130,24 +134,24 @@ msgstr "Kennung" #: compensation/tables.py:29 compensation/tables.py:169 #: compensation/templates/compensation/detail/includes/documents.html:28 #: compensation/templates/compensation/detail/view.html:47 -#: intervention/forms.py:36 intervention/tables.py:28 +#: intervention/forms.py:35 intervention/tables.py:28 #: intervention/templates/intervention/detail/includes/compensations.html:33 #: intervention/templates/intervention/detail/includes/documents.html:28 -#: intervention/templates/intervention/detail/view.html:64 konova/forms.py:248 +#: intervention/templates/intervention/detail/view.html:64 konova/forms.py:243 msgid "Title" msgstr "Bezeichnung" #: compensation/tables.py:34 #: compensation/templates/compensation/detail/view.html:59 #: intervention/tables.py:33 -#: intervention/templates/intervention/detail/view.html:96 +#: intervention/templates/intervention/detail/view.html:96 user/models.py:48 msgid "Checked" msgstr "Geprüft" #: compensation/tables.py:40 #: compensation/templates/compensation/detail/view.html:73 #: intervention/tables.py:39 -#: intervention/templates/intervention/detail/view.html:110 +#: intervention/templates/intervention/detail/view.html:110 user/models.py:49 msgid "Recorded" msgstr "Verzeichnet" @@ -202,7 +206,7 @@ msgstr "Für Sie freigegeben - Datensatz kann bearbeitet werden" msgid "Access not granted" msgstr "Nicht freigegeben - Datensatz nur lesbar" -#: compensation/tables.py:174 konova/forms.py:253 +#: compensation/tables.py:174 konova/forms.py:248 msgid "Created on" msgstr "Erstellt" @@ -231,14 +235,14 @@ msgid "Add new deadline" msgstr "Neue Frist hinzufügen" #: compensation/templates/compensation/detail/includes/deadlines.html:28 -#: intervention/forms.py:41 +#: intervention/forms.py:40 msgid "Type" msgstr "Typ" #: compensation/templates/compensation/detail/includes/deadlines.html:37 #: compensation/templates/compensation/detail/includes/documents.html:34 -#: compensation/templates/compensation/detail/includes/states-after.html:34 -#: compensation/templates/compensation/detail/includes/states-before.html:34 +#: compensation/templates/compensation/detail/includes/states-after.html:39 +#: compensation/templates/compensation/detail/includes/states-before.html:39 #: intervention/templates/intervention/detail/includes/compensations.html:36 #: intervention/templates/intervention/detail/includes/documents.html:34 #: intervention/templates/intervention/detail/includes/eco-account-withdraws.html:36 @@ -250,12 +254,6 @@ msgstr "Aktionen" msgid "Remove deadline" msgstr "Frist löschen" -#: compensation/templates/compensation/detail/includes/deadlines.html:62 -#: compensation/templates/compensation/detail/includes/states-after.html:58 -#: compensation/templates/compensation/detail/includes/states-before.html:58 -msgid "Missing surfaces: " -msgstr "Fehlende Flächen: " - #: compensation/templates/compensation/detail/includes/documents.html:8 #: intervention/templates/intervention/detail/includes/documents.html:8 msgid "Documents" @@ -263,7 +261,7 @@ msgstr "Dokumente" #: compensation/templates/compensation/detail/includes/documents.html:14 #: intervention/templates/intervention/detail/includes/documents.html:14 -#: konova/forms.py:289 +#: konova/forms.py:284 msgid "Add new document" msgstr "Neues Dokument hinzufügen" @@ -280,13 +278,18 @@ msgstr "Zielzustand" msgid "Add new state after" msgstr "Neuen Zielzustand hinzufügen" -#: compensation/templates/compensation/detail/includes/states-after.html:28 -#: compensation/templates/compensation/detail/includes/states-before.html:28 +#: compensation/templates/compensation/detail/includes/states-after.html:26 +#: compensation/templates/compensation/detail/includes/states-before.html:26 +msgid "Missing surfaces: " +msgstr "Fehlende Flächen: " + +#: compensation/templates/compensation/detail/includes/states-after.html:33 +#: compensation/templates/compensation/detail/includes/states-before.html:33 msgid "Biotope type" msgstr "Biotoptyp" -#: compensation/templates/compensation/detail/includes/states-after.html:47 -#: compensation/templates/compensation/detail/includes/states-before.html:47 +#: compensation/templates/compensation/detail/includes/states-after.html:52 +#: compensation/templates/compensation/detail/includes/states-before.html:52 msgid "Remove state" msgstr "Zustand entfernen" @@ -346,7 +349,7 @@ msgid "Last modified" msgstr "Zuletzt bearbeitet" #: compensation/templates/compensation/detail/view.html:97 -#: intervention/forms.py:257 +#: intervention/forms.py:256 #: intervention/templates/intervention/detail/view.html:142 msgid "Shared with" msgstr "Freigegeben für" @@ -356,35 +359,35 @@ msgstr "Freigegeben für" msgid "No geometry added, yet." msgstr "Keine Geometrie vorhanden" -#: compensation/views.py:115 +#: compensation/views.py:121 msgid "Compensation removed" msgstr "Kompensation entfernt" -#: compensation/views.py:195 +#: compensation/views.py:201 msgid "Payment added" msgstr "Zahlung hinzugefügt" -#: compensation/views.py:230 +#: compensation/views.py:236 msgid "Payment removed" msgstr "Zahlung gelöscht" -#: compensation/views.py:256 +#: compensation/views.py:262 msgid "Withdraw removed" msgstr "Abbuchung entfernt" -#: compensation/views.py:274 +#: compensation/views.py:280 msgid "Document added" msgstr "Dokument hinzugefügt" -#: compensation/views.py:293 +#: compensation/views.py:299 msgid "State added" msgstr "Zustand hinzugefügt" -#: compensation/views.py:312 +#: compensation/views.py:318 msgid "Deadline added" msgstr "Frist hinzugefügt" -#: compensation/views.py:322 +#: compensation/views.py:328 msgid "State removed" msgstr "Zustand gelöscht" @@ -404,90 +407,90 @@ msgstr "Gemarkung" msgid "Search for district" msgstr "Nach Gemarkung suchen" -#: intervention/forms.py:32 +#: intervention/forms.py:31 msgid "Generated automatically if none was given" msgstr "Wird automatisch erzeugt, falls nicht angegeben" -#: intervention/forms.py:44 +#: intervention/forms.py:43 msgid "Which intervention type is this" msgstr "Welcher Eingriffstyp" -#: intervention/forms.py:47 +#: intervention/forms.py:46 #: intervention/templates/intervention/detail/view.html:72 msgid "Law" msgstr "Gesetz" -#: intervention/forms.py:50 +#: intervention/forms.py:49 msgid "Based on which law" msgstr "Basiert auf welchem Recht" -#: intervention/forms.py:53 +#: intervention/forms.py:52 #: intervention/templates/intervention/detail/view.html:92 msgid "Intervention handler" msgstr "Eingriffsverursacher" -#: intervention/forms.py:56 +#: intervention/forms.py:55 msgid "Who performs the intervention" msgstr "Wer führt den Eingriff durch" -#: intervention/forms.py:59 +#: intervention/forms.py:58 msgid "Data provider" msgstr "Datenbereitsteller" -#: intervention/forms.py:61 +#: intervention/forms.py:60 msgid "Who provides the data for the intervention" msgstr "Wer stellt die Daten für den Eingriff zur Verfügung" -#: intervention/forms.py:66 +#: intervention/forms.py:65 msgid "Organization" msgstr "Organisation" -#: intervention/forms.py:72 +#: intervention/forms.py:71 msgid "Data provider details" msgstr "Datenbereitsteller Details" -#: intervention/forms.py:75 +#: intervention/forms.py:74 msgid "Further details" msgstr "Weitere Details" -#: intervention/forms.py:88 +#: intervention/forms.py:87 msgid "Map" msgstr "Karte" -#: intervention/forms.py:90 +#: intervention/forms.py:89 msgid "Where does the intervention take place" msgstr "Wo findet der Eingriff statt" -#: intervention/forms.py:98 +#: intervention/forms.py:97 msgid "Files" msgstr "Dateien" -#: intervention/forms.py:105 +#: intervention/forms.py:104 msgid "New intervention" msgstr "Neuer Eingriff" -#: intervention/forms.py:152 +#: intervention/forms.py:151 msgid "Edit intervention" msgstr "Eingriff bearbeiten" -#: intervention/forms.py:246 +#: intervention/forms.py:245 msgid "Share link" msgstr "Freigabelink" -#: intervention/forms.py:248 +#: intervention/forms.py:247 msgid "Send this link to users who you want to have writing access on the data" msgstr "Andere Nutzer erhalten über diesen Link Zugriff auf die Daten" -#: intervention/forms.py:260 +#: intervention/forms.py:259 msgid "Remove check to remove access for this user" msgstr "Wählen Sie die Nutzer ab, die keinen Zugriff mehr haben sollen" -#: intervention/forms.py:271 +#: intervention/forms.py:270 #: intervention/templates/intervention/detail/view.html:27 msgid "Share" msgstr "Freigabe" -#: intervention/forms.py:272 +#: intervention/forms.py:271 msgid "Share settings for {}" msgstr "Freigabe Einstellungen für {}" @@ -645,44 +648,40 @@ msgstr "" msgid "You need to be part of another user group." msgstr "Hierfür müssen Sie einer anderen Nutzergruppe angehören!" -#: konova/forms.py:58 +#: konova/forms.py:57 msgid "Not editable" msgstr "Nicht editierbar" -#: konova/forms.py:84 konova/forms.py:215 +#: konova/forms.py:83 konova/forms.py:212 msgid "Confirm" msgstr "Bestätige" -#: konova/forms.py:96 konova/forms.py:224 +#: konova/forms.py:95 konova/forms.py:221 msgid "Remove" msgstr "Löschen" -#: konova/forms.py:98 +#: konova/forms.py:97 msgid "You are about to remove {} {}" msgstr "Sie sind dabei {} {} zu löschen" -#: konova/forms.py:137 -msgid "Object removed" -msgstr "Objekt entfernt" - -#: konova/forms.py:225 +#: konova/forms.py:222 msgid "Are you sure?" msgstr "Sind Sie sicher?" -#: konova/forms.py:255 +#: konova/forms.py:250 msgid "When has this file been created? Important for photos." msgstr "Wann wurde diese Datei erstellt oder das Foto aufgenommen?" -#: konova/forms.py:265 +#: konova/forms.py:260 #: venv/lib/python3.7/site-packages/django/db/models/fields/files.py:231 msgid "File" msgstr "Datei" -#: konova/forms.py:267 +#: konova/forms.py:262 msgid "Must be smaller than 15 Mb" msgstr "Muss kleiner als 15 Mb sein" -#: konova/forms.py:278 +#: konova/forms.py:273 msgid "Additional comment on this file" msgstr "Zusätzlicher Kommentar" @@ -710,19 +709,19 @@ msgstr "Wenn meine freigegebenen Daten gelöscht wurden" msgid "On registered data edited" msgstr "Wenn meine freigegebenen Daten bearbeitet wurden" -#: konova/models.py:62 +#: konova/models.py:61 msgid "Finished" msgstr "Umgesetzt bis" -#: konova/models.py:63 +#: konova/models.py:62 msgid "Maintain" msgstr "Unterhaltung bis" -#: konova/models.py:64 +#: konova/models.py:63 msgid "Control" msgstr "Kontrolle am" -#: konova/models.py:65 +#: konova/models.py:64 msgid "Other" msgstr "Sonstige" @@ -774,6 +773,18 @@ msgstr "Dokument '{}' gelöscht" msgid "Deadline removed" msgstr "Frist gelöscht" +#: news/models.py:11 +msgid "Default" +msgstr "Standard" + +#: news/models.py:12 +msgid "Info" +msgstr "" + +#: news/models.py:13 +msgid "Warning" +msgstr "Warnung" + #: news/templates/news/dashboard-news.html:12 news/templates/news/index.html:19 msgid "Published on" msgstr "Veröffentlicht am" @@ -918,6 +929,14 @@ msgstr "" msgid "User contact data" msgstr "Kontaktdaten" +#: user/models.py:50 +msgid "Created" +msgstr "Erstellt" + +#: user/models.py:51 +msgid "Deleted" +msgstr "Gelöscht" + #: user/templates/user/includes/contact_modal_button.html:3 msgid "Show contact data" msgstr "Zeige Kontaktdaten" @@ -2159,9 +2178,6 @@ msgstr "" #~ msgid "Your own" #~ msgstr "Eigene" -#~ msgid "Default" -#~ msgstr "Standard" - #~ msgid "Quickstart" #~ msgstr "Schnellstart" diff --git a/news/models.py b/news/models.py index 2030c074..0a9d6dd6 100644 --- a/news/models.py +++ b/news/models.py @@ -1,9 +1,18 @@ from django.db import models +from django.utils.translation import gettext_lazy as _ -from konova.enums import ServerMessageImportance from konova.models import BaseResource +class ServerMessageImportance(models.TextChoices): + """ + Defines importance levels for server messages + """ + DEFAULT = "default", _("Default") + INFO = "info", _("Info") + WARNING = "warning", _("Warning") + + class ServerMessage(BaseResource): """ Holds messages, which can be displayed on the user's dashboard @@ -13,4 +22,4 @@ class ServerMessage(BaseResource): is_active = models.BooleanField(default=True) publish_on = models.DateTimeField() unpublish_on = models.DateTimeField() - importance = models.CharField(max_length=100, choices=ServerMessageImportance.as_choices(drop_empty_choice=True)) \ No newline at end of file + importance = models.CharField(max_length=100, choices=ServerMessageImportance.choices) diff --git a/user/models.py b/user/models.py index 588bf2f1..53a5ca7a 100644 --- a/user/models.py +++ b/user/models.py @@ -1,9 +1,9 @@ import uuid +from django.utils.translation import gettext_lazy as _ from django.contrib.auth.models import User from django.db import models -from konova.enums import UserActionLogEntryEnum from user.enums import UserNotificationEnum @@ -41,6 +41,16 @@ class KonovaUserExtension(models.Model): notifications = models.ManyToManyField(UserNotification, related_name="+") +class UserAction(models.TextChoices): + """ + Defines different possible user actions for UserActionLogEntry + """ + CHECKED = "checked", _("Checked") + RECORDED = "recorded", _("Recorded") + CREATED = "created", _("Created") + DELETED = "deleted", _("Deleted") + + class UserActionLogEntry(models.Model): """ Wraps a user action log entry @@ -58,7 +68,7 @@ class UserActionLogEntry(models.Model): null=True, blank=True, help_text="Short name for performed action - optional", - choices=UserActionLogEntryEnum.as_choices(drop_empty_choice=True), + choices=UserAction.choices, ) def __str__(self):