Aug 7 - Update: add external inspector
This commit is contained in:
@@ -40,7 +40,8 @@ logger = logging.getLogger(__name__)
|
||||
|
||||
bp = Blueprint('api_scheduled', __name__)
|
||||
|
||||
_ALLOWED_ROLES = {'admin', 'director', 'inspector', 'project_manager', 'auditor'}
|
||||
_ALLOWED_ROLES = {'admin', 'director', 'inspector', 'external_inspector',
|
||||
'project_manager', 'auditor'}
|
||||
|
||||
|
||||
def _scheduled_payload(s):
|
||||
@@ -127,7 +128,7 @@ def list_scheduled():
|
||||
InspectionSchedule.mode == 'plan',
|
||||
)
|
||||
|
||||
if user.role == 'inspector':
|
||||
if user.is_inspector:
|
||||
# Inspectors only see schedules assigned directly to them.
|
||||
query = query.filter(InspectionSchedule.inspector_id == user.id)
|
||||
|
||||
@@ -185,7 +186,8 @@ def create_follow_up():
|
||||
user = g.api_user
|
||||
|
||||
# Auditor is read-only everywhere else; keep it that way here.
|
||||
if user.role not in {'admin', 'director', 'inspector', 'project_manager'}:
|
||||
if user.role not in {'admin', 'director', 'inspector', 'external_inspector',
|
||||
'project_manager'}:
|
||||
return api_error('Access denied', 403)
|
||||
|
||||
body = request.get_json(silent=True) or {}
|
||||
@@ -201,7 +203,7 @@ def create_follow_up():
|
||||
# An inspector may only schedule a follow-up of their own work, and only
|
||||
# within their assigned contracts — the same two gates the rest of the
|
||||
# mobile API applies. Managers are unrestricted, matching the web.
|
||||
if user.role == 'inspector':
|
||||
if user.is_inspector:
|
||||
if parent.inspector_id != user.id:
|
||||
return api_error('Access denied', 403)
|
||||
fids = get_inspector_scope(user)
|
||||
|
||||
Reference in New Issue
Block a user