Опросник: добавлен словарь criterion_fields (20 показателей ПП-127), импортёр распознаёт строки «Показатель N …» в листе объекта и складывает в criterion_input; фильтр по сфере (берутся только применимые показатели)

This commit is contained in:
LocoAgent
2026-08-05 15:39:06 +04:00
parent dbf8c613dd
commit 8e97e10714
3 changed files with 157 additions and 0 deletions
+24
View File
@@ -4782,6 +4782,29 @@ class DokoGenApp:
if data.get('informationSystems'):
self.model.information_systems.clear()
for is_data in data['informationSystems']:
# Фильтр по сфере: оставляем только показатели, применимые к сфере объекта
# (организация заполняет в опроснике только свои; лишнее отбрасываем).
_crit_in = dict(is_data.get('criterion_input', {}) or {})
if _crit_in:
import re as _re_sphere
_appl = None
try:
import json as _json_sphere
_ap_path = os.path.join(os.path.dirname(__file__),
'dictionaries', 'criteria_applicability.json')
with open(_ap_path, encoding='utf-8') as _f_sphere:
_appl_all = _json_sphere.load(_f_sphere)
_appl = _appl_all.get(is_data.get('sphere', '') or '')
except Exception:
_appl = None
if _appl:
_filtered = {}
for _n, _v in _crit_in.items():
_m = _re_sphere.match(r'(\d+)', str(_n))
_g = _m.group(1) if _m else str(_n)
if _g in _appl:
_filtered[_n] = _v
_crit_in = _filtered
isys = InformationSystem(
name=is_data.get('name', ''),
description=is_data.get('description', ''),
@@ -4815,6 +4838,7 @@ class DokoGenApp:
attacker_types=is_data.get('attacker_types', ''),
threats=normalize_threats(is_data.get('threats', '')),
incidents=normalize_threats(is_data.get('incidents', '')),
criterion_input=_crit_in,
criteria_values=is_data.get('criteria_values', ''),
criteria_justification=is_data.get('criteria_justification', ''),
org_measures=is_data.get('org_measures', ''),