Compensation control

* removes CompensationControl model
* adds comment field to CompensationAction
* adds max length of 200 for comment fields in forms
* adds rendering of error messages in case of invalid form input
* adds/updates translations
pull/9/head
mipel 3 years ago
parent 2e3fdaad97
commit fd526b80b7

@ -1,19 +1,9 @@
from django.contrib import admin
from compensation.models import Compensation, CompensationAction, CompensationState, CompensationControl, Payment, \
from compensation.models import Compensation, CompensationAction, CompensationState, Payment, \
EcoAccountWithdraw, EcoAccount
class CompensationControlAdmin(admin.ModelAdmin):
list_display = [
"id",
"type",
"deadline",
"expected_result",
"by_authority",
]
class CompensationStateAdmin(admin.ModelAdmin):
list_display = [
"id",
@ -28,7 +18,7 @@ class CompensationActionAdmin(admin.ModelAdmin):
"action_type",
"amount",
"unit",
"control",
"comment",
]
@ -70,6 +60,5 @@ admin.site.register(Compensation, CompensationAdmin)
admin.site.register(Payment, PaymentAdmin)
admin.site.register(CompensationAction, CompensationActionAdmin)
admin.site.register(CompensationState, CompensationStateAdmin)
admin.site.register(CompensationControl, CompensationControlAdmin)
admin.site.register(EcoAccount, EcoAccountAdmin)
admin.site.register(EcoAccountWithdraw, EcoAccountWithdrawAdmin)

@ -178,9 +178,10 @@ class NewDeadlineModalForm(BaseModalForm):
)
comment = forms.CharField(
required=False,
max_length=200,
label=_("Comment"),
label_suffix=_(""),
help_text=_("Additional comment"),
help_text=_("Additional comment, maximum {} letters").format(200),
widget=forms.Textarea(
attrs={
"cols": 30,
@ -239,9 +240,10 @@ class NewActionModalForm(BaseModalForm):
)
comment = forms.CharField(
required=False,
max_length=200,
label=_("Comment"),
label_suffix=_(""),
help_text=_("Additional comment"),
help_text=_("Additional comment, maximum {} letters").format(200),
widget=forms.Textarea(
attrs={
"cols": 30,
@ -265,6 +267,7 @@ class NewActionModalForm(BaseModalForm):
action_type=self.cleaned_data["action_type"],
amount=self.cleaned_data["amount"],
unit=self.cleaned_data["unit"],
comment=self.cleaned_data["comment"],
created=user_action,
)
self.instance.actions.add(comp_action)

@ -42,17 +42,6 @@ class Payment(BaseResource):
)
class CompensationControl(BaseResource):
"""
Holds data on how a compensation shall be controlled
"""
deadline = models.ForeignKey("konova.Deadline", on_delete=models.SET_NULL, null=True, blank=True)
type = models.CharField(max_length=500, null=True, blank=True)
expected_result = models.CharField(max_length=500, null=True, blank=True, help_text="The expected outcome, that needs to be controlled")
by_authority = models.ForeignKey(Organisation, null=True, blank=True, on_delete=models.SET_NULL)
comment = models.TextField()
class CompensationState(UuidModel):
"""
Compensations must define the state of an area before and after the compensation.
@ -83,7 +72,7 @@ class CompensationAction(BaseResource):
action_type = models.CharField(max_length=500, null=True, blank=True)
amount = models.FloatField()
unit = models.CharField(max_length=100, null=True, blank=True, choices=UnitChoices.choices)
control = models.ForeignKey(CompensationControl, on_delete=models.SET_NULL, null=True, blank=True)
comment = models.TextField(blank=True, null=True, help_text="Additional comment")
def __str__(self):
return "{} | {} {}".format(self.action_type, self.amount, self.unit)

@ -1,4 +1,4 @@
{% load i18n l10n fontawesome_5 %}
{% load i18n l10n fontawesome_5 humanize %}
<div id="related-documents" class="card">
<div class="card-header rlp-r">
<div class="row">
@ -31,7 +31,7 @@
{% trans 'Amount' context 'Compensation' %}
</th>
<th scope="col">
{% trans 'Unit' %}
{% trans 'Comment' %}
</th>
<th scope="col">
{% trans 'Action' %}
@ -44,8 +44,8 @@
<td class="align-middle">
{{ action.action_type }}
</td>
<td class="align-middle">{{ action.amount }}</td>
<td class="align-middle">{{ action.unit_humanize }}</td>
<td class="align-middle">{{ action.amount|floatformat:2|intcomma }} {{ action.unit_humanize }}</td>
<td class="align-middle">{{ action.comment|default_if_none:"" }}</td>
<td>
{% if is_default_member and has_access %}
<button data-form-url="{% url 'compensation:action-remove' action.id %}" class="btn btn-default btn-modal" title="{% trans 'Remove action' %}">

@ -23,7 +23,7 @@
<div class="card-body scroll-300">
{% if sum_before_states > sum_after_states %}
<div class="row alert alert-danger">
{% trans 'Missing surfaces: ' %}{{ diff_states|floatformat:2 }} m²
{% trans 'Missing surfaces according to states before: ' %}{{ diff_states|floatformat:2 }} m²
</div>
{% endif %}
<table class="table table-hover">

@ -23,7 +23,7 @@
<div class="card-body scroll-300">
{% if sum_before_states < sum_after_states %}
<div class="row alert alert-danger">
{% trans 'Missing surfaces: ' %}{{ diff_states|floatformat:2 }} m²
{% trans 'Missing surfaces according to states after: ' %}{{ diff_states|floatformat:2 }} m²
</div>
{% endif %}
<table class="table table-hover">

@ -162,9 +162,16 @@ class BaseModalForm(BaseForm, BSModalForm):
)
return redirect(redirect_url)
else:
messages.info(
messages.error(
request,
msg_error
msg_error,
extra_tags="danger"
)
for field, error in self.errors.items():
messages.error(
request,
"{}: {}".format(self.fields[field].label, _(error[0])),
extra_tags="danger"
)
return redirect(redirect_url)
elif request.method == "GET":
@ -275,9 +282,10 @@ class NewDocumentForm(BaseModalForm):
)
comment = forms.CharField(
required=False,
max_length=200,
label=_("Comment"),
label_suffix=_(""),
help_text=_("Additional comment on this file"),
help_text=_("Additional comment, maximum {} letters").format(200),
widget=forms.Textarea(
attrs={
"cols": 30,

Binary file not shown.

@ -3,18 +3,18 @@
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#: compensation/forms.py:34 compensation/forms.py:39 compensation/forms.py:52
#: compensation/forms.py:182 compensation/forms.py:243
#: compensation/forms.py:35 compensation/forms.py:40 compensation/forms.py:53
#: compensation/forms.py:184 compensation/forms.py:246
#: intervention/filters.py:26 intervention/filters.py:40
#: intervention/filters.py:47 intervention/filters.py:48 konova/forms.py:91
#: konova/forms.py:220 konova/forms.py:251 konova/forms.py:256
#: konova/forms.py:268 konova/forms.py:279 konova/forms.py:292 user/forms.py:38
#: konova/forms.py:227 konova/forms.py:258 konova/forms.py:263
#: konova/forms.py:275 konova/forms.py:287 konova/forms.py:300 user/forms.py:38
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-08-04 10:57+0200\n"
"POT-Creation-Date: 2021-08-04 11:52+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -24,157 +24,157 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
#: compensation/forms.py:33 compensation/forms.py:233
#: compensation/forms.py:34 compensation/forms.py:235
#: intervention/templates/intervention/detail/includes/eco-account-withdraws.html:33
msgid "Amount"
msgstr "Menge"
#: compensation/forms.py:35
#: compensation/forms.py:36
msgid "Amount in Euro"
msgstr "Betrag in Euro"
#: compensation/forms.py:38
#: compensation/forms.py:39
#: intervention/templates/intervention/detail/includes/payments.html:31
msgid "Due on"
msgstr "Fällig am"
#: compensation/forms.py:40
#: compensation/forms.py:41
msgid "Due on which date"
msgstr "Zahlung wird an diesem Datum erwartet"
#: compensation/forms.py:53
#: compensation/forms.py:54
msgid "Transfer note"
msgstr "Verwendungszweck"
#: compensation/forms.py:54
#: compensation/forms.py:55
msgid "Note for money transfer"
msgstr "Verwendungszweck für Überweisung"
#: compensation/forms.py:61
#: compensation/forms.py:62
msgid "Payment"
msgstr "Zahlung"
#: compensation/forms.py:62
#: compensation/forms.py:63
msgid "Add a payment for intervention '{}'"
msgstr "Neue Ersatzzahlung zu Eingriff '{}' hinzufügen"
#: compensation/forms.py:82
#: compensation/forms.py:83
msgid "Biotope Type"
msgstr "Biotoptyp"
#: compensation/forms.py:85
#: compensation/forms.py:86
msgid "Select the biotope type"
msgstr "Biotoptyp wählen"
#: compensation/forms.py:90
#: compensation/forms.py:91
#: compensation/templates/compensation/detail/includes/states-after.html:36
#: compensation/templates/compensation/detail/includes/states-before.html:36
msgid "Surface"
msgstr "Fläche"
#: compensation/forms.py:93
#: compensation/forms.py:94
msgid "in m²"
msgstr ""
#: compensation/forms.py:98
#: compensation/forms.py:99
msgid "New state"
msgstr "Neuer Zustand"
#: compensation/forms.py:99
#: compensation/forms.py:100
msgid "Insert data for the new state"
msgstr "Geben Sie die Daten des neuen Zustandes ein"
#: compensation/forms.py:113 konova/forms.py:141
#: compensation/forms.py:114 konova/forms.py:141
msgid "Object removed"
msgstr "Objekt entfernt"
#: compensation/forms.py:155
#: compensation/forms.py:156
msgid "Deadline Type"
msgstr "Fristart"
#: compensation/forms.py:158
#: compensation/forms.py:159
msgid "Select the deadline type"
msgstr "Fristart wählen"
#: compensation/forms.py:167
#: compensation/forms.py:168
#: compensation/templates/compensation/detail/includes/deadlines.html:31
msgid "Date"
msgstr "Datum"
#: compensation/forms.py:170
#: compensation/forms.py:171
msgid "Select date"
msgstr "Datum wählen"
#: compensation/forms.py:181 compensation/forms.py:242
#: compensation/forms.py:183 compensation/forms.py:245
#: compensation/templates/compensation/detail/includes/actions.html:34
#: 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:278
#: konova/forms.py:286
msgid "Comment"
msgstr "Kommentar"
#: compensation/forms.py:183 compensation/forms.py:244
msgid "Additional comment"
msgstr "Zusätzlicher Kommentar"
#: compensation/forms.py:185 compensation/forms.py:247 konova/forms.py:288
msgid "Additional comment, maximum {} letters"
msgstr "Zusätzlicher Kommentar, maximal {} Zeichen"
#: compensation/forms.py:194
#: compensation/forms.py:196
msgid "New deadline"
msgstr "Neue Frist"
#: compensation/forms.py:195
#: compensation/forms.py:197
msgid "Insert data for the new deadline"
msgstr "Geben Sie die Daten der neuen Frist ein"
#: compensation/forms.py:215
#: compensation/forms.py:217
msgid "Action Type"
msgstr "Maßnahmentyp"
#: compensation/forms.py:218
#: compensation/forms.py:220
msgid "Select the action type"
msgstr "Maßnahmentyp wählen"
#: compensation/forms.py:221
#: compensation/templates/compensation/detail/includes/actions.html:34
#: compensation/forms.py:223
msgid "Unit"
msgstr "Einheit"
#: compensation/forms.py:224
#: compensation/forms.py:226
msgid "Select the unit"
msgstr "Einheit wählen"
#: compensation/forms.py:236
#: compensation/forms.py:238
msgid "Insert the amount"
msgstr "Menge eingeben"
#: compensation/forms.py:255
#: compensation/forms.py:258
msgid "New action"
msgstr "Neue Maßnahme"
#: compensation/forms.py:256
#: compensation/forms.py:259
msgid "Insert data for the new action"
msgstr "Geben Sie die Daten der neuen Maßnahme ein"
#: compensation/models.py:71
#: compensation/models.py:60
msgid "cm"
msgstr ""
#: compensation/models.py:72
#: compensation/models.py:61
msgid "m"
msgstr ""
#: compensation/models.py:73
#: compensation/models.py:62
msgid "km"
msgstr ""
#: compensation/models.py:74
#: compensation/models.py:63
msgid "m²"
msgstr ""
#: compensation/models.py:75
#: compensation/models.py:64
msgid "ha"
msgstr ""
#: compensation/models.py:76
#: compensation/models.py:65
msgid "Pieces"
msgstr "Stück"
@ -190,7 +190,7 @@ msgstr "Kennung"
#: 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:250
#: intervention/templates/intervention/detail/view.html:64 konova/forms.py:257
msgid "Title"
msgstr "Bezeichnung"
@ -259,7 +259,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:255
#: compensation/tables.py:174 konova/forms.py:262
msgid "Created on"
msgstr "Erstellt"
@ -337,7 +337,7 @@ msgstr "Dokumente"
#: compensation/templates/compensation/detail/includes/documents.html:14
#: intervention/templates/intervention/detail/includes/documents.html:14
#: konova/forms.py:291
#: konova/forms.py:299
msgid "Add new document"
msgstr "Neues Dokument hinzufügen"
@ -355,9 +355,8 @@ msgid "Add new state after"
msgstr "Neuen Zielzustand hinzufügen"
#: 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: "
msgid "Missing surfaces according to states before: "
msgstr "Fehlende Flächenmengen aus Ausgangszustand: "
#: compensation/templates/compensation/detail/includes/states-after.html:33
#: compensation/templates/compensation/detail/includes/states-before.html:33
@ -377,6 +376,10 @@ msgstr "Ausgangszustand"
msgid "Add new state before"
msgstr "Neuen Ausgangszustand hinzufügen"
#: compensation/templates/compensation/detail/includes/states-before.html:26
msgid "Missing surfaces according to states after: "
msgstr "Fehlende Flächenmengen aus Zielzustand: "
#: compensation/templates/compensation/detail/view.html:17
#: intervention/templates/intervention/detail/view.html:17
msgid "Open in LANIS"
@ -736,11 +739,11 @@ msgstr "Hierfür müssen Sie einer anderen Nutzergruppe angehören!"
msgid "Not editable"
msgstr "Nicht editierbar"
#: konova/forms.py:90 konova/forms.py:219
#: konova/forms.py:90 konova/forms.py:226
msgid "Confirm"
msgstr "Bestätige"
#: konova/forms.py:102 konova/forms.py:228
#: konova/forms.py:102 konova/forms.py:235
msgid "Remove"
msgstr "Löschen"
@ -748,27 +751,23 @@ msgstr "Löschen"
msgid "You are about to remove {} {}"
msgstr "Sie sind dabei {} {} zu löschen"
#: konova/forms.py:229
#: konova/forms.py:236
msgid "Are you sure?"
msgstr "Sind Sie sicher?"
#: konova/forms.py:257
#: konova/forms.py:264
msgid "When has this file been created? Important for photos."
msgstr "Wann wurde diese Datei erstellt oder das Foto aufgenommen?"
#: konova/forms.py:267
#: konova/forms.py:274
#: venv/lib/python3.7/site-packages/django/db/models/fields/files.py:231
msgid "File"
msgstr "Datei"
#: konova/forms.py:269
#: konova/forms.py:276
msgid "Must be smaller than 15 Mb"
msgstr "Muss kleiner als 15 Mb sein"
#: konova/forms.py:280
msgid "Additional comment on this file"
msgstr "Zusätzlicher Kommentar"
#: konova/management/commands/setup_data.py:42
msgid "On new related data"
msgstr "Wenn neue Daten für mich angelegt werden"
@ -2253,6 +2252,12 @@ msgstr ""
msgid "A fontawesome icon field"
msgstr ""
#~ msgid "Additional comment"
#~ msgstr "Zusätzlicher Kommentar"
#~ msgid "Missing surfaces: "
#~ msgstr "Fehlende Flächen: "
#~ msgid "Show all"
#~ msgstr "Alle anzeigen"

Loading…
Cancel
Save