EcoAccount fixes

* adds deductable surface field into NewEcoAccountForm directly
* removes custom manager for LegalData and ResponsibilityData
pull/33/head
mpeltriaux 3 years ago
parent b90a07ca2a
commit 9e7e5ee726

@ -284,10 +284,26 @@ class NewEcoAccountForm(AbstractCompensationForm, CompensationResponsibleFormMix
Inherits from basic AbstractCompensationForm and further form fields from CompensationResponsibleFormMixin
"""
surface = forms.DecimalField(
min_value=0.00,
decimal_places=2,
label=_("Available Surface"),
label_suffix="",
required=False,
help_text=_("The amount that can be used for deductions"),
widget=forms.NumberInput(
attrs={
"class": "form-control",
"placeholder": "0,00"
}
)
)
field_order = [
"identifier",
"title",
"conservation_office",
"surface",
"conservation_file_number",
"handler",
"fundings",
@ -314,6 +330,7 @@ class NewEcoAccountForm(AbstractCompensationForm, CompensationResponsibleFormMix
title = self.cleaned_data.get("title", None)
fundings = self.cleaned_data.get("fundings", None)
handler = self.cleaned_data.get("handler", None)
surface = self.cleaned_data.get("surface", None)
conservation_office = self.cleaned_data.get("conservation_office", None)
conservation_file_number = self.cleaned_data.get("conservation_file_number", None)
comment = self.cleaned_data.get("comment", None)
@ -337,7 +354,7 @@ class NewEcoAccountForm(AbstractCompensationForm, CompensationResponsibleFormMix
identifier=identifier,
title=title,
responsible=responsible,
deductable_surface=0.00,
deductable_surface=surface,
created=action,
geometry=geometry,
comment=comment,
@ -354,30 +371,6 @@ class EditEcoAccountForm(NewEcoAccountForm):
""" Form for editing eco accounts
"""
surface = forms.DecimalField(
min_value=0.00,
decimal_places=2,
label=_("Available Surface"),
label_suffix="",
required=False,
help_text=_("The amount that can be used for deductions"),
widget=forms.NumberInput(
attrs={
"class": "form-control",
"placeholder": "0,00"
}
)
)
field_order = [
"identifier",
"title",
"conservation_office",
"surface",
"conservation_file_number",
"handler",
"fundings",
"comment",
]
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)

@ -23,26 +23,3 @@ class InterventionManager(models.Manager):
).prefetch_related(
"users",
)
class LegalDataManager(models.Manager):
""" Holds default db fetch setting for this model type
"""
def get_queryset(self):
return super().get_querset().select_related(
"process_type",
).prefetch_related(
"laws"
)
class ResponsibilityDataManager(models.Manager):
""" Holds default db fetch setting for this model type
"""
def get_queryset(self):
return super().get_querset().select_related(
"registration_office",
"conservation_office",
)

@ -15,7 +15,7 @@ from django.utils.translation import gettext_lazy as _
from codelist.models import KonovaCode
from codelist.settings import CODELIST_REGISTRATION_OFFICE_ID, CODELIST_CONSERVATION_OFFICE_ID, CODELIST_LAW_ID, \
CODELIST_PROCESS_TYPE_ID
from intervention.managers import InterventionManager, LegalDataManager, ResponsibilityDataManager
from intervention.managers import InterventionManager
from konova.models import BaseObject, Geometry, UuidModel, BaseResource, AbstractDocument, \
generate_document_file_upload_path
from konova.settings import DEFAULT_SRID_RLP, LANIS_LINK_TEMPLATE, LANIS_ZOOM_LUT
@ -56,7 +56,6 @@ class ResponsibilityData(UuidModel):
conservation_file_number = models.CharField(max_length=1000, blank=True, null=True)
handler = models.CharField(max_length=500, null=True, blank=True, help_text="Refers to 'Eingriffsverursacher' or 'Maßnahmenträger'")
objects = ResponsibilityDataManager()
def __str__(self):
return "ZB: {} | ETS: {} | Handler: {}".format(
@ -172,8 +171,6 @@ class LegalData(UuidModel):
revocation = models.OneToOneField(Revocation, null=True, blank=True, help_text="Refers to 'Widerspruch am'", on_delete=models.SET_NULL)
objects = LegalDataManager()
class Intervention(BaseObject):
"""

Loading…
Cancel
Save