Skip to content

Commit 1a2227e

Browse files
committed
remove general regulations from regulation group library generated from active plan
This way there shouldn't be any chance a plan regulation group widget to be created from a general regulation, preventing the case where the plan is counted as a plan feature linked to a regulation group. This change is also a fix in itself because it shouldn't be possible to assign general regulations for plan features.
1 parent 32876bd commit 1a2227e

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

arho_feature_template/core/plan_manager.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -441,13 +441,18 @@ def unload(self):
441441
def regulation_group_library_from_active_plan() -> RegulationGroupLibrary:
442442
category_features = list(PlanRegulationGroupTypeLayer.get_features())
443443
category_id_to_name: dict[str, str] = {category["id"]: category["name"][LANGUAGE] for category in category_features}
444+
445+
# Exclude general regulations from the library
444446
category_regulation_group_map: dict[str, list[QgsFeature]] = {
445-
feature["name"][LANGUAGE]: [] for feature in category_features
447+
feature["name"][LANGUAGE]: [] for feature in category_features if feature["value"] != "generalRegulations"
446448
}
447449

448450
for feat in RegulationGroupLayer.get_features():
449451
name = category_id_to_name[feat["type_of_plan_regulation_group_id"]]
450-
category_regulation_group_map[name].append(feat)
452+
feat_list = category_regulation_group_map.get(name)
453+
if type(feat_list) is list:
454+
feat_list.append(feat)
455+
451456
return RegulationGroupLibrary(
452457
name="Käytössä olevat kaavamääräysryhmät",
453458
version=None,

0 commit comments

Comments
 (0)