mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-23 16:06:43 -06:00
requested adjustments
This commit is contained in:
parent
63b1736c97
commit
48d7ca7a64
@ -338,14 +338,12 @@ class ObjectDeleteView(GetReturnURLMixin, BaseObjectView):
|
|||||||
using = router.db_for_write(obj._meta.model)
|
using = router.db_for_write(obj._meta.model)
|
||||||
collector = Collector(using=using)
|
collector = Collector(using=using)
|
||||||
collector.collect([obj])
|
collector.collect([obj])
|
||||||
deletion_objects = []
|
related_objects = {}
|
||||||
if collector.instances_with_model():
|
for model, instance in collector.instances_with_model():
|
||||||
for model, instance in collector.instances_with_model():
|
# we could ignore the instance == obj so that the list doesnt contain itself...
|
||||||
# we could ignore the instance == obj so that the list doesnt contain itself...
|
if not model.__name__ in related_objects:
|
||||||
deletion_objects.append({
|
related_objects[model.__name__] = []
|
||||||
"modelname":f"{model.__name__}",
|
related_objects[model.__name__].append(instance)
|
||||||
"object": instance,
|
|
||||||
})
|
|
||||||
|
|
||||||
# If this is an HTMX request, return only the rendered deletion form as modal content
|
# If this is an HTMX request, return only the rendered deletion form as modal content
|
||||||
if is_htmx(request):
|
if is_htmx(request):
|
||||||
@ -356,7 +354,7 @@ class ObjectDeleteView(GetReturnURLMixin, BaseObjectView):
|
|||||||
'object_type': self.queryset.model._meta.verbose_name,
|
'object_type': self.queryset.model._meta.verbose_name,
|
||||||
'form': form,
|
'form': form,
|
||||||
'form_url': form_url,
|
'form_url': form_url,
|
||||||
'deletion_objects': deletion_objects,
|
'related_objects': related_objects,
|
||||||
**self.get_extra_context(request, obj),
|
**self.get_extra_context(request, obj),
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -364,7 +362,7 @@ class ObjectDeleteView(GetReturnURLMixin, BaseObjectView):
|
|||||||
'object': obj,
|
'object': obj,
|
||||||
'form': form,
|
'form': form,
|
||||||
'return_url': self.get_return_url(request, obj),
|
'return_url': self.get_return_url(request, obj),
|
||||||
'deletion_objects': deletion_objects,
|
'related_objects': related_objects,
|
||||||
**self.get_extra_context(request, obj),
|
**self.get_extra_context(request, obj),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -12,11 +12,15 @@
|
|||||||
Are you sure you want to <strong class="text-danger">delete</strong> {{ object_type }} <strong>{{ object }}</strong>?
|
Are you sure you want to <strong class="text-danger">delete</strong> {{ object_type }} <strong>{{ object }}</strong>?
|
||||||
{% endblocktrans %}
|
{% endblocktrans %}
|
||||||
</p>
|
</p>
|
||||||
{% if deletion_objects %}
|
{% if related_objects %}
|
||||||
<p>
|
<p>
|
||||||
This will cause deltion of the following items: <br>
|
This will cause deletion of the following items: <br>
|
||||||
{% for deletion_object in deletion_objects %}
|
{% for model,objects in related_objects.items %}
|
||||||
- {{ deletion_object.modelname }} - {{ deletion_object.object | linkify }} <br>
|
- {{ model }}:
|
||||||
|
{% for object in objects %}
|
||||||
|
{{ object | linkify }},
|
||||||
|
{% endfor %}
|
||||||
|
<br>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</p>
|
</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
Loading…
Reference in New Issue
Block a user