|
|
|
@ -13,7 +13,7 @@ from django.utils.translation import gettext_lazy as _
|
|
|
|
|
from django import forms
|
|
|
|
|
|
|
|
|
|
from codelist.models import KonovaCode
|
|
|
|
|
from codelist.settings import CODELIST_COMPENSATION_FUNDING_ID, CODELIST_CONSERVATION_OFFICE_ID
|
|
|
|
|
from codelist.settings import CODELIST_CONSERVATION_OFFICE_ID
|
|
|
|
|
from compensation.models import Compensation, EcoAccount
|
|
|
|
|
from intervention.inputs import GenerateInput
|
|
|
|
|
from intervention.models import Intervention, ResponsibilityData, LegalData
|
|
|
|
@ -51,23 +51,6 @@ class AbstractCompensationForm(BaseForm):
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
fundings = forms.ModelMultipleChoiceField(
|
|
|
|
|
label=_("Fundings"),
|
|
|
|
|
label_suffix="",
|
|
|
|
|
required=False,
|
|
|
|
|
help_text=_("Select fundings for this compensation"),
|
|
|
|
|
queryset=KonovaCode.objects.filter(
|
|
|
|
|
is_archived=False,
|
|
|
|
|
is_leaf=True,
|
|
|
|
|
code_lists__in=[CODELIST_COMPENSATION_FUNDING_ID],
|
|
|
|
|
),
|
|
|
|
|
widget=autocomplete.ModelSelect2Multiple(
|
|
|
|
|
url="codes-compensation-funding-autocomplete",
|
|
|
|
|
attrs={
|
|
|
|
|
"data-placeholder": _("Click for selection"),
|
|
|
|
|
}
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
comment = forms.CharField(
|
|
|
|
|
label_suffix="",
|
|
|
|
|
label=_("Comment"),
|
|
|
|
@ -163,7 +146,6 @@ class NewCompensationForm(AbstractCompensationForm):
|
|
|
|
|
"identifier",
|
|
|
|
|
"title",
|
|
|
|
|
"intervention",
|
|
|
|
|
"fundings",
|
|
|
|
|
"comment",
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
@ -194,7 +176,6 @@ class NewCompensationForm(AbstractCompensationForm):
|
|
|
|
|
# Fetch data from cleaned POST values
|
|
|
|
|
identifier = self.cleaned_data.get("identifier", None)
|
|
|
|
|
title = self.cleaned_data.get("title", None)
|
|
|
|
|
fundings = self.cleaned_data.get("fundings", None)
|
|
|
|
|
intervention = self.cleaned_data.get("intervention", None)
|
|
|
|
|
comment = self.cleaned_data.get("comment", None)
|
|
|
|
|
|
|
|
|
@ -215,7 +196,6 @@ class NewCompensationForm(AbstractCompensationForm):
|
|
|
|
|
geometry=geometry,
|
|
|
|
|
comment=comment,
|
|
|
|
|
)
|
|
|
|
|
comp.fundings.set(fundings)
|
|
|
|
|
|
|
|
|
|
# Add the log entry to the main objects log list
|
|
|
|
|
comp.log.add(action)
|
|
|
|
@ -237,7 +217,6 @@ class EditCompensationForm(NewCompensationForm):
|
|
|
|
|
"identifier": self.instance.identifier,
|
|
|
|
|
"title": self.instance.title,
|
|
|
|
|
"intervention": self.instance.intervention,
|
|
|
|
|
"fundings": self.instance.fundings.all(),
|
|
|
|
|
"comment": self.instance.comment,
|
|
|
|
|
}
|
|
|
|
|
disabled_fields = []
|
|
|
|
@ -251,7 +230,6 @@ class EditCompensationForm(NewCompensationForm):
|
|
|
|
|
# Fetch data from cleaned POST values
|
|
|
|
|
identifier = self.cleaned_data.get("identifier", None)
|
|
|
|
|
title = self.cleaned_data.get("title", None)
|
|
|
|
|
fundings = self.cleaned_data.get("fundings", None)
|
|
|
|
|
intervention = self.cleaned_data.get("intervention", None)
|
|
|
|
|
comment = self.cleaned_data.get("comment", None)
|
|
|
|
|
|
|
|
|
@ -271,7 +249,6 @@ class EditCompensationForm(NewCompensationForm):
|
|
|
|
|
self.instance.geometry = geometry
|
|
|
|
|
self.instance.comment = comment
|
|
|
|
|
self.instance.modified = action
|
|
|
|
|
self.instance.fundings.set(fundings)
|
|
|
|
|
self.instance.save()
|
|
|
|
|
|
|
|
|
|
self.instance.log.add(action)
|
|
|
|
@ -320,7 +297,6 @@ class NewEcoAccountForm(AbstractCompensationForm, CompensationResponsibleFormMix
|
|
|
|
|
"surface",
|
|
|
|
|
"conservation_file_number",
|
|
|
|
|
"handler",
|
|
|
|
|
"fundings",
|
|
|
|
|
"comment",
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
@ -342,7 +318,6 @@ class NewEcoAccountForm(AbstractCompensationForm, CompensationResponsibleFormMix
|
|
|
|
|
# Fetch data from cleaned POST values
|
|
|
|
|
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)
|
|
|
|
@ -379,7 +354,6 @@ class NewEcoAccountForm(AbstractCompensationForm, CompensationResponsibleFormMix
|
|
|
|
|
comment=comment,
|
|
|
|
|
legal=legal
|
|
|
|
|
)
|
|
|
|
|
acc.fundings.set(fundings)
|
|
|
|
|
acc.share_with(user)
|
|
|
|
|
|
|
|
|
|
# Add the log entry to the main objects log list
|
|
|
|
@ -411,7 +385,6 @@ class EditEcoAccountForm(NewEcoAccountForm):
|
|
|
|
|
"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(),
|
|
|
|
|
"comment": self.instance.comment,
|
|
|
|
|
}
|
|
|
|
|
disabled_fields = []
|
|
|
|
@ -425,7 +398,6 @@ class EditEcoAccountForm(NewEcoAccountForm):
|
|
|
|
|
# Fetch data from cleaned POST values
|
|
|
|
|
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)
|
|
|
|
@ -459,7 +431,6 @@ class EditEcoAccountForm(NewEcoAccountForm):
|
|
|
|
|
self.instance.comment = comment
|
|
|
|
|
self.instance.modified = action
|
|
|
|
|
self.instance.save()
|
|
|
|
|
self.instance.fundings.set(fundings)
|
|
|
|
|
|
|
|
|
|
# Add the log entry to the main objects log list
|
|
|
|
|
self.instance.log.add(action)
|
|
|
|
|