#38 User requests
* implements 5) "Add 'Maßnahmentyp' for KOMs "
* prepares model and form fields as mixins for easy extension to eco accounts and emas (possibly in the future?)
This commit is contained in:
@@ -115,7 +115,33 @@ class CompensationResponsibleFormMixin(forms.Form):
|
||||
)
|
||||
|
||||
|
||||
class NewCompensationForm(AbstractCompensationForm):
|
||||
class CEFCompensationFormMixin(forms.Form):
|
||||
""" A form mixin, providing CEF compensation field
|
||||
|
||||
"""
|
||||
is_cef = forms.BooleanField(
|
||||
label_suffix="",
|
||||
label=_("Is CEF"),
|
||||
help_text=_("Optionally: Whether this compensation is a CEF compensation?"),
|
||||
required=False,
|
||||
widget=forms.CheckboxInput()
|
||||
)
|
||||
|
||||
|
||||
class CoherenceCompensationFormMixin(forms.Form):
|
||||
""" A form mixin, providing coherence compensation field
|
||||
|
||||
"""
|
||||
is_coherence_keeping = forms.BooleanField(
|
||||
label_suffix="",
|
||||
label=_("Is coherence keeping"),
|
||||
help_text=_("Optionally: Whether this compensation is a coherence keeping compensation?"),
|
||||
required=False,
|
||||
widget=forms.CheckboxInput()
|
||||
)
|
||||
|
||||
|
||||
class NewCompensationForm(AbstractCompensationForm, CEFCompensationFormMixin, CoherenceCompensationFormMixin):
|
||||
""" Form for creating new compensations.
|
||||
|
||||
Can be initialized with an intervention id for preselecting the related intervention.
|
||||
@@ -146,6 +172,8 @@ class NewCompensationForm(AbstractCompensationForm):
|
||||
"identifier",
|
||||
"title",
|
||||
"intervention",
|
||||
"is_cef",
|
||||
"is_coherence_keeping",
|
||||
"comment",
|
||||
]
|
||||
|
||||
@@ -177,6 +205,8 @@ class NewCompensationForm(AbstractCompensationForm):
|
||||
identifier = self.cleaned_data.get("identifier", None)
|
||||
title = self.cleaned_data.get("title", None)
|
||||
intervention = self.cleaned_data.get("intervention", None)
|
||||
is_cef = self.cleaned_data.get("is_cef", None)
|
||||
is_coherence_keeping = self.cleaned_data.get("is_coherence_keeping", None)
|
||||
comment = self.cleaned_data.get("comment", None)
|
||||
|
||||
# Create log entry
|
||||
@@ -193,6 +223,8 @@ class NewCompensationForm(AbstractCompensationForm):
|
||||
title=title,
|
||||
intervention=intervention,
|
||||
created=action,
|
||||
is_cef=is_cef,
|
||||
is_coherence_keeping=is_coherence_keeping,
|
||||
geometry=geometry,
|
||||
comment=comment,
|
||||
)
|
||||
@@ -217,6 +249,8 @@ class EditCompensationForm(NewCompensationForm):
|
||||
"identifier": self.instance.identifier,
|
||||
"title": self.instance.title,
|
||||
"intervention": self.instance.intervention,
|
||||
"is_cef": self.instance.is_cef,
|
||||
"is_coherence_keeping": self.instance.is_coherence_keeping,
|
||||
"comment": self.instance.comment,
|
||||
}
|
||||
disabled_fields = []
|
||||
@@ -231,6 +265,8 @@ class EditCompensationForm(NewCompensationForm):
|
||||
identifier = self.cleaned_data.get("identifier", None)
|
||||
title = self.cleaned_data.get("title", None)
|
||||
intervention = self.cleaned_data.get("intervention", None)
|
||||
is_cef = self.cleaned_data.get("is_cef", None)
|
||||
is_coherence_keeping = self.cleaned_data.get("is_coherence_keeping", None)
|
||||
comment = self.cleaned_data.get("comment", None)
|
||||
|
||||
# Create log entry
|
||||
@@ -247,6 +283,8 @@ class EditCompensationForm(NewCompensationForm):
|
||||
self.instance.title = title
|
||||
self.instance.intervention = intervention
|
||||
self.instance.geometry = geometry
|
||||
self.instance.is_cef = is_cef
|
||||
self.instance.is_coherence_keeping = is_coherence_keeping
|
||||
self.instance.comment = comment
|
||||
self.instance.modified = action
|
||||
self.instance.save()
|
||||
|
||||
@@ -189,7 +189,37 @@ class AbstractCompensation(BaseObject):
|
||||
return checker
|
||||
|
||||
|
||||
class Compensation(AbstractCompensation):
|
||||
class CEFMixin(models.Model):
|
||||
""" Provides CEF flag as Mixin
|
||||
|
||||
"""
|
||||
is_cef = models.BooleanField(
|
||||
blank=True,
|
||||
null=True,
|
||||
default=False,
|
||||
help_text="Flag if compensation is a 'CEF-Maßnahme'"
|
||||
)
|
||||
|
||||
class Meta:
|
||||
abstract = True
|
||||
|
||||
|
||||
class CoherenceMixin(models.Model):
|
||||
""" Provides coherence keeping flag as Mixin
|
||||
|
||||
"""
|
||||
is_coherence_keeping = models.BooleanField(
|
||||
blank=True,
|
||||
null=True,
|
||||
default=False,
|
||||
help_text="Flag if compensation is a 'Kohärenzsicherung'"
|
||||
)
|
||||
|
||||
class Meta:
|
||||
abstract = True
|
||||
|
||||
|
||||
class Compensation(AbstractCompensation, CEFMixin, CoherenceMixin):
|
||||
"""
|
||||
Regular compensation, linked to an intervention
|
||||
"""
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{% extends 'base.html' %}
|
||||
{% load i18n l10n static fontawesome_5 humanize %}
|
||||
{% load i18n l10n static fontawesome_5 humanize ksp_filters %}
|
||||
|
||||
{% block head %}
|
||||
{% comment %}
|
||||
@@ -38,6 +38,26 @@
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">{% trans 'Is CEF compensation' %}</th>
|
||||
<td class="align-middle">
|
||||
{% if obj.is_cef %}
|
||||
{% trans 'Yes' %}
|
||||
{% else %}
|
||||
{% trans 'No' %}
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">{% trans 'Is Coherence keeping compensation' %}</th>
|
||||
<td class="align-middle">
|
||||
{% if obj.is_coherence_keeping %}
|
||||
{% trans 'Yes' %}
|
||||
{% else %}
|
||||
{% trans 'No' %}
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">{% trans 'Checked' %}</th>
|
||||
<td class="align-middle">
|
||||
|
||||
Reference in New Issue
Block a user