ae54d93442
Section-based portal access, matrix прав по группам, аккаунтинг-портал, управление группами пользователей, справочники, дашборд и общий каркас навигации/стилей. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
16 lines
681 B
Python
16 lines
681 B
Python
"""Видимость персональных данных сотрудника в портале."""
|
|
|
|
|
|
def can_view_employee_pii(viewer, employee) -> bool:
|
|
"""Телефон, email, AD/Mattermost и т.п. — сам сотрудник, его керівник або HR/staff."""
|
|
if not viewer or not getattr(viewer, 'is_authenticated', False):
|
|
return False
|
|
if getattr(viewer, 'is_staff', False):
|
|
return True
|
|
from core.portal_access import user_can_manage_hr_portal
|
|
if user_can_manage_hr_portal(viewer):
|
|
return True
|
|
if employee is None:
|
|
return False
|
|
return viewer.pk == employee.pk or employee.manager_id == viewer.pk
|