05/15 Update: implement iPad notification function 3

This commit is contained in:
Nguyen Ngo
2026-05-15 15:35:39 -04:00
parent b69a52e5f5
commit 33efa9402e
2 changed files with 74 additions and 65 deletions
+12 -9
View File
@@ -58,6 +58,10 @@ def _issue_payload(issue):
'reported_at': issue.reported_at.isoformat() if issue.reported_at else None,
'resolved_at': issue.resolved_at.isoformat() if issue.resolved_at else None,
'mobile_local_id': issue.mobile_local_id,
# photo_path is the primary issue photo; result_photos are resolution photos.
# Both are relative paths from the server static root.
'photo_path': issue.photo_path or None,
'result_photos': issue.result_photos or [],
}
@@ -67,14 +71,15 @@ def _issue_payload(issue):
@jwt_required
def list_issues():
"""
Return issues assigned to the authenticated user.
Return active issues for the authenticated user.
Inspectors: only issues where assigned_to == current user.
Admin / director / project_manager: all non-resolved issues (capped at 200).
All roles see all non-resolved issues (inspectors included) so the iPad
shows the full picture of open work at their facilities.
A ?status= filter can be used to override the default exclusion.
Query parameters
----------------
status str Filter by status (default: excludes resolved).
status str Filter by status. Omit to get all non-resolved issues.
limit int Default 100, max 200.
offset int Default 0.
@@ -100,7 +105,7 @@ def list_issues():
query = Issue.query
if user.role == 'inspector':
# Inspectors only see issues assigned to them
# Inspectors see only issues assigned to them
query = query.filter(Issue.assigned_to == user.id)
else:
# Broader roles: exclude resolved by default so the list stays manageable
@@ -249,9 +254,7 @@ def get_issue(issue_id):
Return current status, severity, description, assigned_to, and facility
for a single issue.
Access:
- admin / director / project_manager : any issue
- inspector : only issues where assigned_to == current user
Access: all allowed roles may fetch any issue.
"""
user = g.api_user
if user.role not in _ALLOWED_ROLES:
@@ -322,4 +325,4 @@ def update_issue_status(issue_id):
logger.info('API ISSUES | status_updated | issue_id=%d | %s%s | user=%s',
issue.id, old_status, new_status, user.username)
return api_ok({'issue_id': issue.id, 'status': issue.status})
return api_ok({'issue_id': issue.id, 'status': issue.status})