# 70 Tab title compensation

* adds tab titles for compensations
* adds/updates translations
* optimizes identifier generating, so that one-digit months will be converted into two digits
This commit is contained in:
mpeltriaux 2022-01-20 12:19:08 +01:00
parent 77e9c989aa
commit fb911c7429
4 changed files with 42 additions and 22 deletions

View File

@ -13,6 +13,7 @@ from intervention.models import Intervention
from konova.contexts import BaseContext
from konova.decorators import *
from konova.forms import RemoveModalForm, SimpleGeomForm
from konova.sub_settings.context_settings import TAB_TITLE_IDENTIFIER
from konova.utils.documents import get_document, remove_document
from konova.utils.generators import generate_qr_code
from konova.utils.message_templates import FORM_INVALID, IDENTIFIER_REPLACED, DATA_UNSHARED_EXPLANATION, \
@ -43,6 +44,7 @@ def index_view(request: HttpRequest):
)
context = {
"table": table,
TAB_TITLE_IDENTIFIER: _("Compensations - Overview"),
}
context = BaseContext(request, context).context
return render(request, template, context)
@ -86,6 +88,7 @@ def new_view(request: HttpRequest, intervention_id: str = None):
context = {
"form": data_form,
"geom_form": geom_form,
TAB_TITLE_IDENTIFIER: _("New compensation"),
}
context = BaseContext(request, context).context
return render(request, template, context)
@ -150,6 +153,7 @@ def edit_view(request: HttpRequest, id: str):
context = {
"form": data_form,
"geom_form": geom_form,
TAB_TITLE_IDENTIFIER: _("Edit {}").format(comp.identifier),
}
context = BaseContext(request, context).context
return render(request, template, context)
@ -202,6 +206,7 @@ def detail_view(request: HttpRequest, id: str):
"is_zb_member": in_group(_user, ZB_GROUP),
"is_ets_member": in_group(_user, ETS_GROUP),
"LANIS_LINK": comp.get_LANIS_link(),
TAB_TITLE_IDENTIFIER: f"{comp.identifier} - {comp.title}",
}
context = BaseContext(request, context).context
return render(request, template, context)
@ -444,10 +449,15 @@ def report_view(request: HttpRequest, id: str):
template = "compensation/report/compensation/report.html"
comp = get_object_or_404(Compensation, id=id)
tab_title = _("Report {}").format(comp.identifier)
# If intervention is not recorded (yet or currently) we need to render another template without any data
if not comp.intervention.recorded:
template = "report/unavailable.html"
return render(request, template, {})
context = {
TAB_TITLE_IDENTIFIER: tab_title,
}
context = BaseContext(request, context).context
return render(request, template, context)
# Prepare data for map viewer
geom_form = SimpleGeomForm(
@ -477,6 +487,7 @@ def report_view(request: HttpRequest, id: str):
"geom_form": geom_form,
"parcels": parcels,
"actions": actions,
TAB_TITLE_IDENTIFIER: tab_title,
}
context = BaseContext(request, context).context
return render(request, template, context)

View File

@ -182,7 +182,12 @@ class BaseObject(BaseResource):
return generate_random_string(10)
_now = now()
curr_month = str(_now.month)
curr_month = _now.month
if curr_month < 10:
# Make sure month part has two digits to have same length identifiers by default
curr_month = f"0{curr_month}"
else:
curr_month = str(curr_month)
curr_year = str(_now.year)
rand_str = generate_random_string(
length=definitions[self.__class__]["length"],

Binary file not shown.

View File

@ -26,7 +26,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-01-20 12:07+0100\n"
"POT-Creation-Date: 2022-01-20 12:17+0100\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"
@ -426,7 +426,7 @@ msgstr "kompensiert Eingriff"
msgid "Select the intervention for which this compensation compensates"
msgstr "Wählen Sie den Eingriff, für den diese Kompensation bestimmt ist"
#: compensation/forms/forms.py:184
#: compensation/forms/forms.py:184 compensation/views/compensation.py:91
msgid "New compensation"
msgstr "Neue Kompensation"
@ -1055,53 +1055,65 @@ msgstr ""
msgid "Responsible data"
msgstr "Daten zu den verantwortlichen Stellen"
#: compensation/views/compensation.py:79
#: compensation/views/compensation.py:47
msgid "Compensations - Overview"
msgstr "Kompensationen - Übersicht"
#: compensation/views/compensation.py:81
msgid "Compensation {} added"
msgstr "Kompensation {} hinzugefügt"
#: compensation/views/compensation.py:143
#: compensation/views/compensation.py:146
msgid "Compensation {} edited"
msgstr "Kompensation {} bearbeitet"
#: compensation/views/compensation.py:230 compensation/views/eco_account.py:309
#: compensation/views/compensation.py:156 intervention/views.py:309
msgid "Edit {}"
msgstr "Bearbeite {}"
#: compensation/views/compensation.py:235 compensation/views/eco_account.py:309
#: ema/views.py:183 intervention/views.py:482
msgid "Log"
msgstr "Log"
#: compensation/views/compensation.py:253
#: compensation/views/compensation.py:258
msgid "Compensation removed"
msgstr "Kompensation entfernt"
#: compensation/views/compensation.py:274 compensation/views/eco_account.py:461
#: compensation/views/compensation.py:279 compensation/views/eco_account.py:461
#: ema/views.py:350 intervention/views.py:132
msgid "Document added"
msgstr "Dokument hinzugefügt"
#: compensation/views/compensation.py:343 compensation/views/eco_account.py:355
#: compensation/views/compensation.py:348 compensation/views/eco_account.py:355
#: ema/views.py:288
msgid "State added"
msgstr "Zustand hinzugefügt"
#: compensation/views/compensation.py:364 compensation/views/eco_account.py:376
#: compensation/views/compensation.py:369 compensation/views/eco_account.py:376
#: ema/views.py:309
msgid "Action added"
msgstr "Maßnahme hinzugefügt"
#: compensation/views/compensation.py:385 compensation/views/eco_account.py:441
#: compensation/views/compensation.py:390 compensation/views/eco_account.py:441
#: ema/views.py:330
msgid "Deadline added"
msgstr "Frist/Termin hinzugefügt"
#: compensation/views/compensation.py:407 compensation/views/eco_account.py:398
#: compensation/views/compensation.py:412 compensation/views/eco_account.py:398
#: ema/views.py:420
msgid "State removed"
msgstr "Zustand gelöscht"
#: compensation/views/compensation.py:429 compensation/views/eco_account.py:420
#: compensation/views/compensation.py:434 compensation/views/eco_account.py:420
#: ema/views.py:442
msgid "Action removed"
msgstr "Maßnahme entfernt"
#: compensation/views/compensation.py:452 intervention/views.py:546
msgid "Report {}"
msgstr "Bericht {}"
#: compensation/views/eco_account.py:89
msgid "Eco-Account {} added"
msgstr "Ökokonto {} hinzugefügt"
@ -1475,10 +1487,6 @@ msgstr "Dem Eingriff liegen {} Widersprüche vor"
msgid "Intervention {} edited"
msgstr "Eingriff {} bearbeitet"
#: intervention/views.py:309
msgid "Edit {}"
msgstr "Bearbeite {}"
#: intervention/views.py:333
msgid "{} removed"
msgstr "{} entfernt"
@ -1499,10 +1507,6 @@ msgstr "Widerspruch hinzugefügt"
msgid "There are errors on this intervention:"
msgstr "Es liegen Fehler in diesem Eingriff vor:"
#: intervention/views.py:546
msgid "Report {}"
msgstr "Bericht {}"
#: konova/decorators.py:30
msgid "You need to be staff to perform this action!"
msgstr "Hierfür müssen Sie Mitarbeiter sein!"