delete_form.html 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. {% load form_helpers %}
  2. {% load i18n %}
  3. <form action="{{ form_url }}" method="post">
  4. {# Render hidden fields #}
  5. {% csrf_token %}
  6. {% for field in form.hidden_fields %}
  7. {{ field }}
  8. {% endfor %}
  9. <div class="modal-header">
  10. <h5 class="modal-title">{% trans "Confirm Deletion" %}</h5>
  11. </div>
  12. <div class="modal-body">
  13. <p>
  14. {% blocktrans trimmed %}
  15. Are you sure you want to <strong class="text-danger">delete</strong> {{ object_type }} <strong>{{ object }}</strong>?
  16. {% endblocktrans %}
  17. </p>
  18. {% if dependent_objects %}
  19. <p>
  20. {% trans "The following objects will be deleted as a result of this action." %}
  21. </p>
  22. <div class="accordion mb-3" id="deleteAccordion">
  23. {% for model, instances in dependent_objects.items %}
  24. {% with object_count=instances|length %}
  25. <div class="accordion-item">
  26. <h2 class="accordion-header h4" id="deleteheading{{ forloop.counter }}">
  27. {# High-cardinality relations (e.g. jobs) are summarized by count and are not #}
  28. {# expandable, since their instances are intentionally not loaded (see #22812). #}
  29. {% if instances.count_only %}
  30. <div class="accordion-button collapsed" style="cursor: default;">
  31. {{ object_count }}
  32. {% if object_count == 1 %}{{ model|meta:"verbose_name" }}{% else %}{{ model|meta:"verbose_name_plural" }}{% endif %}
  33. </div>
  34. {% else %}
  35. <button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#collapse{{ forloop.counter }}" aria-expanded="false" aria-controls="collapse{{ forloop.counter }}">
  36. {{ object_count }}
  37. {% if object_count == 1 %}{{ model|meta:"verbose_name" }}{% else %}{{ model|meta:"verbose_name_plural" }}{% endif %}
  38. </button>
  39. {% endif %}
  40. </h2>
  41. {% if not instances.count_only %}
  42. <div id="collapse{{ forloop.counter }}" class="accordion-collapse collapse" aria-labelledby="deleteheading{{ forloop.counter }}" data-bs-parent="#deleteAccordion">
  43. <div class="accordion-body p-0">
  44. <div class="list-group list-group-flush">
  45. {% for instance in instances %}
  46. {% with url=instance.get_absolute_url %}
  47. <a {% if url %}href="{{ url }}" {% endif %}class="list-group-item list-group-item-action">{{ instance }}</a>
  48. {% endwith %}
  49. {% endfor %}
  50. </div>
  51. </div>
  52. </div>
  53. {% endif %}
  54. </div>
  55. {% endwith %}
  56. {% endfor %}
  57. </div>
  58. {% endif %}
  59. {# Meta fields #}
  60. {% if form.changelog_message %}
  61. <div class="bg-primary-subtle border border-primary rounded-1 pt-3 px-3">
  62. {% render_field form.changelog_message %}
  63. </div>
  64. {% endif %}
  65. </div>
  66. <div class="modal-footer">
  67. {% if return_url %}
  68. <a href="{{ return_url }}" class="btn btn-outline-secondary">{% trans "Cancel" %}</a>
  69. {% else %}
  70. <button type="button" class="btn btn-outline-secondary" data-bs-dismiss="modal">{% trans "Cancel" %}</button>
  71. {% endif %}
  72. <button type="submit" class="btn btn-danger">{% trans "Delete" %}</button>
  73. </div>
  74. </form>