improved deletion of recipes

This commit is contained in:
vabene1111
2021-11-04 12:27:21 +01:00
parent 980dc48eb8
commit 1fad1d2b8f
3 changed files with 62 additions and 28 deletions

View File

@@ -22,13 +22,11 @@
</div>
{{ form|crispy }}
{% if related_objects %}
{% blocktrans %} <i>{{ object }}</i> could not be deleted because it is still referenced by the following instances: {% endblocktrans %}
<br/>
<br/>
{% for o in related_objects %}
{% if protected_objects %}
<h5>{% trans 'Protected' %} <small class="text-muted">The object you are trying to delete is <b>protected</b> by the following references to it.</small></h5>
{% for o in protected_objects %}
{% class_name o.model as name %}
<h5>{{ name }}</h5>
<u>{{ name }}</u>
<ul>
{% for e in o %}
<li>
@@ -36,14 +34,40 @@
</li>
{% endfor %}
</ul>
{% endfor %}
<br/>
{% endif %}
<button class="btn btn-success" type="submit" href="{{ success_url }}"><i
{% if cascading_objects %}
<h5>{% trans 'Cascade' %} <small class="text-muted">The object you are trying to delete is used by the following objects which will <b>also be deleted</b>.</small></h5>
{% for o in cascading_objects %}
{% class_name o.model as name %}
<u>{{ name }}</u>
<ul>
{% for e in o %}
<li>
<span class="badge badge-info">#{{ e.id }}</span> {{ e }}
</li>
{% endfor %}
</ul>
{% endfor %}
{% endif %}
{% if set_null_objects %}
<h5>{% trans 'Remove' %} <small class="text-muted">The object you are trying to delete is used by the following objects from which the reference will be removed.</small></h5>
{% for o in set_null_objects %}
{% class_name o.model as name %}
<u>{{ name }}</u>
<ul>
{% for e in o %}
<li>
<span class="badge badge-info">#{{ e.id }}</span> {{ e }}
</li>
{% endfor %}
</ul>
{% endfor %}
{% endif %}
<button class="btn btn-success" type="submit" href="{{ success_url }}" {% if protected_objects %}disabled{% endif %}><i
class="fas fa-trash-alt"></i> {% trans 'Confirm' %}</button>
<a href="javascript:history.back()" class="btn btn-danger"><i class="fas fa-undo-alt"></i> {% trans 'Cancel' %}
</a>