{% 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 %}
{# Rated fields only, grouped by section #} {% if form_fields %} {# Build a lookup of image fields by row number for pairing with ratings #} {% set ns = namespace(pending_section='', has_any=false) %} {% for field in form_fields %} {% if field.type == 'section' %} {% set ns.pending_section = field.label %} {% elif field.type == 'rating' %} {% set fid = field.id | string %} {% set score = form_data.get(fid, '0') | int %} {% if score > 0 %} {% set ns.has_any = true %} {# Flush pending section header #} {% if ns.pending_section %}
{{ ns.pending_section }}
{% set ns.pending_section = '' %} {% endif %} {# Look for an image field on the same grid row #} {% set photo_url = '' %} {% for other in form_fields %} {% if other.type == 'image' and other.row == field.row %} {% set photo_url = form_data.get(other.id | string, '') %} {% endif %} {% endfor %}
{{ field.label }}
{% for i in range(1,6) %}{{ '★' if i <= score else '☆' }}{% endfor %} {{ score }}/5
{% if photo_url %} {% endif %}
{% endif %} {% endif %} {% endfor %} {% if not ns.has_any %}

No rated fields in this inspection.

{% endif %} {% 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 lightbox modal #}
Photo
Inspection photo
{% endblock %} {% block extra_js %} {% endblock %}