05/29 Update customer Inspections and Issues contract filter
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user