From 291d566f17907c772a639d87f86be1d10f7ab698 Mon Sep 17 00:00:00 2001 From: NguyenND Date: Wed, 19 Aug 2026 14:51:16 -0400 Subject: [PATCH] Aug 19 - Fix New Inspection Internal Server error --- app/routes/inspection_schedules.py | 1 + app/templates/inspection_schedules/form.html | 3 ++- app/templates/inspections/view.html | 8 +++++++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/app/routes/inspection_schedules.py b/app/routes/inspection_schedules.py index 5455ff3..65184e8 100644 --- a/app/routes/inspection_schedules.py +++ b/app/routes/inspection_schedules.py @@ -42,6 +42,7 @@ from app.models.inspection_schedule import (InspectionSchedule, DEFAULT_RUN_HOUR) from app.models.inspection import Inspection, InspectionTemplate from app.models.facility import Facility, Area +from app.models.project import Project from app.models.user import User from functools import wraps from app.utils.decorators import project_manager_required diff --git a/app/templates/inspection_schedules/form.html b/app/templates/inspection_schedules/form.html index bbe6ac2..36aacdc 100644 --- a/app/templates/inspection_schedules/form.html +++ b/app/templates/inspection_schedules/form.html @@ -9,7 +9,6 @@ the auto/plan MODE. They are placed next to the field they qualify rather than in a block of their own. #} -{% block content %} {# ── Sticky values ──────────────────────────────────────────────────────── This form is hand-built (no WTForms), so a re-render after a validation error would otherwise come back blank and the user would retype everything. @@ -33,6 +32,8 @@ {% set v_nth_weekday = (posted.get('nth_weekday')|int(-1)) if posted else (schedule.nth_weekday if schedule and schedule.nth_weekday is not none else -1) %} {% set v_weekdays = (posted.getlist('weekdays')|map('int')|list) if posted else (schedule.weekday_list if schedule else []) %} {% set v_active = (posted.get('active') is not none) if posted else (schedule.active if schedule else True) %} + +{% block content %}
diff --git a/app/templates/inspections/view.html b/app/templates/inspections/view.html index 29acda1..aaddd35 100644 --- a/app/templates/inspections/view.html +++ b/app/templates/inspections/view.html @@ -1,6 +1,13 @@ {% extends "base.html" %} {% block title %}Inspection #{{ inspection.id }} — Results{% endblock %} +{# The filtered list URL this page was opened from. Defined at TOP LEVEL, not + inside the content block: Jinja blocks do not share scope, and the follow-up + modal below sits in the extra_js block — from there a content-scoped + back_url is Undefined and posts next="", silently dropping the very filters + this mechanism exists to preserve. #} +{% set back_url = request.args.get('next') or url_for('inspections.index') %} + {% block extra_css %}