Merge branch 'develop' into 7113-fix-prefix-iprange-bulkedit

This commit is contained in:
Jeremy Stretch 2021-09-01 10:55:52 -04:00 committed by GitHub
commit 9772c5705f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 8 additions and 14 deletions

View File

@ -23,6 +23,7 @@
* [#7101](https://github.com/netbox-community/netbox/issues/7101) - Enforce `MAX_PAGE_SIZE` for table and REST API pagination
* [#7106](https://github.com/netbox-community/netbox/issues/7106) - Fix incorrect "Map It" button URL on a site's Physical Address field
* [#7107](https://github.com/netbox-community/netbox/issues/7107) - Fix missing search button and search results in IP Address assignment "Assign IP" tab
* [#7109](https://github.com/netbox-community/netbox/issues/7109) - Ensure human readability of exceptions raised during REST API requests
* [#7113](https://github.com/netbox-community/netbox/issues/7113) - Fix IPRange bulk options within Prefix view
---

View File

@ -113,6 +113,10 @@ class ExceptionHandlingMiddleware(object):
def process_exception(self, request, exception):
# Handle exceptions that occur from REST API requests
if is_api_request(request):
return rest_api_server_error(request)
# Don't catch exceptions when in debug mode
if settings.DEBUG:
return
@ -121,10 +125,6 @@ class ExceptionHandlingMiddleware(object):
if isinstance(exception, Http404):
return
# Handle exceptions that occur from REST API requests
if is_api_request(request):
return rest_api_server_error(request)
# Determine the type of exception. If it's a common issue, return a custom error page with instructions.
custom_template = None
if isinstance(exception, ProgrammingError):

View File

@ -5,7 +5,7 @@
<html
lang="en"
data-netbox-path="{{ request.path }}"
data-netbox-base-path="{% base_path %}"
data-netbox-base-path="{{ settings.BASE_PATH }}"
{% if preferences|get_key:'ui.colormode' == 'dark'%}
data-netbox-color-mode="dark"
{% else %}

View File

@ -48,7 +48,8 @@ def is_api_request(request):
Return True of the request is being made via the REST API.
"""
api_path = reverse('api-root')
return request.path_info.startswith(api_path)
return request.path_info.startswith(api_path) and request.content_type == 'application/json'
def get_view_name(view, suffix=None):

View File

@ -355,14 +355,6 @@ def querystring(request, **kwargs):
return ''
@register.simple_tag()
def base_path():
"""
Access `BASE_PATH` in templates.
"""
return settings.BASE_PATH
@register.inclusion_tag('utilities/templatetags/utilization_graph.html')
def utilization_graph(utilization, warning_threshold=75, danger_threshold=90):
"""