{% extends "base.html" %} {#- What a delete would take with it, counted before anything is written. A confirmation that only says "this cannot be undone" asks a question nobody can answer. The one people actually have is what happens to the rows underneath, and that is the difference between a confirmation and a trap. -#} {% macro related_list(groups) %} {% endmacro %} {% block content %}

{{ _("Delete {name}", name=model_singular|lower) }}

{{ _("This cannot be undone.") }}

{{ _("Delete {name}?", name=label) }}

{% set protected = related | selectattr("effect", "equalto", "protect") | list %} {% set cascaded = related | selectattr("effect", "equalto", "delete") | list %} {% set cleared = related | selectattr("effect", "equalto", "clear") | list %} {% if protected %} {# The database would refuse this, so the button is not offered. Failing here with a sentence beats failing inside the transaction with a constraint violation nobody can act on. #}
{{ _("Other records require this one") }}

{{ _("Remove or reassign these first, then delete this record.") }}

{{ related_list(protected) }}
{% endif %} {% if cascaded %}
{{ _("These records will be deleted too") }}
{{ related_list(cascaded) }}
{% endif %} {% if cleared %} {# Not a deletion. Saying so plainly is the point: a nullable foreign key means the rows survive with the column emptied, and warning that they will be deleted would be a lie in the other direction. #}
{{ _("These records will be kept, without the link") }}
{{ related_list(cleared) }}
{% endif %} {% if not related and cascades %} {# Nothing points at this row today, but the model declares relations that would go with it. Worth saying, so the absence of a warning is not read as a promise. #}
{{ _("Related records will be deleted too") }}
    {% for relation in cascades %}
  • {{ relation }}
  • {% endfor %}
{% endif %}
{% if not blocked %} {% endif %} {{ _("Cancel") if not blocked else _("Back") }}
{% endblock %}