0da9c13192
Иерархия рамочных/дочерних договоров и платежей, интернет-биллинг, месячные IT-отчёты (импорт, DOCX/PDF, шаблоны выводов). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
43 lines
1.2 KiB
Python
43 lines
1.2 KiB
Python
"""Реестр отчётов портала — какие карточки видит пользователь на /reports/."""
|
|
from __future__ import annotations
|
|
|
|
from dataclasses import dataclass
|
|
from typing import Callable
|
|
|
|
from django.contrib.auth.models import AbstractBaseUser
|
|
|
|
from apps.reports.it_monthly.builder import user_can_view_it_monthly_report
|
|
|
|
|
|
@dataclass(frozen=True)
|
|
class ReportSpec:
|
|
code: str
|
|
title: str
|
|
department: str
|
|
description: str
|
|
path: str
|
|
can_view: Callable[[AbstractBaseUser], bool]
|
|
|
|
|
|
REPORTS: tuple[ReportSpec, ...] = (
|
|
ReportSpec(
|
|
code='it_monthly',
|
|
title='Месячный IT-отчёт',
|
|
department='it',
|
|
description='Сводка выполненных работ IT-отдела за месяц: сотрудники, объекты, выводы. Экспорт MD/DOCX/PDF.',
|
|
path='/reports/it/monthly/',
|
|
can_view=user_can_view_it_monthly_report,
|
|
),
|
|
)
|
|
|
|
|
|
def visible_reports(user) -> list[ReportSpec]:
|
|
return [spec for spec in REPORTS if spec.can_view(user)]
|
|
|
|
|
|
def get_report(code: str) -> ReportSpec | None:
|
|
for spec in REPORTS:
|
|
if spec.code == code:
|
|
return spec
|
|
return None
|