feat: add KS-6a Excel/Word export
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
"""Export layer: shared DTOs, helpers, and format-specific renderers."""
|
||||
import re
|
||||
from urllib.parse import quote
|
||||
|
||||
|
||||
def _clean_export_name(raw: str) -> str:
|
||||
return re.sub(r'[<>:"/\\|?*]', "_", raw)
|
||||
|
||||
|
||||
def safe_export_filename(prefix: str, number: str, dt, extension: str) -> str:
|
||||
raw = f"{prefix} №{number} от {dt.strftime('%d.%m.%Y')}"
|
||||
return f"{_clean_export_name(raw)}.{extension}"
|
||||
|
||||
|
||||
def safe_export_filename_period(prefix: str, date_from, date_to, extension: str, suffix: str = "") -> str:
|
||||
raw = f"{prefix}_{date_from.strftime('%d.%m.%Y')}-{date_to.strftime('%d.%m.%Y')}"
|
||||
if suffix:
|
||||
raw = f"{raw}_{suffix}"
|
||||
return f"{_clean_export_name(raw)}.{extension}"
|
||||
|
||||
|
||||
def content_disposition(filename: str) -> str:
|
||||
return f"attachment; filename*=UTF-8''{quote(filename)}"
|
||||
|
||||
Reference in New Issue
Block a user