mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Changelog & grammar tweak for #3211
This commit is contained in:
@@ -252,11 +252,8 @@ class ModelViewSet(_ModelViewSet):
|
||||
try:
|
||||
return super().dispatch(request, *args, **kwargs)
|
||||
except ProtectedError as e:
|
||||
models = '\n'.join(
|
||||
'- {} ({})'.format(o, o._meta)
|
||||
for o in e.protected_objects.all()
|
||||
)
|
||||
msg = 'You tried deleting a model that is protected by:\n{}'.format(models)
|
||||
models = ['{} ({})'.format(o, o._meta) for o in e.protected_objects.all()]
|
||||
msg = 'Unable to delete object. The following dependent objects were found: {}'.format(', '.join(models))
|
||||
return self.finalize_response(
|
||||
request,
|
||||
Response({'detail': msg}, status=409),
|
||||
|
@@ -70,6 +70,7 @@ class ExceptionHandlingMiddleware(object):
|
||||
custom_template = 'exceptions/import_error.html'
|
||||
elif isinstance(exception, PermissionError):
|
||||
custom_template = 'exceptions/permission_error.html'
|
||||
|
||||
# Return a custom error message, or fall back to Django's default 500 error handling
|
||||
if custom_template:
|
||||
return server_error(request, template_name=custom_template)
|
||||
|
Reference in New Issue
Block a user