fix: добавлены маппинги для старых <...> переменных + резолвер для is:/commission_member
This commit is contained in:
@@ -62,6 +62,28 @@ VARIABLE_DEFS = [
|
||||
|
||||
# === 152-ФЗ ===
|
||||
('{{is_security_requirements}}', 'B', 'Требования уровня защищённости', 'security_reqs'),
|
||||
('{{is_list}}', 'B', 'Список всех ИС (нумерованный)', 'is_list'),
|
||||
('{{is_name}}', 'B', 'Наименование первой ИС', 'is:name'),
|
||||
('{{name}}', 'B', 'Название ИС (алиас)', 'is:name'),
|
||||
('{{description}}', 'B', 'Описание ИС (алиас)', 'is:description'),
|
||||
('{{category}}', 'B', 'Категория ИС (алиас)', 'is:category'),
|
||||
('{{number}}', 'B', 'Номер (алиас)', 'doc_number'),
|
||||
('{{pd_count}}', 'B', 'Количество записей ПДн (алиас)', 'is:pd_count'),
|
||||
('{{pd_list}}', 'B', 'Список ПДн (алиас)', 'is:pd_list'),
|
||||
('{{pd_subjects}}', 'B', 'Субъекты ПДн (алиас)', 'is:pd_subjects'),
|
||||
('{{threat_type}}', 'B', 'Тип угроз (алиас)', 'is:threat_type'),
|
||||
('{{users}}', 'B', 'Пользователи ИС (алиас)', 'is:users'),
|
||||
('{{defence_level}}', 'B', 'Уровень защищённости (алиас)', 'is:defence_level'),
|
||||
('{{full_name_genitive}}', 'A', 'Полное наименование (род.п., алиас)', 'decl:full_name:gent'),
|
||||
('{{document}}', 'A', 'Название бумажного документа (алиас)', 'company:paper_documents'),
|
||||
('{{storage}}', 'A', 'Место хранения (алиас)', 'company:paper_storage'),
|
||||
('{{responsible_fio_accs}}', 'A', 'ФИО ответственного (вин.п.)', 'fio_acl:responsible'),
|
||||
('{{commission1}}', 'A', 'Должность члена комиссии 1', 'commission_member:0:position'),
|
||||
('{{commission1_fio}}', 'A', 'ФИО члена комиссии 1', 'commission_member:0:fio'),
|
||||
('{{commission2}}', 'A', 'Должность члена комиссии 2', 'commission_member:1:position'),
|
||||
('{{commission2_fio}}', 'A', 'ФИО члена комиссии 2', 'commission_member:1:fio'),
|
||||
('{{commission3}}', 'A', 'Должность члена комиссии 3', 'commission_member:2:position'),
|
||||
('{{commission3_fio}}', 'A', 'ФИО члена комиссии 3', 'commission_member:2:fio'),
|
||||
]
|
||||
|
||||
# Маппинг старых переменных <...> → {{...}}
|
||||
@@ -93,6 +115,26 @@ OLD_VAR_MAP = {
|
||||
'<DocumentDate>': '{{document_date}}',
|
||||
'<Date>': '{{date}}',
|
||||
'<SurveyDate>': '{{document_date}}',
|
||||
# Недостающие маппинги из лога
|
||||
'<ShortCompanyName2>': '{{company_short_name_genitive}}',
|
||||
'<ShortCompanyName3>': '{{company_short_name_dative}}',
|
||||
'<ShortCompanyName4>': '{{company_short_name_accs}}',
|
||||
'<ShortCompanyName5>': '{{company_short_name_ablt}}',
|
||||
'<ShortCompanyName6>': '{{company_short_name_loct}}',
|
||||
'<CompanyName3>': '{{company_full_name_dative}}',
|
||||
'<CompanyName4>': '{{company_full_name_accs}}',
|
||||
'<Commission1>': '{{commission1}}',
|
||||
'<Commission1Fio>': '{{commission1_fio}}',
|
||||
'<Commission2>': '{{commission2}}',
|
||||
'<Commission2Fio>': '{{commission2_fio}}',
|
||||
'<Commission3>': '{{commission3}}',
|
||||
'<Commission3Fio>': '{{commission3_fio}}',
|
||||
'<IspdnName>': '{{is_name}}',
|
||||
'<AdministratorPosition>': '{{admin_position}}',
|
||||
# Исключаем клавиши клавиатуры из проверки
|
||||
'<Alt>': 'Alt',
|
||||
'<Ctrl>': 'Ctrl',
|
||||
'<Del>': 'Del',
|
||||
}
|
||||
|
||||
VAR_PATTERN = re.compile(r'\{\{[^}]+\}\}')
|
||||
@@ -291,6 +333,54 @@ def _resolve(source: str, ctx: Dict) -> str:
|
||||
if source == 'security_reqs':
|
||||
return _get_security_text(ctx)
|
||||
|
||||
# IS-алиасы (первая ИС)
|
||||
if source.startswith('is:'):
|
||||
field = source[3:]
|
||||
if is_list:
|
||||
first = is_list[0]
|
||||
field_map = {
|
||||
'name': 'name',
|
||||
'description': 'description',
|
||||
'category': 'category',
|
||||
'defence_level': 'defence_level',
|
||||
'threat_type': 'threat_type',
|
||||
'pd_list': lambda: ', '.join(first.personal_data_list or []),
|
||||
'pd_count': 'pd_count',
|
||||
'pd_subjects': lambda: '; '.join(first.pd_subjects_list or []),
|
||||
'users': lambda: ', '.join(first.users_list or []),
|
||||
}
|
||||
if field in field_map:
|
||||
val = field_map[field]
|
||||
if callable(val):
|
||||
return val() or '—'
|
||||
return str(getattr(first, val, '') or '—') if isinstance(val, str) else '—'
|
||||
return '—'
|
||||
|
||||
# Список ИС
|
||||
if source == 'is_list':
|
||||
if is_list:
|
||||
return '\n'.join(f"{i}. {isys.name}" for i, isys in enumerate(is_list, 1))
|
||||
return '—'
|
||||
if source == 'is_list_comma':
|
||||
if is_list:
|
||||
return ', '.join(isys.name for isys in is_list)
|
||||
return '—'
|
||||
|
||||
# Члены комиссии
|
||||
if source.startswith('commission_member:'):
|
||||
parts = source.split(':')
|
||||
idx, field = int(parts[1]), parts[2]
|
||||
members = getattr(company, 'commission', None) or []
|
||||
if idx < len(members):
|
||||
return str(getattr(members[idx], field, '') or '—')
|
||||
return '—'
|
||||
|
||||
# Склонение ФИО по падежам
|
||||
if source.startswith('fio_acl:'):
|
||||
who = source.split(':', 1)[1]
|
||||
fio = _get_fio(company, who)
|
||||
return dc.decline(fio, 'accs') if fio else '—'
|
||||
|
||||
return '—'
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user