Files
ACORE/apps/reports/access.py
T
lokses 4d4537deff reports: публикация отчётов и право управления
- Публикация отчёта (модель ReportPublication + миграция, сервис publication).
- Разделение прав: user_can_manage_it_monthly_report (правка) vs view;
  reports.view_all_departments в списке портальных прав.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-09-10 13:17:41 +03:00

19 lines
688 B
Python

"""Права на шаблоны отчётов."""
from __future__ import annotations
from apps.reports.it_monthly.builder import user_can_manage_it_monthly_report
from apps.reports.models import ReportTemplate
def user_can_manage_templates(user) -> bool:
"""Список/копирование/правка несистемных — руководитель отдела или superuser."""
return user_can_manage_it_monthly_report(user)
def user_can_edit_template(user, tpl: ReportTemplate) -> bool:
if not user_can_manage_templates(user):
return False
if tpl.is_system and not getattr(user, 'is_superuser', False):
return False
return True