{% extends 'base.html' %} {% load static %} {% block title %}Site Report — {{ work_log.date|date:"d M Y" }} | FoxFitt{% endblock %} {% block content %} {% comment %} Mobile-first site-report edit form. Reachable two ways: 1. Auto-redirect after a successful /attendance/log/ submission (the "two-step flow" — supervisor logs WHO worked, then lands here to log WHAT was done). 2. Direct visit /site-report//edit/ (admin or supervisor of the parent work log) — useful for backfilling a missed report. The form is deliberately optional: a "Skip" link goes straight home so supervisors who're in a hurry can ship the attendance log without the progress data. WorkLogs without a SiteReport are completely valid. Layout principles: - Vertical stack of inputs (no multi-column on phone) - Large tap-targets for the boolean checkboxes - inputmode="numeric" on count + temperature fields → numeric keypad - Weather rendered as a chunky icon-button row, not a dropdown {% endcomment %}
{# === Page header === #}

{% if is_creating %}Log Today's Work{% else %}Edit Site Report{% endif %}

{{ work_log.project.name }} — {{ work_log.date|date:"l, d M Y" }} {% if work_log.team %}({{ work_log.team.name }}){% endif %}
{# Skip = abandon this report (intentional) and go home. #} {# Save the attendance, ship the day. #} Skip
{# === Helpful note for the supervisor — only visible on first creation === #} {% if is_creating %}
Logging the day's progress is optional. Skip if you're in a hurry — the attendance entry is already saved.
{% endif %} {# === The form === #}
{% csrf_token %} {# --- Form-level error display --- #} {% if form.non_field_errors %}
{% for error in form.non_field_errors %}
{{ error }}
{% endfor %}
{% endif %} {# === SECTION 1 — Weather + Temperature === #}
Conditions
{# --- Weather: icon-button row, picks one --- #} {# Bootstrap btn-check + label pattern gives us large tap targets #} {# without a custom JavaScript handler. #}
{% for choice_value, choice_label in form.weather.field.choices %} {% endfor %}
{% if form.weather.errors %}
{{ form.weather.errors|first }}
{% endif %}
{# --- Temperature min/max: two short numeric fields --- #}
{{ form.temperature_min }} {% if form.temperature_min.errors %}
{{ form.temperature_min.errors|first }}
{% endif %}
{{ form.temperature_max }} {% if form.temperature_max.errors %}
{{ form.temperature_max.errors|first }}
{% endif %}
{# === SECTION 2 — Count metrics === #} {# Iterates (metric, bound_field) tuples pre-built in the view #} {# so we don't need a "form-by-variable-name" template filter. #}
Counts (today's totals)
{% for metric, bound_field in count_field_pairs %}
{{ bound_field }} {% if bound_field.errors %}
{{ bound_field.errors|first }}
{% endif %}
{% endfor %}
{# === SECTION 3 — Check metrics (booleans) === #}
Other (tap to mark)
{% for metric, bound_field in check_field_pairs %}
{{ bound_field }}
{% endfor %}
{# === SECTION 4 — Free-form notes === #}
{{ form.notes }} {% if form.notes.errors %}
{{ form.notes.errors|first }}
{% endif %}
{# === Actions === #}
Skip
{% endblock %}