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(