form-export-fix: убрал экспорт страницы OTCH9F, кириллические названия страниц
This commit is contained in:
parent
efe6df992d
commit
45710ff58e
@ -40,6 +40,17 @@ ZIP_MEDIA_TYPE = "application/zip"
|
||||
FORM1_DIRECTION_REQUIRED_SHEETS = {"AHR", "CAP"}
|
||||
SHEETS_WITH_SECTIONS = {"AHR", "CAP", "OPER"}
|
||||
|
||||
SHEET_NAMES = {
|
||||
'AHR': 'АХР',
|
||||
'CAP': 'КВП',
|
||||
'OPER': 'Операц',
|
||||
'AHR_LIMIT': 'АХР Лимиты',
|
||||
'AHR_RENT': 'АХР Аренда',
|
||||
'AHR_SECURITY': 'АХР Безопасность',
|
||||
'AHR_UTILITY': 'АХР Коммунальные услуги',
|
||||
'SMETA': 'Смета',
|
||||
}
|
||||
SKIP_SHEETS = ('OTCH9F',)
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class ExportSheetPlan:
|
||||
@ -233,6 +244,9 @@ class ExportService:
|
||||
workbook = self._create_workbook_with_metadata(form=form)
|
||||
exported_sheets = 0
|
||||
for plan in plans:
|
||||
if not plan.validation_direction and plan.sheet_name in SKIP_SHEETS:
|
||||
continue
|
||||
|
||||
self._validate_sheet_query_params(
|
||||
form_type_code=form.form_type.code,
|
||||
sheet=plan.sheet_name,
|
||||
@ -245,7 +259,7 @@ class ExportService:
|
||||
direction=plan.effective_direction,
|
||||
sections=plan.effective_sections,
|
||||
)
|
||||
worksheet = workbook.create_sheet(title=self._safe_sheet_name(plan.sheet_name))
|
||||
worksheet = workbook.create_sheet(title=self._safe_sheet_name(plan.sheet_name, plan.effective_direction))
|
||||
self._write_sheet_rows(
|
||||
worksheet=worksheet,
|
||||
rows=rows,
|
||||
@ -420,7 +434,15 @@ class ExportService:
|
||||
return form_type_code == FormTypeEnum.FORM_1 and sheet in FORM1_DIRECTION_REQUIRED_SHEETS
|
||||
|
||||
@staticmethod
|
||||
def _safe_sheet_name(value: str) -> str:
|
||||
def _safe_sheet_name(value: str, direction: str | None = None) -> str:
|
||||
if value in SHEET_NAMES:
|
||||
sheet_name = SHEET_NAMES[value]
|
||||
match direction:
|
||||
case 'Support':
|
||||
sheet_name = f'{sheet_name}_П'
|
||||
case 'Development':
|
||||
sheet_name = f'{sheet_name}_Р'
|
||||
return sheet_name
|
||||
safe = value
|
||||
for char in ("[", "]", ":", "*", "?", "/", "\\"):
|
||||
safe = safe.replace(char, "_")
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user