delete_form.html 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. <div class="accordion-item">
  25. <h2 class="accordion-header h4" id="deleteheading{{ forloop.counter }}">
  26. <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 }}">
  27. {% with object_count=instances|length %}
  28. {{ object_count }}
  29. {% if object_count == 1 %}
  30. {{ model|meta:"verbose_name" }}
  31. {% else %}
  32. {{ model|meta:"verbose_name_plural" }}
  33. {% endif %}
  34. {% endwith %}
  35. </button>
  36. </h2>
  37. <div id="collapse{{ forloop.counter }}" class="accordion-collapse collapse" aria-labelledby="deleteheading{{ forloop.counter }}" data-bs-parent="#deleteAccordion">
  38. <div class="accordion-body p-0">
  39. <div class="list-group list-group-flush">
  40. {% for instance in instances %}
  41. {% with url=instance.get_absolute_url %}
  42. <a {% if url %}href="{{ url }}" {% endif %}class="list-group-item list-group-item-action">{{ instance }}</a>
  43. {% endwith %}
  44. {% endfor %}
  45. </div>
  46. </div>
  47. </div>
  48. </div>
  49. {% endfor %}
  50. </div>
  51. {% endif %}
  52. {# Meta fields #}
  53. {% if form.changelog_message %}
  54. <div class="bg-primary-subtle border border-primary rounded-1 pt-3 px-3">
  55. {% render_field form.changelog_message %}
  56. </div>
  57. {% endif %}
  58. </div>
  59. <div class="modal-footer">
  60. {% if return_url %}
  61. <a href="{{ return_url }}" class="btn btn-outline-secondary">{% trans "Cancel" %}</a>
  62. {% else %}
  63. <button type="button" class="btn btn-outline-secondary" data-bs-dismiss="modal">{% trans "Cancel" %}</button>
  64. {% endif %}
  65. <button type="submit" class="btn btn-danger">{% trans "Delete" %}</button>
  66. </div>
  67. </form>