Changelog & grammar tweak for #3211

This commit is contained in:
Jeremy Stretch 2019-05-29 10:33:29 -04:00
parent a7ca49c44d
commit 28facca291
3 changed files with 4 additions and 5 deletions

View File

@ -16,6 +16,7 @@
* [#3150](https://github.com/digitalocean/netbox/issues/3150) - Fix formatting of cable length during cable trace * [#3150](https://github.com/digitalocean/netbox/issues/3150) - Fix formatting of cable length during cable trace
* [#3184](https://github.com/digitalocean/netbox/issues/3184) - Correctly display color block for white cables * [#3184](https://github.com/digitalocean/netbox/issues/3184) - Correctly display color block for white cables
* [#3190](https://github.com/digitalocean/netbox/issues/3190) - Fix custom field rendering for Jinja2 export templates * [#3190](https://github.com/digitalocean/netbox/issues/3190) - Fix custom field rendering for Jinja2 export templates
* [#3211](https://github.com/digitalocean/netbox/issues/3211) - Fix error handling when attempting to delete a protected object via API
* [#3223](https://github.com/digitalocean/netbox/issues/3223) - Fix filtering devices by "has power outlets" * [#3223](https://github.com/digitalocean/netbox/issues/3223) - Fix filtering devices by "has power outlets"
--- ---

View File

@ -252,11 +252,8 @@ class ModelViewSet(_ModelViewSet):
try: try:
return super().dispatch(request, *args, **kwargs) return super().dispatch(request, *args, **kwargs)
except ProtectedError as e: except ProtectedError as e:
models = '\n'.join( models = ['{} ({})'.format(o, o._meta) for o in e.protected_objects.all()]
'- {} ({})'.format(o, o._meta) msg = 'Unable to delete object. The following dependent objects were found: {}'.format(', '.join(models))
for o in e.protected_objects.all()
)
msg = 'You tried deleting a model that is protected by:\n{}'.format(models)
return self.finalize_response( return self.finalize_response(
request, request,
Response({'detail': msg}, status=409), Response({'detail': msg}, status=409),

View File

@ -70,6 +70,7 @@ class ExceptionHandlingMiddleware(object):
custom_template = 'exceptions/import_error.html' custom_template = 'exceptions/import_error.html'
elif isinstance(exception, PermissionError): elif isinstance(exception, PermissionError):
custom_template = 'exceptions/permission_error.html' custom_template = 'exceptions/permission_error.html'
# Return a custom error message, or fall back to Django's default 500 error handling # Return a custom error message, or fall back to Django's default 500 error handling
if custom_template: if custom_template:
return server_error(request, template_name=custom_template) return server_error(request, template_name=custom_template)