Jul 8 - Update scheduled inspection

This commit is contained in:
2026-07-08 15:46:14 -04:00
parent f08ca997d7
commit 4d661e9776
15 changed files with 795 additions and 6 deletions
+19
View File
@@ -337,8 +337,27 @@ def index():
.all()
)
# ── Scheduled inspections (phase36): upcoming / overdue ──────────────
sched_upcoming = []
sched_overdue_count = 0
if not is_customer:
from app.models.scheduled_inspection import ScheduledInspection
_today = now.date()
_sq = ScheduledInspection.query.filter_by(active=True)
if is_inspector:
_sq = _sq.filter(ScheduledInspection.inspector_id == current_user.id)
_all_sched = _sq.order_by(ScheduledInspection.next_due_date.asc()).all()
sched_overdue_count = sum(1 for s in _all_sched if s.next_due_date < _today)
# Upcoming = due today through the next 7 days (overdue shown separately)
sched_upcoming = [
s for s in _all_sched
if _today <= s.next_due_date <= _today + timedelta(days=7)
][:8]
return render_template(
'dashboard.html',
sched_upcoming = sched_upcoming,
sched_overdue_count = sched_overdue_count,
today_inspections = today_inspections,
completed_today = completed_today,
open_issues = open_issues,