From 38eb77a441792f2ad00a7e63007eb504dc28fc3d Mon Sep 17 00:00:00 2001 From: NguyenND Date: Fri, 29 May 2026 09:29:31 -0400 Subject: [PATCH] 05/29 Update customer Inspections and Issues contract filter --- app/routes/inspections.py | 13 +++++++++++-- app/routes/issues.py | 13 +++++++++++-- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/app/routes/inspections.py b/app/routes/inspections.py index e6dffea..4a950fd 100644 --- a/app/routes/inspections.py +++ b/app/routes/inspections.py @@ -249,8 +249,17 @@ def index(): facilities = _fq.order_by(Facility.name).all() - from app.models.project import Project - projects = Project.query.filter_by(active=True).order_by(Project.name).all() + from app.models.project import Project, CustomerAssignment + if current_user.role == 'customer': + assigned_pids = { + a.project_id for a in + CustomerAssignment.query.filter_by(user_id=current_user.id).all() + } + projects = Project.query.filter( + Project.active == True, Project.id.in_(assigned_pids) + ).order_by(Project.name).all() + else: + projects = Project.query.filter_by(active=True).order_by(Project.name).all() return render_template('inspections/list.html', inspections=inspections, diff --git a/app/routes/issues.py b/app/routes/issues.py index 66fb777..630a5a0 100644 --- a/app/routes/issues.py +++ b/app/routes/issues.py @@ -169,8 +169,17 @@ def index(): facilities = _fq.order_by(Facility.name).all() - from app.models.project import Project - projects = Project.query.filter_by(active=True).order_by(Project.name).all() + from app.models.project import Project, CustomerAssignment + if current_user.role == 'customer': + assigned_pids = { + a.project_id for a in + CustomerAssignment.query.filter_by(user_id=current_user.id).all() + } + projects = Project.query.filter( + Project.active == True, Project.id.in_(assigned_pids) + ).order_by(Project.name).all() + else: + projects = Project.query.filter_by(active=True).order_by(Project.name).all() # Staff for quick-assign dropdown — same roles as the full issue form staff = User.query.filter(