#132 Enhancements

* adds CL288 to list of codelists
    * holds historic detail codes on biotopes (needed for proper migration of old entries but not for future, new entries)
* improves EMA finance migration
* adds fix for KonovaCodes where parents do not have any proper long_name values set but short_names instead
This commit is contained in:
mpeltriaux 2022-03-22 13:41:03 +01:00
parent 0c1ca4d173
commit f312dafa68
5 changed files with 16 additions and 13 deletions

View File

@ -14,7 +14,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_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_COMPENSATION_ACTION_DETAIL_ID
CODELIST_COMPENSATION_ACTION_DETAIL_ID, CODELIST_288_ID
from konova.management.commands.setup import BaseKonovaCommand
from konova.settings import PROXIES
@ -33,6 +33,7 @@ class Command(BaseKonovaCommand):
CODELIST_INTERVENTION_HANDLER_ID,
CODELIST_CONSERVATION_OFFICE_ID,
CODELIST_REGISTRATION_OFFICE_ID,
CODELIST_288_ID,
CODELIST_BIOTOPES_ID,
CODELIST_BIOTOPES_EXTRA_CODES_ID,
CODELIST_LAW_ID,

View File

@ -51,7 +51,7 @@ class KonovaCode(models.Model):
def __str__(self, with_parent: bool = True):
ret_val = ""
if self.parent and with_parent:
ret_val += self.parent.long_name + " > "
ret_val += self.parent.long_name or self.parent.short_name + " > "
ret_val += self.long_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

View File

@ -13,6 +13,7 @@ CODELIST_BASE_URL = "https://codelisten.naturschutz.rlp.de/repository/referenzli
CODELIST_INTERVENTION_HANDLER_ID = 903 # CLMassnahmeträger
CODELIST_CONSERVATION_OFFICE_ID = 907 # CLNaturschutzbehörden
CODELIST_REGISTRATION_OFFICE_ID = 1053 # CLZulassungsbehörden
CODELIST_288_ID = 288 # CL_288 (holds GISPAD related detail-biotope codes, similar to 975, but historical and only important for migration)
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_BIOTOPES_EXTRA_CODES_ID = 975 # CLZusatzbezeichnung

View File

@ -1,14 +1,11 @@
from django.core.exceptions import ObjectDoesNotExist, MultipleObjectsReturned
from django.core.exceptions import ObjectDoesNotExist
from django.db import transaction
from django.utils import formats
from codelist.models import KonovaCode
from codelist.settings import CODELIST_BIOTOPES_ID, CODELIST_BIOTOPES_EXTRA_CODES_ID, \
CODELIST_COMPENSATION_ACTION_DETAIL_ID, CODELIST_COMPENSATION_ACTION_ID, CODELIST_CONSERVATION_OFFICE_ID, \
CODELIST_HANDLER_ID, CODELIST_COMPENSATION_HANDLER_ID
CODELIST_COMPENSATION_ACTION_DETAIL_ID, CODELIST_COMPENSATION_ACTION_ID, CODELIST_COMPENSATION_HANDLER_ID, CODELIST_288_ID
from compensation.models import Compensation, CompensationState, CompensationAction, UnitChoices, CompensationDocument
from ema.models import Ema, EmaDocument
from intervention.models import Responsibility, Handler, Intervention
from intervention.models import Responsibility, Intervention
from konova.management.commands.kspMigrater.base_migrater import BaseMigrater
from konova.models import Deadline, DeadlineType
@ -172,7 +169,10 @@ class CompensationMigrater(BaseMigrater):
for z_code_result in z_code_results:
z_code = KonovaCode.objects.filter(
atom_id=z_code_result[0],
code_lists__in=[CODELIST_BIOTOPES_EXTRA_CODES_ID],
code_lists__in=[
CODELIST_BIOTOPES_EXTRA_CODES_ID,
CODELIST_288_ID,
],
)
z_codes += z_code
tmp_cursor_z_code.close()

View File

@ -172,12 +172,13 @@ class EmaMigrater(CompensationMigrater):
tmp_cursor = self.db_connection.cursor()
tmp_cursor.execute(
'select '
'b.datum, '
'b.hoehe '
'b.datum, '
'b.hoehe '
'from "OBJ_MASTER" om '
'left join bewilligung b on om."GISPADID"=b.gispadid '
'left join bewilligung b on om."GISPADID"=b.gispadid '
'where '
f'om."KENNUNG"={ema_identifier} '
f'om."KENNUNG"={ema_identifier} and '
'b.hoehe is not null'
)
db_results = tmp_cursor.fetchall()
for result in db_results: