05/16 Fix bugs 2
This commit is contained in:
@@ -110,9 +110,14 @@ def index():
|
||||
recent_inspections = recent_q.limit(5).all()
|
||||
|
||||
# ── Pending follow-up inspections ────────────────────────────────────
|
||||
# follow_ups is a lazy='dynamic' relationship — comparing it to None does
|
||||
# NOT produce a "has no rows" predicate for dynamic relationships. The
|
||||
# correct idiom is ~.any(), which generates EXISTS (SELECT 1 FROM inspections
|
||||
# WHERE parent_inspection_id = inspections.id). This matches the identical
|
||||
# filter used in routes/inspections.py:follow_up_filter.
|
||||
followup_q = Inspection.query.filter_by(
|
||||
follow_up_required=True, status='completed'
|
||||
).filter(Inspection.follow_ups == None) # noqa: E711 — SQLAlchemy usage
|
||||
).filter(~Inspection.follow_ups.any())
|
||||
if is_inspector:
|
||||
followup_q = followup_q.filter(Inspection.inspector_id == current_user.id)
|
||||
elif is_customer:
|
||||
|
||||
Reference in New Issue
Block a user