{% extends "base.html" %} {% block title %}Inspection #{{ inspection.id }} — Results{% endblock %} {% block extra_css %} {% endblock %} {% block content %}
{# Action bar #}
Back
{% if current_user.role in ['admin','supervisor'] %}
{% endif %}
{# Header #}
{{ inspection.template.name }}
{{ inspection.facility.name }}{% if inspection.area %} · {{ inspection.area.name }}{% endif %} · Inspector: {{ inspection.inspector.username }}
{{ inspection.status|replace('_',' ')|title }} {% if inspection.overall_score is not none %}
{{ inspection.overall_score }}%
{% endif %}
{# Meta strip #}
Date {{ inspection.inspection_date.strftime('%b %d, %Y %H:%M') }}
{% if inspection.completed_at %}
Completed {{ inspection.completed_at.strftime('%b %d, %Y %H:%M') }}
{% endif %}
Template {{ inspection.template.name }}
Frequency {{ inspection.template.frequency|title }}
{% if inspection.overall_score is not none %}
Overall Score
{{ inspection.overall_score }}%
{% endif %}
{# All form fields — compact single-line rows, grouped by section #} {% if form_fields %} {% set ns = namespace(pending_section='') %} {% for field in form_fields %} {% set ftype = field.type %} {% set fid = field.id | string %} {% set val = form_data.get(fid, '') %} {# Section heading — buffer it, only flush when a visible field follows #} {% if ftype == 'section' %} {% set ns.pending_section = field.label %} {# Skip display-only types #} {% elif ftype in ('label', 'button_submit', 'button_print', 'button_email') %} {# All input field types — render as compact row #} {% else %} {# Flush pending section header #} {% if ns.pending_section %}
{{ ns.pending_section }}
{% set ns.pending_section = '' %} {% endif %}
{{ field.label }} {# ── Rating ── #} {% if ftype == 'rating' %} {% set score = val | int %} {% if score > 0 %} {% for i in range(1,6) %}{{ '★' if i <= score else '☆' }}{% endfor %} {{ score }}/5 {% else %} Not rated {% endif %} {# ── Image / Photo ── #} {% elif ftype == 'image' %} {% if val %} {% else %} No photo {% endif %} {# ── Signature ── #} {% elif ftype == 'signature' %} {% if val and val.startswith('data:') %} {% else %} No signature {% endif %} {# ── Checkbox single ── #} {% elif ftype == 'checkbox' %} {% if val == 'yes' %} Yes {% else %} No {% endif %} {# ── Checkbox group ── #} {% elif ftype == 'checkbox_group' %} {% if val and val is iterable and val is not string and val | length > 0 %} {% for opt in val %}{{ opt }}{% endfor %} {% else %} None selected {% endif %} {# ── Table ── #} {% elif ftype == 'table' %} {% if val and val is iterable and val is not string %} {% for hdr in (field.col_headers or ['Column 1']) %}{% endfor %} {% for row in val %} {% for hdr in (field.col_headers or ['Column 1']) %}{% endfor %} {% endfor %}
{{ hdr }}
{{ row.get(hdr,'') }}
{% else %} No data {% endif %}
{# ── Everything else: text, textarea, number, date, email, radio, select ── #} {% else %} {% if val %} {{ val }} {% else %} {% endif %} {% endif %}
{# /field-row #} {% endif %} {% endfor %} {% else %}

No form fields found for this template.

{% endif %} {# Issues #} {% if issues %}
Issues ({{ issues|length }})
{% for issue in issues %} {% endfor %}
Severity Area Description Status
{{ issue.severity|title }} {{ issue.area.name }} {{ issue.description[:80] }}{% if issue.description|length > 80 %}…{% endif %} {{ issue.status|replace('_',' ')|title }} View
{% endif %}
{# /insp-body #}
{# /insp-wrap #} {# Photo / Signature lightbox #}
Photo
Photo
{% endblock %} {% block extra_js %} {% endblock %}