Skip to content

Commit

Permalink
Fixes netbox-community#1116: Correct object links on recursive deleti…
Browse files Browse the repository at this point in the history
…on error
  • Loading branch information
jeremystretch committed May 2, 2017
1 parent a958d2c commit 4527457
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions netbox/utilities/error_handlers.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
from django.contrib import messages
from django.utils.html import escape
from django.utils.safestring import mark_safe


def handle_protectederror(obj, request, e):
Expand All @@ -25,11 +27,11 @@ def handle_protectederror(obj, request, e):

# Append dependent objects to error message
dependent_objects = []
for o in e.protected_objects:
if hasattr(o, 'get_absolute_url'):
dependent_objects.append(u'<a href="{}">{}</a>'.format(o.get_absolute_url(), o))
for obj in e.protected_objects:
if hasattr(obj, 'get_absolute_url'):
dependent_objects.append(u'<a href="{}">{}</a>'.format(obj.get_absolute_url(), escape(obj)))
else:
dependent_objects.append(str(o))
dependent_objects.append(str(obj))
err_message += u', '.join(dependent_objects)

messages.error(request, err_message)
messages.error(request, mark_safe(err_message))

0 comments on commit 4527457

Please sign in to comment.