27
ema/forms.py
27
ema/forms.py
@@ -12,8 +12,6 @@ from django.db import transaction
|
||||
from django.urls import reverse, reverse_lazy
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from codelist.models import KonovaCode
|
||||
from codelist.settings import CODELIST_COMPENSATION_FUNDING_ID
|
||||
from compensation.forms.forms import AbstractCompensationForm, CompensationResponsibleFormMixin
|
||||
from ema.models import Ema
|
||||
from intervention.models import ResponsibilityData
|
||||
@@ -28,32 +26,12 @@ class NewEmaForm(AbstractCompensationForm, CompensationResponsibleFormMixin):
|
||||
Second holds self.instance.response related fields
|
||||
|
||||
"""
|
||||
|
||||
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"),
|
||||
}
|
||||
),
|
||||
)
|
||||
|
||||
field_order = [
|
||||
"identifier",
|
||||
"title",
|
||||
"conservation_office",
|
||||
"conservation_file_number",
|
||||
"handler",
|
||||
"fundings",
|
||||
"comment",
|
||||
]
|
||||
|
||||
@@ -75,7 +53,6 @@ class NewEmaForm(AbstractCompensationForm, CompensationResponsibleFormMixin):
|
||||
# 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)
|
||||
handler = self.cleaned_data.get("handler", None)
|
||||
conservation_office = self.cleaned_data.get("conservation_office", None)
|
||||
conservation_file_number = self.cleaned_data.get("conservation_file_number", None)
|
||||
@@ -104,7 +81,6 @@ class NewEmaForm(AbstractCompensationForm, CompensationResponsibleFormMixin):
|
||||
geometry=geometry,
|
||||
comment=comment,
|
||||
)
|
||||
acc.fundings.set(fundings)
|
||||
|
||||
# Add the creating user to the list of shared users
|
||||
acc.share_with(user)
|
||||
@@ -135,7 +111,6 @@ class EditEmaForm(NewEmaForm):
|
||||
"handler": self.instance.responsible.handler,
|
||||
"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 = []
|
||||
@@ -149,7 +124,6 @@ class EditEmaForm(NewEmaForm):
|
||||
# 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)
|
||||
handler = self.cleaned_data.get("handler", None)
|
||||
conservation_office = self.cleaned_data.get("conservation_office", None)
|
||||
conservation_file_number = self.cleaned_data.get("conservation_file_number", None)
|
||||
@@ -176,7 +150,6 @@ class EditEmaForm(NewEmaForm):
|
||||
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)
|
||||
|
||||
@@ -3,8 +3,6 @@ import shutil
|
||||
from django.db import models
|
||||
from django.db.models import QuerySet
|
||||
|
||||
from codelist.models import KonovaCode
|
||||
from codelist.settings import CODELIST_COMPENSATION_FUNDING_ID
|
||||
from compensation.models import AbstractCompensation
|
||||
from ema.managers import EmaManager
|
||||
from ema.utils.quality import EmaQualityChecker
|
||||
@@ -28,16 +26,6 @@ class Ema(AbstractCompensation, ShareableObject, RecordableObject):
|
||||
EMA therefore holds data like a compensation: actions, before-/after-states, deadlines, ...
|
||||
|
||||
"""
|
||||
fundings = models.ManyToManyField(
|
||||
KonovaCode,
|
||||
blank=True,
|
||||
limit_choices_to={
|
||||
"code_lists__in": [CODELIST_COMPENSATION_FUNDING_ID],
|
||||
"is_selectable": True,
|
||||
"is_archived": False,
|
||||
},
|
||||
help_text="List of funding project codes",
|
||||
)
|
||||
objects = EmaManager()
|
||||
|
||||
def __str__(self):
|
||||
|
||||
@@ -50,19 +50,6 @@
|
||||
<th scope="row">{% trans 'Action handler' %}</th>
|
||||
<td class="align-middle">{{obj.responsible.handler|default_if_none:""}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">{% trans 'Funded by' %}</th>
|
||||
<td class="align-middle">
|
||||
{% for funding in obj.fundings.all %}
|
||||
<div class="badge badge-pill rlp-r-outline">
|
||||
{{ funding.short_name}}
|
||||
</div>
|
||||
<br>
|
||||
{% empty %}
|
||||
{% trans 'None' %}
|
||||
{% endfor %}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">{% trans 'Last modified' %}</th>
|
||||
<td class="align-middle">
|
||||
|
||||
@@ -24,19 +24,6 @@
|
||||
<th scope="row">{% trans 'Action handler' %}</th>
|
||||
<td class="align-middle">{{obj.responsible.handler|default_if_none:""}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">{% trans 'Funded by' %}</th>
|
||||
<td class="align-middle">
|
||||
{% with obj.fundings.all as fundings %}
|
||||
{% for funding in fundings %}
|
||||
<div class="badge pill-badge rlp-r-outline">{{funding.short_name}}</div>
|
||||
<br>
|
||||
{% empty %}
|
||||
{% trans 'None' %}
|
||||
{% endfor %}
|
||||
{% endwith %}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">{% trans 'Last modified' %}</th>
|
||||
<td class="align-middle">
|
||||
|
||||
Reference in New Issue
Block a user