{# Versions card — owner + admin only. Renders entity.version_history (oldest-first) reversed so newest appears at top. Each row gets: * version label (vN, "current" badge for the active one) * short hash + size + created_at * Restore button (owner + admin) for non-current versions * Download button (admin only) — links to admin submission bundle Required scope: entity — store_entities row carrying version_no + version_history is_owner — bool is_admin — bool Self-guards on visibility (only renders for owner/admin) and on history length (>= 1). Plain entities created post-v37 always have at least a v1 entry. #} {% if (is_owner or is_admin) and entity and entity.version_history and entity.version_history|length >= 1 %}
| Version | Hash | Size | Created | |
|---|---|---|---|---|
| v{{ v.n }} {% if v.n == entity.version_no %}current{% endif %} | {{ v.hash[:12] if v.hash else '—' }} |
{%- if v.size is not none -%} {%- if v.size < 1024 -%}{{ v.size }} B {%- elif v.size < 1048576 -%}{{ "%.1f"|format(v.size / 1024) }} KB {%- else -%}{{ "%.1f"|format(v.size / 1048576) }} MB {%- endif -%} {%- else -%}—{%- endif -%} | {{ v.created_at[:10] if v.created_at else '' }} | {# Restore only when the version was actually approved. ``submission_status=None`` is legacy v1 (seeded pre-v37 before submission_id backfill) — treat as approved. Anything else (blocked_inline / blocked_llm / review_error / pending_*) renders a pill instead so the owner understands why no button. #} {% set _sub_status = v.submission_status %} {% set _is_approvable = _sub_status in ['approved', None] %} {% if v.n != entity.version_no %} {% if _is_approvable %} {% elif _sub_status in ['blocked_inline', 'blocked_llm'] %} blocked {% elif _sub_status == 'review_error' %} errored {% elif _sub_status in ['pending_inline', 'pending_llm'] %} pending {% endif %} {% endif %} |