4d4537deff
- Публикация отчёта (модель ReportPublication + миграция, сервис publication). - Разделение прав: user_can_manage_it_monthly_report (правка) vs view; reports.view_all_departments в списке портальных прав. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
19 lines
688 B
Python
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
|