# 88 Additional biotope codes
* adds codelist 975 to project * adds new form field for adding extra biotope information
This commit is contained in:
parent
af75ff5885
commit
d0c6449c39
@ -13,7 +13,7 @@ from codelist.models import KonovaCode, KonovaCodeList
|
|||||||
from codelist.settings import CODELIST_INTERVENTION_HANDLER_ID, CODELIST_CONSERVATION_OFFICE_ID, \
|
from codelist.settings import CODELIST_INTERVENTION_HANDLER_ID, CODELIST_CONSERVATION_OFFICE_ID, \
|
||||||
CODELIST_REGISTRATION_OFFICE_ID, CODELIST_BIOTOPES_ID, CODELIST_LAW_ID, CODELIST_COMPENSATION_HANDLER_ID, \
|
CODELIST_REGISTRATION_OFFICE_ID, CODELIST_BIOTOPES_ID, CODELIST_LAW_ID, CODELIST_COMPENSATION_HANDLER_ID, \
|
||||||
CODELIST_COMPENSATION_ACTION_ID, CODELIST_COMPENSATION_ACTION_CLASS_ID, CODELIST_COMPENSATION_ADDITIONAL_TYPE_ID, \
|
CODELIST_COMPENSATION_ACTION_ID, CODELIST_COMPENSATION_ACTION_CLASS_ID, CODELIST_COMPENSATION_ADDITIONAL_TYPE_ID, \
|
||||||
CODELIST_BASE_URL, CODELIST_PROCESS_TYPE_ID
|
CODELIST_BASE_URL, CODELIST_PROCESS_TYPE_ID, CODELIST_BIOTOPES_EXTRA_CODES_ID
|
||||||
from konova.management.commands.setup import BaseKonovaCommand
|
from konova.management.commands.setup import BaseKonovaCommand
|
||||||
from konova.settings import PROXIES
|
from konova.settings import PROXIES
|
||||||
|
|
||||||
@ -33,6 +33,7 @@ class Command(BaseKonovaCommand):
|
|||||||
CODELIST_CONSERVATION_OFFICE_ID,
|
CODELIST_CONSERVATION_OFFICE_ID,
|
||||||
CODELIST_REGISTRATION_OFFICE_ID,
|
CODELIST_REGISTRATION_OFFICE_ID,
|
||||||
CODELIST_BIOTOPES_ID,
|
CODELIST_BIOTOPES_ID,
|
||||||
|
CODELIST_BIOTOPES_EXTRA_CODES_ID,
|
||||||
CODELIST_LAW_ID,
|
CODELIST_LAW_ID,
|
||||||
CODELIST_COMPENSATION_HANDLER_ID,
|
CODELIST_COMPENSATION_HANDLER_ID,
|
||||||
CODELIST_COMPENSATION_ACTION_ID,
|
CODELIST_COMPENSATION_ACTION_ID,
|
||||||
|
@ -14,6 +14,7 @@ CODELIST_INTERVENTION_HANDLER_ID = 903 # CLMassnahmeträger
|
|||||||
CODELIST_CONSERVATION_OFFICE_ID = 907 # CLNaturschutzbehörden
|
CODELIST_CONSERVATION_OFFICE_ID = 907 # CLNaturschutzbehörden
|
||||||
CODELIST_REGISTRATION_OFFICE_ID = 1053 # CLZulassungsbehörden
|
CODELIST_REGISTRATION_OFFICE_ID = 1053 # CLZulassungsbehörden
|
||||||
CODELIST_BIOTOPES_ID = 974 # CL_EIV_Biotoptypen
|
CODELIST_BIOTOPES_ID = 974 # CL_EIV_Biotoptypen
|
||||||
|
CODELIST_BIOTOPES_EXTRA_CODES_ID = 975 # CLZusatzbezeichnung
|
||||||
CODELIST_LAW_ID = 1048 # CLVerfahrensrecht
|
CODELIST_LAW_ID = 1048 # CLVerfahrensrecht
|
||||||
CODELIST_PROCESS_TYPE_ID = 44382 # CLVerfahrenstyp
|
CODELIST_PROCESS_TYPE_ID = 44382 # CLVerfahrenstyp
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ from django.shortcuts import render
|
|||||||
from django.utils.translation import pgettext_lazy as _con, gettext_lazy as _
|
from django.utils.translation import pgettext_lazy as _con, gettext_lazy as _
|
||||||
|
|
||||||
from codelist.models import KonovaCode
|
from codelist.models import KonovaCode
|
||||||
from codelist.settings import CODELIST_BIOTOPES_ID, CODELIST_COMPENSATION_ACTION_ID
|
from codelist.settings import CODELIST_BIOTOPES_ID, CODELIST_COMPENSATION_ACTION_ID, CODELIST_BIOTOPES_EXTRA_CODES_ID
|
||||||
from compensation.models import CompensationDocument, EcoAccountDocument
|
from compensation.models import CompensationDocument, EcoAccountDocument
|
||||||
from konova.contexts import BaseContext
|
from konova.contexts import BaseContext
|
||||||
from konova.forms import BaseModalForm, NewDocumentForm
|
from konova.forms import BaseModalForm, NewDocumentForm
|
||||||
@ -127,6 +127,23 @@ class NewStateModalForm(BaseModalForm):
|
|||||||
}
|
}
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
biotope_extra = forms.ModelChoiceField(
|
||||||
|
label=_("Biotope additional type"),
|
||||||
|
label_suffix="",
|
||||||
|
required=False,
|
||||||
|
help_text=_("Select an additional biotope type"),
|
||||||
|
queryset=KonovaCode.objects.filter(
|
||||||
|
is_archived=False,
|
||||||
|
is_leaf=True,
|
||||||
|
code_lists__in=[CODELIST_BIOTOPES_EXTRA_CODES_ID],
|
||||||
|
),
|
||||||
|
widget=autocomplete.ModelSelect2Multiple(
|
||||||
|
url="codes-biotope-extra-type-autocomplete",
|
||||||
|
attrs={
|
||||||
|
"data-placeholder": _("Biotope additional type"),
|
||||||
|
}
|
||||||
|
),
|
||||||
|
)
|
||||||
surface = forms.DecimalField(
|
surface = forms.DecimalField(
|
||||||
min_value=0.00,
|
min_value=0.00,
|
||||||
decimal_places=2,
|
decimal_places=2,
|
||||||
|
@ -11,7 +11,8 @@ from django.db.models import Q
|
|||||||
|
|
||||||
from codelist.models import KonovaCode
|
from codelist.models import KonovaCode
|
||||||
from codelist.settings import CODELIST_COMPENSATION_ACTION_ID, CODELIST_BIOTOPES_ID, CODELIST_LAW_ID, \
|
from codelist.settings import CODELIST_COMPENSATION_ACTION_ID, CODELIST_BIOTOPES_ID, CODELIST_LAW_ID, \
|
||||||
CODELIST_REGISTRATION_OFFICE_ID, CODELIST_CONSERVATION_OFFICE_ID, CODELIST_PROCESS_TYPE_ID
|
CODELIST_REGISTRATION_OFFICE_ID, CODELIST_CONSERVATION_OFFICE_ID, CODELIST_PROCESS_TYPE_ID, \
|
||||||
|
CODELIST_BIOTOPES_EXTRA_CODES_ID
|
||||||
from compensation.models import EcoAccount
|
from compensation.models import EcoAccount
|
||||||
from intervention.models import Intervention
|
from intervention.models import Intervention
|
||||||
|
|
||||||
@ -192,6 +193,36 @@ class BiotopeCodeAutocomplete(KonovaCodeAutocomplete):
|
|||||||
return f"{result.long_name} ({result.short_name})"
|
return f"{result.long_name} ({result.short_name})"
|
||||||
|
|
||||||
|
|
||||||
|
class BiotopeExtraCodeAutocomplete(KonovaCodeAutocomplete):
|
||||||
|
"""
|
||||||
|
Due to limitations of the django dal package, we need to subclass for each code list
|
||||||
|
"""
|
||||||
|
group_by_related = "parent"
|
||||||
|
related_field_name = "long_name"
|
||||||
|
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
self.c = CODELIST_BIOTOPES_EXTRA_CODES_ID
|
||||||
|
super().__init__(*args, **kwargs)
|
||||||
|
|
||||||
|
def order_by(self, qs):
|
||||||
|
""" Orders by a predefined value
|
||||||
|
|
||||||
|
Wrapped in a function to provide inheritance-based different orders
|
||||||
|
|
||||||
|
Args:
|
||||||
|
qs (QuerySet): The queryset to be ordered
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
qs (QuerySet): The ordered queryset
|
||||||
|
"""
|
||||||
|
return qs.order_by(
|
||||||
|
"parent__long_name",
|
||||||
|
)
|
||||||
|
|
||||||
|
def get_result_label(self, result):
|
||||||
|
return f"{result.long_name} ({result.short_name})"
|
||||||
|
|
||||||
|
|
||||||
class LawCodeAutocomplete(KonovaCodeAutocomplete):
|
class LawCodeAutocomplete(KonovaCodeAutocomplete):
|
||||||
"""
|
"""
|
||||||
Due to limitations of the django dal package, we need to subclass for each code list
|
Due to limitations of the django dal package, we need to subclass for each code list
|
||||||
|
@ -229,4 +229,7 @@ No other approach worked to get the autocomplete fields to full width of parent
|
|||||||
}
|
}
|
||||||
.select2-results__option--highlighted{
|
.select2-results__option--highlighted{
|
||||||
background-color: var(--rlp-red) !important;
|
background-color: var(--rlp-red) !important;
|
||||||
|
}
|
||||||
|
.select2-container--default .select2-results > .select2-results__options{
|
||||||
|
max-height: 500px !important;
|
||||||
}
|
}
|
@ -20,7 +20,7 @@ from django.urls import path, include
|
|||||||
from konova.autocompletes import EcoAccountAutocomplete, \
|
from konova.autocompletes import EcoAccountAutocomplete, \
|
||||||
InterventionAutocomplete, CompensationActionCodeAutocomplete, BiotopeCodeAutocomplete, LawCodeAutocomplete, \
|
InterventionAutocomplete, CompensationActionCodeAutocomplete, BiotopeCodeAutocomplete, LawCodeAutocomplete, \
|
||||||
RegistrationOfficeCodeAutocomplete, ConservationOfficeCodeAutocomplete, ProcessTypeCodeAutocomplete, \
|
RegistrationOfficeCodeAutocomplete, ConservationOfficeCodeAutocomplete, ProcessTypeCodeAutocomplete, \
|
||||||
ShareUserAutocomplete
|
ShareUserAutocomplete, BiotopeExtraCodeAutocomplete
|
||||||
from konova.settings import SSO_SERVER, SSO_PUBLIC_KEY, SSO_PRIVATE_KEY, DEBUG
|
from konova.settings import SSO_SERVER, SSO_PUBLIC_KEY, SSO_PRIVATE_KEY, DEBUG
|
||||||
from konova.sso.sso import KonovaSSOClient
|
from konova.sso.sso import KonovaSSOClient
|
||||||
from konova.views import logout_view, home_view, remove_deadline_view
|
from konova.views import logout_view, home_view, remove_deadline_view
|
||||||
@ -48,6 +48,7 @@ urlpatterns = [
|
|||||||
path("atcmplt/interventions", InterventionAutocomplete.as_view(), name="interventions-autocomplete"),
|
path("atcmplt/interventions", InterventionAutocomplete.as_view(), name="interventions-autocomplete"),
|
||||||
path("atcmplt/codes/comp/action", CompensationActionCodeAutocomplete.as_view(), name="codes-compensation-action-autocomplete"),
|
path("atcmplt/codes/comp/action", CompensationActionCodeAutocomplete.as_view(), name="codes-compensation-action-autocomplete"),
|
||||||
path("atcmplt/codes/biotope", BiotopeCodeAutocomplete.as_view(), name="codes-biotope-autocomplete"),
|
path("atcmplt/codes/biotope", BiotopeCodeAutocomplete.as_view(), name="codes-biotope-autocomplete"),
|
||||||
|
path("atcmplt/codes/biotope/extra", BiotopeExtraCodeAutocomplete.as_view(), name="codes-biotope-extra-type-autocomplete"),
|
||||||
path("atcmplt/codes/law", LawCodeAutocomplete.as_view(), name="codes-law-autocomplete"),
|
path("atcmplt/codes/law", LawCodeAutocomplete.as_view(), name="codes-law-autocomplete"),
|
||||||
path("atcmplt/codes/prc-type", ProcessTypeCodeAutocomplete.as_view(), name="codes-process-type-autocomplete"),
|
path("atcmplt/codes/prc-type", ProcessTypeCodeAutocomplete.as_view(), name="codes-process-type-autocomplete"),
|
||||||
path("atcmplt/codes/reg-off", RegistrationOfficeCodeAutocomplete.as_view(), name="codes-registration-office-autocomplete"),
|
path("atcmplt/codes/reg-off", RegistrationOfficeCodeAutocomplete.as_view(), name="codes-registration-office-autocomplete"),
|
||||||
|
Loading…
Reference in New Issue
Block a user