fix: restore historical order visibility for HartOMat admins

This commit is contained in:
2026-04-06 19:24:09 +02:00
parent f13cb489c1
commit 2a00abe91f
6 changed files with 19 additions and 7 deletions
+2 -1
View File
@@ -9,6 +9,7 @@ from sqlalchemy.ext.asyncio import AsyncSession
from sqlalchemy import select, func, update, or_, and_
from app.database import get_db
from app.domains.auth.models import PM_ROLES
from app.models.audit_log import AuditLog
from app.models.user import User
from app.utils.auth import get_current_user
@@ -45,7 +46,7 @@ class MarkReadRequest(BaseModel):
def _visibility_filter(user: User):
"""Rows visible to this user: targeted at them, or broadcast (null) if admin/PM."""
targeted = AuditLog.target_user_id == user.id
if user.role.value in ("admin", "project_manager"):
if user.role.value in PM_ROLES:
broadcast = AuditLog.target_user_id.is_(None)
return and_(AuditLog.notification == True, or_(targeted, broadcast)) # noqa: E712
return and_(AuditLog.notification == True, targeted) # noqa: E712