# Codelist 288
* introduces 288 to codelist/settings.py * refactors usage from 975 to 288 * enhances rendering of codelist names depending on which name exists (short vs long)
This commit is contained in:
parent
2761d2a19c
commit
762d25a87e
@ -16,7 +16,8 @@ from api.utils.serializer.serializer import AbstractModelAPISerializer
|
|||||||
from codelist.models import KonovaCode
|
from codelist.models import KonovaCode
|
||||||
from codelist.settings import CODELIST_COMPENSATION_ACTION_ID, CODELIST_BIOTOPES_ID, CODELIST_PROCESS_TYPE_ID, \
|
from codelist.settings import CODELIST_COMPENSATION_ACTION_ID, CODELIST_BIOTOPES_ID, CODELIST_PROCESS_TYPE_ID, \
|
||||||
CODELIST_LAW_ID, CODELIST_REGISTRATION_OFFICE_ID, CODELIST_CONSERVATION_OFFICE_ID, \
|
CODELIST_LAW_ID, CODELIST_REGISTRATION_OFFICE_ID, CODELIST_CONSERVATION_OFFICE_ID, \
|
||||||
CODELIST_COMPENSATION_ACTION_DETAIL_ID, CODELIST_BIOTOPES_EXTRA_CODES_ID, CODELIST_HANDLER_ID
|
CODELIST_COMPENSATION_ACTION_DETAIL_ID, CODELIST_HANDLER_ID, \
|
||||||
|
CODELIST_BIOTOPES_EXTRA_CODES_FULL_ID
|
||||||
from compensation.models import CompensationAction, UnitChoices, CompensationState
|
from compensation.models import CompensationAction, UnitChoices, CompensationState
|
||||||
from intervention.models import Responsibility, Legal, Handler
|
from intervention.models import Responsibility, Legal, Handler
|
||||||
from konova.models import Deadline, DeadlineType
|
from konova.models import Deadline, DeadlineType
|
||||||
@ -347,7 +348,7 @@ class AbstractCompensationAPISerializerV1Mixin:
|
|||||||
try:
|
try:
|
||||||
biotope_type = entry["biotope"]
|
biotope_type = entry["biotope"]
|
||||||
biotope_details = [
|
biotope_details = [
|
||||||
self._konova_code_from_json(e, CODELIST_BIOTOPES_EXTRA_CODES_ID) for e in entry["biotope_details"]
|
self._konova_code_from_json(e, CODELIST_BIOTOPES_EXTRA_CODES_FULL_ID) for e in entry["biotope_details"]
|
||||||
]
|
]
|
||||||
surface = float(entry["surface"])
|
surface = float(entry["surface"])
|
||||||
except KeyError:
|
except KeyError:
|
||||||
|
@ -9,7 +9,8 @@ import collections
|
|||||||
|
|
||||||
from django.core.exceptions import ImproperlyConfigured
|
from django.core.exceptions import ImproperlyConfigured
|
||||||
|
|
||||||
from codelist.settings import CODELIST_BIOTOPES_ID, CODELIST_BIOTOPES_EXTRA_CODES_ID
|
from codelist.settings import CODELIST_BIOTOPES_ID, \
|
||||||
|
CODELIST_BIOTOPES_EXTRA_CODES_FULL_ID
|
||||||
from codelist.autocomplete.base import KonovaCodeAutocomplete
|
from codelist.autocomplete.base import KonovaCodeAutocomplete
|
||||||
from konova.utils.message_templates import UNGROUPED
|
from konova.utils.message_templates import UNGROUPED
|
||||||
|
|
||||||
@ -84,11 +85,11 @@ class BiotopeExtraCodeAutocomplete(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
|
||||||
"""
|
"""
|
||||||
group_by_related = "parent"
|
group_by_related = "parent"
|
||||||
related_field_name = "long_name"
|
related_field_name = "short_name"
|
||||||
paginate_by = 200
|
paginate_by = 200
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
self.c = CODELIST_BIOTOPES_EXTRA_CODES_ID
|
self.c = CODELIST_BIOTOPES_EXTRA_CODES_FULL_ID
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
|
|
||||||
def order_by(self, qs):
|
def order_by(self, qs):
|
||||||
@ -103,7 +104,7 @@ class BiotopeExtraCodeAutocomplete(KonovaCodeAutocomplete):
|
|||||||
qs (QuerySet): The ordered queryset
|
qs (QuerySet): The ordered queryset
|
||||||
"""
|
"""
|
||||||
return qs.order_by(
|
return qs.order_by(
|
||||||
"long_name",
|
"short_name",
|
||||||
)
|
)
|
||||||
|
|
||||||
def get_result_label(self, result):
|
def get_result_label(self, result):
|
||||||
|
@ -13,7 +13,7 @@ from codelist.settings import CODELIST_INTERVENTION_HANDLER_ID, CODELIST_CONSERV
|
|||||||
CODELIST_REGISTRATION_OFFICE_ID, CODELIST_BIOTOPES_ID, CODELIST_LAW_ID, CODELIST_HANDLER_ID, \
|
CODELIST_REGISTRATION_OFFICE_ID, CODELIST_BIOTOPES_ID, CODELIST_LAW_ID, CODELIST_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_BIOTOPES_EXTRA_CODES_ID, \
|
CODELIST_BASE_URL, CODELIST_PROCESS_TYPE_ID, CODELIST_BIOTOPES_EXTRA_CODES_ID, \
|
||||||
CODELIST_COMPENSATION_ACTION_DETAIL_ID
|
CODELIST_COMPENSATION_ACTION_DETAIL_ID, CODELIST_BIOTOPES_EXTRA_CODES_FULL_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
|
||||||
|
|
||||||
@ -34,6 +34,7 @@ class Command(BaseKonovaCommand):
|
|||||||
CODELIST_REGISTRATION_OFFICE_ID,
|
CODELIST_REGISTRATION_OFFICE_ID,
|
||||||
CODELIST_BIOTOPES_ID,
|
CODELIST_BIOTOPES_ID,
|
||||||
CODELIST_BIOTOPES_EXTRA_CODES_ID,
|
CODELIST_BIOTOPES_EXTRA_CODES_ID,
|
||||||
|
CODELIST_BIOTOPES_EXTRA_CODES_FULL_ID,
|
||||||
CODELIST_LAW_ID,
|
CODELIST_LAW_ID,
|
||||||
CODELIST_HANDLER_ID,
|
CODELIST_HANDLER_ID,
|
||||||
CODELIST_COMPENSATION_ACTION_ID,
|
CODELIST_COMPENSATION_ACTION_ID,
|
||||||
@ -55,7 +56,7 @@ class Command(BaseKonovaCommand):
|
|||||||
content = result.content.decode("utf-8")
|
content = result.content.decode("utf-8")
|
||||||
root = etree.fromstring(content)
|
root = etree.fromstring(content)
|
||||||
items = root.findall("item")
|
items = root.findall("item")
|
||||||
self._write_warning("Found {} codes. Process now...".format(len(items)))
|
self._write_warning(" Found {} codes. Process now...".format(len(items)))
|
||||||
|
|
||||||
code_list = KonovaCodeList.objects.get_or_create(
|
code_list = KonovaCodeList.objects.get_or_create(
|
||||||
id=list_id,
|
id=list_id,
|
||||||
@ -74,7 +75,7 @@ class Command(BaseKonovaCommand):
|
|||||||
if items is None:
|
if items is None:
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
self._write_warning(" --- Found {} subcodes. Process now...".format(len(items)))
|
self._write_warning(" --- Found {} subcodes. Process now...".format(len(items)))
|
||||||
for element in items:
|
for element in items:
|
||||||
children = element.find("items")
|
children = element.find("items")
|
||||||
_id = element.find("id").text
|
_id = element.find("id").text
|
||||||
|
@ -50,12 +50,23 @@ class KonovaCode(models.Model):
|
|||||||
|
|
||||||
def __str__(self, with_parent: bool = True):
|
def __str__(self, with_parent: bool = True):
|
||||||
ret_val = ""
|
ret_val = ""
|
||||||
if self.parent and self.parent.long_name and with_parent:
|
|
||||||
ret_val += self.parent.long_name + " > "
|
long_name = self.long_name
|
||||||
ret_val += self.long_name
|
short_name = self.short_name
|
||||||
if self.short_name and self.short_name != self.long_name:
|
|
||||||
# Only add short name, if we won't have stupid repition like 'thing a (thing a)' due to misused long-short names
|
both_names_exist = long_name and short_name
|
||||||
ret_val += f" ({self.short_name})"
|
|
||||||
|
if both_names_exist:
|
||||||
|
if with_parent:
|
||||||
|
if self.parent and self.parent.long_name:
|
||||||
|
ret_val += self.parent.long_name + " > "
|
||||||
|
ret_val += long_name
|
||||||
|
|
||||||
|
if short_name and short_name != long_name:
|
||||||
|
ret_val += f" ({short_name})"
|
||||||
|
else:
|
||||||
|
ret_val += str(long_name or short_name)
|
||||||
|
|
||||||
return ret_val
|
return ret_val
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -15,7 +15,8 @@ CODELIST_CONSERVATION_OFFICE_ID = 907 # CLNaturschutzbehörden
|
|||||||
CODELIST_REGISTRATION_OFFICE_ID = 1053 # CLZulassungsbehörden
|
CODELIST_REGISTRATION_OFFICE_ID = 1053 # CLZulassungsbehörden
|
||||||
CODELIST_BIOTOPES_ID = 654 # CL_Biotoptypen
|
CODELIST_BIOTOPES_ID = 654 # CL_Biotoptypen
|
||||||
CODELIST_AFTER_STATE_BIOTOPES_ID = 974 # CL-KSP_ZielBiotoptypen - USAGE HAS BEEN DROPPED IN 2022 IN FAVOR OF 654
|
CODELIST_AFTER_STATE_BIOTOPES_ID = 974 # CL-KSP_ZielBiotoptypen - USAGE HAS BEEN DROPPED IN 2022 IN FAVOR OF 654
|
||||||
CODELIST_BIOTOPES_EXTRA_CODES_ID = 975 # CLZusatzbezeichnung
|
CODELIST_BIOTOPES_EXTRA_CODES_ID = 975 # CLZusatzbezeichnung - Subset of 288. Migration usage 975->288 in 08/2024
|
||||||
|
CODELIST_BIOTOPES_EXTRA_CODES_FULL_ID = 288 # CLBiotoptypZusatzcode
|
||||||
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,8 @@ from django.shortcuts import render
|
|||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
|
||||||
from codelist.models import KonovaCode
|
from codelist.models import KonovaCode
|
||||||
from codelist.settings import CODELIST_BIOTOPES_ID, CODELIST_BIOTOPES_EXTRA_CODES_ID
|
from codelist.settings import CODELIST_BIOTOPES_ID, \
|
||||||
|
CODELIST_BIOTOPES_EXTRA_CODES_FULL_ID
|
||||||
from intervention.inputs import CompensationStateTreeRadioSelect
|
from intervention.inputs import CompensationStateTreeRadioSelect
|
||||||
from konova.contexts import BaseContext
|
from konova.contexts import BaseContext
|
||||||
from konova.forms.modals import RemoveModalForm, BaseModalForm
|
from konova.forms.modals import RemoveModalForm, BaseModalForm
|
||||||
@ -43,7 +44,7 @@ class NewCompensationStateModalForm(BaseModalForm):
|
|||||||
queryset=KonovaCode.objects.filter(
|
queryset=KonovaCode.objects.filter(
|
||||||
is_archived=False,
|
is_archived=False,
|
||||||
is_leaf=True,
|
is_leaf=True,
|
||||||
code_lists__in=[CODELIST_BIOTOPES_EXTRA_CODES_ID],
|
code_lists__in=[CODELIST_BIOTOPES_EXTRA_CODES_FULL_ID],
|
||||||
),
|
),
|
||||||
widget=autocomplete.ModelSelect2Multiple(
|
widget=autocomplete.ModelSelect2Multiple(
|
||||||
url="codelist:biotope-extra-type-autocomplete",
|
url="codelist:biotope-extra-type-autocomplete",
|
||||||
|
@ -6,10 +6,10 @@ Created on: 16.11.21
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.db.models import Q
|
|
||||||
|
|
||||||
from codelist.models import KonovaCode
|
from codelist.models import KonovaCode
|
||||||
from codelist.settings import CODELIST_BIOTOPES_ID, CODELIST_BIOTOPES_EXTRA_CODES_ID
|
from codelist.settings import CODELIST_BIOTOPES_ID, \
|
||||||
|
CODELIST_BIOTOPES_EXTRA_CODES_FULL_ID
|
||||||
from compensation.managers import CompensationStateManager
|
from compensation.managers import CompensationStateManager
|
||||||
from konova.models import UuidModel
|
from konova.models import UuidModel
|
||||||
|
|
||||||
@ -34,7 +34,7 @@ class CompensationState(UuidModel):
|
|||||||
KonovaCode,
|
KonovaCode,
|
||||||
blank=True,
|
blank=True,
|
||||||
limit_choices_to={
|
limit_choices_to={
|
||||||
"code_lists__in": [CODELIST_BIOTOPES_EXTRA_CODES_ID],
|
"code_lists__in": [CODELIST_BIOTOPES_EXTRA_CODES_FULL_ID],
|
||||||
"is_selectable": True,
|
"is_selectable": True,
|
||||||
"is_archived": False,
|
"is_archived": False,
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user