diff --git a/compensation/views.py b/compensation/views.py index ec6ddd7e..7f6923a0 100644 --- a/compensation/views.py +++ b/compensation/views.py @@ -15,6 +15,7 @@ from konova.utils.message_templates import FORM_INVALID @login_required +@any_group_check def index_view(request: HttpRequest): """ Renders the index view for compensation @@ -56,6 +57,7 @@ def edit_view(request: HttpRequest, id: str): @login_required +@any_group_check def open_view(request: HttpRequest, id: str): # ToDo pass @@ -81,6 +83,7 @@ def remove_view(request: HttpRequest, id: str): @login_required +@any_group_check def account_index_view(request: HttpRequest): """ Renders the index view for eco accounts @@ -122,6 +125,7 @@ def account_edit_view(request: HttpRequest, id: str): @login_required +@any_group_check def account_open_view(request: HttpRequest, id: str): # ToDo pass diff --git a/intervention/views.py b/intervention/views.py index f325f847..c9c27c8c 100644 --- a/intervention/views.py +++ b/intervention/views.py @@ -15,6 +15,7 @@ from konova.utils.user_checks import in_group @login_required +@any_group_check def index_view(request: HttpRequest): """ Renders the index view for Interventions @@ -115,6 +116,7 @@ def new_document_view(request: HttpRequest, id: str): @login_required +@any_group_check def open_view(request: HttpRequest, id: str): """ Renders a detail view for viewing an intervention's data diff --git a/konova/decorators.py b/konova/decorators.py index f4a3ae8a..3d1a5473 100644 --- a/konova/decorators.py +++ b/konova/decorators.py @@ -46,6 +46,25 @@ def superuser_required(function): return wrap +def any_group_check(function): + """ + Checks for any group membership. Adds a message in case of having none. + + """ + @wraps(function) + def wrap(request, *args, **kwargs): + user = request.user + # Inform user about missing group privileges! + groups = user.groups.all() + if not groups: + messages.info( + request, + _("+++ Attention: You are not part of any group. You won't be able to create, edit or do anything. Please contact an administrator. +++") + ) + return function(request, *args, **kwargs) + return wrap + + def default_group_required(function): """ A decorator for functions which shall only be usable for users of specific groups. diff --git a/konova/views.py b/konova/views.py index 9a33a17f..bb6ee96e 100644 --- a/konova/views.py +++ b/konova/views.py @@ -16,6 +16,7 @@ from django.utils.translation import gettext_lazy as _ from compensation.models import Compensation, EcoAccount from intervention.models import Intervention from konova.contexts import BaseContext +from konova.decorators import any_group_check from konova.forms import RemoveModalForm from konova.models import Document from news.models import ServerMessage @@ -37,6 +38,7 @@ def logout_view(request: HttpRequest): @login_required +@any_group_check def home_view(request: HttpRequest): """ Renders the landing page diff --git a/locale/de/LC_MESSAGES/django.mo b/locale/de/LC_MESSAGES/django.mo index cfda5044..6c35190b 100644 Binary files a/locale/de/LC_MESSAGES/django.mo and b/locale/de/LC_MESSAGES/django.mo differ diff --git a/locale/de/LC_MESSAGES/django.po b/locale/de/LC_MESSAGES/django.po index a5157759..88b904c6 100644 --- a/locale/de/LC_MESSAGES/django.po +++ b/locale/de/LC_MESSAGES/django.po @@ -6,14 +6,14 @@ #: compensation/forms.py:29 compensation/forms.py:34 compensation/forms.py:47 #: intervention/filters.py:26 intervention/filters.py:40 #: intervention/filters.py:47 intervention/filters.py:48 konova/forms.py:85 -#: konova/forms.py:177 konova/forms.py:247 konova/forms.py:252 -#: konova/forms.py:264 konova/forms.py:275 konova/forms.py:288 user/forms.py:38 +#: konova/forms.py:177 konova/forms.py:248 konova/forms.py:253 +#: konova/forms.py:265 konova/forms.py:276 konova/forms.py:289 user/forms.py:38 #, fuzzy msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2021-08-02 14:06+0200\n" +"POT-Creation-Date: 2021-08-03 09:19+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -24,7 +24,7 @@ msgstr "" "Plural-Forms: nplurals=2; plural=(n != 1);\n" #: compensation/forms.py:28 -#: intervention/templates/intervention/detail/includes/eco-account-withdraws.html:31 +#: intervention/templates/intervention/detail/includes/eco-account-withdraws.html:33 msgid "Amount" msgstr "Menge" @@ -33,7 +33,7 @@ msgid "Amount in Euro" msgstr "Betrag in Euro" #: compensation/forms.py:33 -#: intervention/templates/intervention/detail/includes/payments.html:29 +#: intervention/templates/intervention/detail/includes/payments.html:31 msgid "Due on" msgstr "Fällig am" @@ -58,26 +58,26 @@ msgid "Add a payment for intervention '{}'" msgstr "Neue Ersatzzahlung zu Eingriff '{}' hinzufügen" #: compensation/tables.py:24 compensation/tables.py:164 -#: intervention/forms.py:28 intervention/tables.py:23 -#: intervention/templates/intervention/detail/includes/compensations.html:28 +#: intervention/forms.py:29 intervention/tables.py:23 +#: intervention/templates/intervention/detail/includes/compensations.html:30 msgid "Identifier" msgstr "Kennung" #: compensation/tables.py:29 compensation/tables.py:169 -#: intervention/forms.py:35 intervention/tables.py:28 -#: intervention/templates/intervention/detail/includes/compensations.html:31 -#: intervention/templates/intervention/detail/includes/documents.html:26 -#: intervention/templates/intervention/detail/view.html:60 konova/forms.py:246 +#: intervention/forms.py:36 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:247 msgid "Title" msgstr "Bezeichnung" #: compensation/tables.py:34 intervention/tables.py:33 -#: intervention/templates/intervention/detail/view.html:92 +#: intervention/templates/intervention/detail/view.html:96 msgid "Checked" msgstr "Geprüft" #: compensation/tables.py:40 intervention/tables.py:39 -#: intervention/templates/intervention/detail/view.html:106 +#: intervention/templates/intervention/detail/view.html:110 msgid "Recorded" msgstr "Verzeichnet" @@ -128,7 +128,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:251 +#: compensation/tables.py:174 konova/forms.py:252 msgid "Created on" msgstr "Erstellt" @@ -148,19 +148,19 @@ msgstr "Bearbeite {}" msgid "Delete {}" msgstr "Lösche {}" -#: compensation/views.py:77 +#: compensation/views.py:79 msgid "Compensation removed" msgstr "Kompensation entfernt" -#: compensation/views.py:151 +#: compensation/views.py:156 msgid "Payment added" msgstr "Zahlung hinzugefügt" -#: compensation/views.py:185 +#: compensation/views.py:191 msgid "Payment removed" msgstr "Zahlung gelöscht" -#: compensation/views.py:210 +#: compensation/views.py:217 msgid "Withdraw removed" msgstr "Abbuchung entfernt" @@ -180,98 +180,99 @@ msgstr "Gemarkung" msgid "Search for district" msgstr "Nach Gemarkung suchen" -#: intervention/forms.py:31 +#: intervention/forms.py:32 msgid "Generated automatically if none was given" msgstr "Wird automatisch erzeugt, falls nicht angegeben" -#: intervention/forms.py:40 +#: intervention/forms.py:41 msgid "Type" msgstr "Typ" -#: intervention/forms.py:43 +#: intervention/forms.py:44 msgid "Which intervention type is this" msgstr "Welcher Eingriffstyp" -#: intervention/forms.py:46 -#: intervention/templates/intervention/detail/view.html:68 +#: intervention/forms.py:47 +#: intervention/templates/intervention/detail/view.html:72 msgid "Law" msgstr "Gesetz" -#: intervention/forms.py:49 +#: intervention/forms.py:50 msgid "Based on which law" msgstr "Basiert auf welchem Recht" -#: intervention/forms.py:52 -#: intervention/templates/intervention/detail/view.html:88 +#: intervention/forms.py:53 +#: intervention/templates/intervention/detail/view.html:92 msgid "Intervention handler" msgstr "Eingriffsverursacher" -#: intervention/forms.py:55 +#: intervention/forms.py:56 msgid "Who performs the intervention" msgstr "Wer führt den Eingriff durch" -#: intervention/forms.py:58 +#: intervention/forms.py:59 msgid "Data provider" msgstr "Datenbereitsteller" -#: intervention/forms.py:60 +#: intervention/forms.py:61 msgid "Who provides the data for the intervention" msgstr "Wer stellt die Daten für den Eingriff zur Verfügung" -#: intervention/forms.py:65 +#: intervention/forms.py:66 msgid "Organization" msgstr "Organisation" -#: intervention/forms.py:71 +#: intervention/forms.py:72 msgid "Data provider details" msgstr "Datenbereitsteller Details" -#: intervention/forms.py:74 +#: intervention/forms.py:75 msgid "Further details" msgstr "Weitere Details" -#: intervention/forms.py:87 +#: intervention/forms.py:88 msgid "Map" msgstr "Karte" -#: intervention/forms.py:89 +#: intervention/forms.py:90 msgid "Where does the intervention take place" msgstr "Wo findet der Eingriff statt" -#: intervention/forms.py:97 +#: intervention/forms.py:98 msgid "Files" msgstr "Dateien" -#: intervention/forms.py:104 +#: intervention/forms.py:105 msgid "New intervention" msgstr "Neuer Eingriff" -#: intervention/forms.py:151 +#: intervention/forms.py:152 msgid "Edit intervention" msgstr "Eingriff bearbeiten" -#: intervention/forms.py:245 +#: intervention/forms.py:246 msgid "Share link" msgstr "Freigabelink" -#: intervention/forms.py:247 +#: intervention/forms.py:248 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:256 +#: intervention/forms.py:257 +#: intervention/templates/intervention/detail/view.html:142 msgid "Shared with" msgstr "Freigegeben für" -#: intervention/forms.py:259 +#: intervention/forms.py:260 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:270 +#: intervention/forms.py:271 #: intervention/templates/intervention/detail/view.html:27 msgid "Share" msgstr "Freigabe" -#: intervention/forms.py:271 +#: intervention/forms.py:272 msgid "Share settings for {}" msgstr "Freigabe Einstellungen für {}" @@ -285,18 +286,18 @@ msgstr "Eingriffe" msgid "Intervention" msgstr "Eingriff" -#: intervention/templates/intervention/detail/includes/compensations.html:13 +#: intervention/templates/intervention/detail/includes/compensations.html:14 msgid "Add new compensation" msgstr "Neue Kompensation hinzufügen" -#: intervention/templates/intervention/detail/includes/compensations.html:34 -#: intervention/templates/intervention/detail/includes/documents.html:32 -#: intervention/templates/intervention/detail/includes/eco-account-withdraws.html:34 -#: intervention/templates/intervention/detail/includes/payments.html:35 +#: 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 +#: intervention/templates/intervention/detail/includes/payments.html:37 msgid "Action" msgstr "Aktionen" -#: intervention/templates/intervention/detail/includes/compensations.html:48 +#: intervention/templates/intervention/detail/includes/compensations.html:51 msgid "Remove compensation" msgstr "Kompensation entfernen" @@ -304,17 +305,17 @@ msgstr "Kompensation entfernen" msgid "Documents" msgstr "Dokumente" -#: intervention/templates/intervention/detail/includes/documents.html:13 -#: konova/forms.py:287 +#: intervention/templates/intervention/detail/includes/documents.html:14 +#: konova/forms.py:288 msgid "Add new document" msgstr "Neues Dokument hinzufügen" -#: intervention/templates/intervention/detail/includes/documents.html:29 -#: konova/forms.py:274 +#: intervention/templates/intervention/detail/includes/documents.html:31 +#: konova/forms.py:275 msgid "Comment" msgstr "Kommentar" -#: intervention/templates/intervention/detail/includes/documents.html:46 +#: intervention/templates/intervention/detail/includes/documents.html:49 msgid "Remove document" msgstr "Dokument löschen" @@ -322,15 +323,15 @@ msgstr "Dokument löschen" msgid "Eco Account Withdraws" msgstr "Ökokonto Abbuchungen" -#: intervention/templates/intervention/detail/includes/eco-account-withdraws.html:13 +#: intervention/templates/intervention/detail/includes/eco-account-withdraws.html:14 msgid "Add new withdraw" msgstr "Neue Abbuchung hinzufügen" -#: intervention/templates/intervention/detail/includes/eco-account-withdraws.html:28 +#: intervention/templates/intervention/detail/includes/eco-account-withdraws.html:30 msgid "Account Identifier" msgstr "Ökokonto Kennung" -#: intervention/templates/intervention/detail/includes/eco-account-withdraws.html:48 +#: intervention/templates/intervention/detail/includes/eco-account-withdraws.html:51 msgid "Remove Withdraw" msgstr "Abbuchung entfernen" @@ -338,20 +339,20 @@ msgstr "Abbuchung entfernen" msgid "Payments" msgstr "Ersatzzahlungen" -#: intervention/templates/intervention/detail/includes/payments.html:13 +#: intervention/templates/intervention/detail/includes/payments.html:14 msgid "Add new payment" msgstr "Neue Zahlung hinzufügen" -#: intervention/templates/intervention/detail/includes/payments.html:26 +#: intervention/templates/intervention/detail/includes/payments.html:28 msgctxt "money" msgid "Amount" msgstr "Betrag" -#: intervention/templates/intervention/detail/includes/payments.html:32 +#: intervention/templates/intervention/detail/includes/payments.html:34 msgid "Transfer comment" msgstr "Verwendungszweck" -#: intervention/templates/intervention/detail/includes/payments.html:50 +#: intervention/templates/intervention/detail/includes/payments.html:53 msgid "Remove payment" msgstr "Zahlung entfernen" @@ -363,85 +364,85 @@ msgstr "In LANIS öffnen" msgid "Public report" msgstr "Öffentlicher Bericht" -#: intervention/templates/intervention/detail/view.html:31 +#: intervention/templates/intervention/detail/view.html:32 msgid "Run check" msgstr "Prüfung vornehmen" -#: intervention/templates/intervention/detail/view.html:36 +#: intervention/templates/intervention/detail/view.html:39 msgid "Record" msgstr "Verzeichnen" -#: intervention/templates/intervention/detail/view.html:41 +#: intervention/templates/intervention/detail/view.html:46 msgid "Edit" msgstr "Bearbeiten" -#: intervention/templates/intervention/detail/view.html:46 +#: intervention/templates/intervention/detail/view.html:50 #: venv/lib/python3.7/site-packages/django/forms/formsets.py:391 msgid "Delete" msgstr "Löschen" -#: intervention/templates/intervention/detail/view.html:64 +#: intervention/templates/intervention/detail/view.html:68 msgid "Process type" msgstr "Verfahrenstyp" -#: intervention/templates/intervention/detail/view.html:72 +#: intervention/templates/intervention/detail/view.html:76 msgid "Registration office" msgstr "Zulassungsbehörde" -#: intervention/templates/intervention/detail/view.html:76 +#: intervention/templates/intervention/detail/view.html:80 msgid "Registration office file number" msgstr "Aktenzeichen Zulassungsbehörde" -#: intervention/templates/intervention/detail/view.html:80 +#: intervention/templates/intervention/detail/view.html:84 msgid "Conservation office" msgstr "Naturschutzbehörde" -#: intervention/templates/intervention/detail/view.html:84 +#: intervention/templates/intervention/detail/view.html:88 msgid "Conversation office file number" msgstr "Aktenzeichen Naturschutzbehörde" -#: intervention/templates/intervention/detail/view.html:99 +#: intervention/templates/intervention/detail/view.html:103 msgid "Checked on " msgstr "Geprüft am " -#: intervention/templates/intervention/detail/view.html:99 -#: intervention/templates/intervention/detail/view.html:113 +#: intervention/templates/intervention/detail/view.html:103 +#: intervention/templates/intervention/detail/view.html:117 msgid "by" msgstr "von" -#: intervention/templates/intervention/detail/view.html:113 +#: intervention/templates/intervention/detail/view.html:117 msgid "Recorded on " msgstr "Verzeichnet am" -#: intervention/templates/intervention/detail/view.html:120 +#: intervention/templates/intervention/detail/view.html:124 msgid "Registration date" msgstr "Datum Zulassung bzw. Satzungsbeschluss" -#: intervention/templates/intervention/detail/view.html:124 +#: intervention/templates/intervention/detail/view.html:128 msgid "Binding on" msgstr "Datum Bestandskraft" -#: intervention/templates/intervention/detail/view.html:128 +#: intervention/templates/intervention/detail/view.html:132 msgid "Last modified" msgstr "Zuletzt bearbeitet" -#: intervention/templates/intervention/detail/view.html:142 +#: intervention/templates/intervention/detail/view.html:154 msgid "No geometry added, yet." msgstr "Keine Geometrie vorhanden" -#: intervention/views.py:63 +#: intervention/views.py:65 msgid "Intervention {} added" msgstr "Eingriff {} hinzugefügt" -#: intervention/views.py:66 intervention/views.py:173 +#: intervention/views.py:68 intervention/views.py:179 msgid "Invalid input" msgstr "Eingabe fehlerhaft" -#: intervention/views.py:95 +#: intervention/views.py:97 msgid "Document '{}' added" msgstr "Dokument '{}' hinzugefügt" -#: intervention/views.py:147 +#: intervention/views.py:153 msgid "" "Remember: This data has not been shared with you, yet. This means you can " "only read but can not edit or perform any actions like running a check or " @@ -451,10 +452,16 @@ msgstr "" "bedeutet, dass Sie nur lesenden Zugriff hierauf haben und weder bearbeiten, " "noch Prüfungen durchführen oder verzeichnen können." -#: intervention/views.py:170 +#: intervention/views.py:176 msgid "{} edited" msgstr "{} bearbeitet" +#: intervention/views.py:205 +#, fuzzy +#| msgid "Object removed" +msgid "{} removed" +msgstr "Objekt entfernt" + #: intervention/views.py:232 msgid "{} has already been shared with you" msgstr "{} wurde bereits für Sie freigegeben" @@ -467,7 +474,7 @@ msgstr "{} ist nun für Sie freigegeben" msgid "Share link invalid" msgstr "Freigabelink ungültig" -#: intervention/views.py:269 +#: intervention/views.py:268 msgid "Share settings updated" msgstr "Freigabe Einstellungen aktualisiert" @@ -507,20 +514,20 @@ msgstr "Sind Sie sicher?" msgid "Object removed" msgstr "Objekt entfernt" -#: konova/forms.py:253 +#: konova/forms.py:254 msgid "When has this file been created? Important for photos." msgstr "Wann wurde diese Datei erstellt oder das Foto aufgenommen?" -#: konova/forms.py:263 +#: konova/forms.py:264 #: venv/lib/python3.7/site-packages/django/db/models/fields/files.py:231 msgid "File" msgstr "Datei" -#: konova/forms.py:265 +#: konova/forms.py:266 msgid "Must be smaller than 15 Mb" msgstr "Muss kleiner als 15 Mb sein" -#: konova/forms.py:276 +#: konova/forms.py:277 msgid "Additional comment on this file" msgstr "Zusätzlicher Kommentar" @@ -588,7 +595,15 @@ msgstr "Abbuchen" msgid "There was an error on this form." msgstr "Es gab einen Fehler im Formular." -#: konova/views.py:140 +#: konova/views.py:58 +msgid "" +"+++ Attention: You are not part of any group. You won't be able to create, " +"edit or do anything. Please contact an administrator. +++" +msgstr "" +"+++ Achtung: Ihr Account ist keiner Rechtegruppe zugewiesen. Sie können somit nichts eingeben, " +"bearbeiten oder sonstige Aktionen ausführen. Kontaktieren Sie bitte einen Administrator. +++" + +#: konova/views.py:147 msgid "Document '{}' deleted" msgstr "Dokument '{}' gelöscht" diff --git a/user/views.py b/user/views.py index 5260dd4b..a719c5b2 100644 --- a/user/views.py +++ b/user/views.py @@ -6,11 +6,13 @@ from django.shortcuts import render, redirect, get_object_or_404 from django.utils.translation import gettext_lazy as _ from konova.contexts import BaseContext +from konova.decorators import any_group_check from user.forms import UserNotificationForm, UserContactForm from user.models import KonovaUserExtension @login_required +@any_group_check def index_view(request: HttpRequest): """ Renders the user's data index view @@ -29,6 +31,7 @@ def index_view(request: HttpRequest): @login_required +@any_group_check def notifications_view(request: HttpRequest): """ Renders the notifications settings view