#26 Annual conservation report
* adds LegalData to EcoAccount to provide registration_date support ("agreement date") for old-data report generating
* adds/updates translations
This commit is contained in:
@@ -16,7 +16,7 @@ from codelist.models import KonovaCode
|
||||
from codelist.settings import CODELIST_COMPENSATION_FUNDING_ID, CODELIST_CONSERVATION_OFFICE_ID
|
||||
from compensation.models import Compensation, EcoAccount
|
||||
from intervention.inputs import GenerateInput
|
||||
from intervention.models import Intervention, ResponsibilityData
|
||||
from intervention.models import Intervention, ResponsibilityData, LegalData
|
||||
from konova.forms import BaseForm, SimpleGeomForm
|
||||
from user.models import UserActionLogEntry, UserAction
|
||||
|
||||
@@ -298,11 +298,25 @@ class NewEcoAccountForm(AbstractCompensationForm, CompensationResponsibleFormMix
|
||||
}
|
||||
)
|
||||
)
|
||||
registration_date = forms.DateField(
|
||||
label=_("Agreement date"),
|
||||
label_suffix="",
|
||||
help_text=_("When did the parties agree on this?"),
|
||||
required=False,
|
||||
widget=forms.DateInput(
|
||||
attrs={
|
||||
"type": "date",
|
||||
"class": "form-control",
|
||||
},
|
||||
format="%d.%m.%Y"
|
||||
)
|
||||
)
|
||||
|
||||
field_order = [
|
||||
"identifier",
|
||||
"title",
|
||||
"conservation_office",
|
||||
"registration_date",
|
||||
"surface",
|
||||
"conservation_file_number",
|
||||
"handler",
|
||||
@@ -329,6 +343,7 @@ class NewEcoAccountForm(AbstractCompensationForm, CompensationResponsibleFormMix
|
||||
identifier = self.cleaned_data.get("identifier", None)
|
||||
title = self.cleaned_data.get("title", None)
|
||||
fundings = self.cleaned_data.get("fundings", None)
|
||||
registration_date = self.cleaned_data.get("registration_date", None)
|
||||
handler = self.cleaned_data.get("handler", None)
|
||||
surface = self.cleaned_data.get("surface", None)
|
||||
conservation_office = self.cleaned_data.get("conservation_office", None)
|
||||
@@ -349,6 +364,10 @@ class NewEcoAccountForm(AbstractCompensationForm, CompensationResponsibleFormMix
|
||||
conservation_office=conservation_office,
|
||||
)
|
||||
|
||||
legal = LegalData.objects.create(
|
||||
registration_date=registration_date
|
||||
)
|
||||
|
||||
# Finally create main object
|
||||
acc = EcoAccount.objects.create(
|
||||
identifier=identifier,
|
||||
@@ -358,6 +377,7 @@ class NewEcoAccountForm(AbstractCompensationForm, CompensationResponsibleFormMix
|
||||
created=action,
|
||||
geometry=geometry,
|
||||
comment=comment,
|
||||
legal=legal
|
||||
)
|
||||
acc.fundings.set(fundings)
|
||||
acc.users.add(user)
|
||||
@@ -380,11 +400,15 @@ class EditEcoAccountForm(NewEcoAccountForm):
|
||||
self.cancel_redirect = reverse("compensation:acc-detail", args=(self.instance.id,))
|
||||
|
||||
# Initialize form data
|
||||
reg_date = self.instance.legal.registration_date
|
||||
if reg_date is not None:
|
||||
reg_date = reg_date.isoformat()
|
||||
form_data = {
|
||||
"identifier": self.instance.identifier,
|
||||
"title": self.instance.title,
|
||||
"surface": self.instance.deductable_surface,
|
||||
"handler": self.instance.responsible.handler,
|
||||
"registration_date": reg_date,
|
||||
"conservation_office": self.instance.responsible.conservation_office,
|
||||
"conservation_file_number": self.instance.responsible.conservation_file_number,
|
||||
"fundings": self.instance.fundings.all(),
|
||||
@@ -402,6 +426,7 @@ class EditEcoAccountForm(NewEcoAccountForm):
|
||||
identifier = self.cleaned_data.get("identifier", None)
|
||||
title = self.cleaned_data.get("title", None)
|
||||
fundings = self.cleaned_data.get("fundings", None)
|
||||
registration_date = self.cleaned_data.get("registration_date", None)
|
||||
handler = self.cleaned_data.get("handler", None)
|
||||
surface = self.cleaned_data.get("surface", None)
|
||||
conservation_office = self.cleaned_data.get("conservation_office", None)
|
||||
@@ -422,6 +447,10 @@ class EditEcoAccountForm(NewEcoAccountForm):
|
||||
self.instance.responsible.conservation_file_number = conservation_file_number
|
||||
self.instance.responsible.save()
|
||||
|
||||
# Update legal data
|
||||
self.instance.legal.registration_date = registration_date
|
||||
self.instance.legal.save()
|
||||
|
||||
# Update main oject data
|
||||
self.instance.identifier = identifier
|
||||
self.instance.title = title
|
||||
|
||||
Reference in New Issue
Block a user