{% if missive.pk %}
{% comment %}
Saved missive: render every PDF physical attachment in priority order
(first_document at priority 0 comes first, then the user's attachments).
Non-PDF attachments are intentionally skipped — no preview, no link.
{% endcomment %}
{% for doc in missive.attachments_physical %}
{% if doc.is_pdf %}
📄
{% if doc.is_first_document %}{% trans "Letter (first page)" %}{% else %}{{ doc.filename|default:"unnamed" }}{% endif %}
{% trans "Loading…" %}
{% endif %}
{% endfor %}
{% else %}
{# Unsaved missive (campaign preview): fall back to inline HTML letter page. #}
{% include "django_pymissive/includes/postal_a4_letter_page.html" %}
{% endif %}
{% endblock %}
{% block preview_scripts %}
{% trans "PDF.js unavailable." as pdfjs_msg_unavailable %}
{% trans "Open attachment" as pdfjs_msg_open %}
{% trans "Could not render document" as pdfjs_msg_error %}
{% endblock %}