diff --git a/codelist/management/commands/update_codelist.py b/codelist/management/commands/update_codelist.py index 345b3244..aba524b7 100644 --- a/codelist/management/commands/update_codelist.py +++ b/codelist/management/commands/update_codelist.py @@ -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, diff --git a/codelist/models.py b/codelist/models.py index de7a2100..7d51ae78 100644 --- a/codelist/models.py +++ b/codelist/models.py @@ -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 diff --git a/codelist/settings.py b/codelist/settings.py index fb9fe79d..e1afa352 100644 --- a/codelist/settings.py +++ b/codelist/settings.py @@ -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 diff --git a/konova/management/commands/kspMigrater/compensation_migrater.py b/konova/management/commands/kspMigrater/compensation_migrater.py index 9e70a36f..96bcc5c0 100644 --- a/konova/management/commands/kspMigrater/compensation_migrater.py +++ b/konova/management/commands/kspMigrater/compensation_migrater.py @@ -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() diff --git a/konova/management/commands/kspMigrater/ema_migrater.py b/konova/management/commands/kspMigrater/ema_migrater.py index c523f12f..f7a7787d 100644 --- a/konova/management/commands/kspMigrater/ema_migrater.py +++ b/konova/management/commands/kspMigrater/ema_migrater.py @@ -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: