{# Shared template macros for tracking-setup. Convention (mirroring scenes-v2 /srv/home/scenes-v2/app/templates/): - Partials are prefixed with `_` and live in /app/templates/. - Import what you need at the top of a template: {% from "_macros.html" import status_badge, kind_badge, action_card %} When a UI fragment is used in 2+ places, extract it here. Don't copy-paste HTML across templates. #} {# Status pill (draft, sent, in_review, approved, etc.). Class hooks live in static/style.css. #} {% macro status_badge(status) -%} {{ status|replace('_', ' ') }} {%- endmacro %} {# Action-kind chip (event, conversion_marking, ads_import, custom_dimension, etc.). #} {% macro kind_badge(kind) -%} {{ kind|replace('_', ' ') }} {%- endmacro %} {# One Action card. Three render modes: mode='internal' — shows edit/delete forms, full spec JSON. mode='review' — shows approve/reject form + comment thread (client-facing). mode='pdf' — print-friendly, no forms, spec rendered as
. `a` is a dict (or sqlite3.Row converted to dict) with: id, kind, title, status, notes_md, proposed_spec_json, spec, spec_pretty (pre-rendered), comments? #} {% macro action_card(a, mode='internal') %}
  • {{ kind_badge(a.kind) }} {{ a.title }} {{ status_badge(a.status) }}
    {% if a.notes_md %}
    {{ a.notes_md }}
    {% endif %} {% if mode == 'pdf' %} {% if a.spec %}
    {% for k, v in a.spec.items() %}
    {{ k }}
    {{ v if v is string or v is number or v is boolean else v|tojson }}
    {% endfor %}
    {% endif %} {% elif mode == 'internal' %}
    Spec ({{ a.spec.event_name or a.spec.name or 'see details' }})
    {{ a.spec_pretty }}
    Edit / delete
    {% else %} {# review mode #} {% if a.spec %}
    Technical detail
      {% for k, v in a.spec.items() %}
    • {{ k }}: {{ v if v is string or v is number or v is boolean else v|tojson }}
    • {% endfor %}
    {% endif %} {% if a.comments %}
    {% for c in a.comments %}
    {{ c.name or c.email }} {{ c.created_at }}
    {{ c.body }}
    {% endfor %}
    {% endif %}
    {% if a.status != 'proposed' %} {% endif %}
    {% endif %}
  • {% endmacro %} {# Client/Org row link with status. Used in dashboard tables. #} {% macro client_row(c, show_org=true) -%} {{ c.name }} {% if show_org %}{{ c.org_name }}{% endif %} {{ c.primary_url }} {{ c.status }} {%- endmacro %}