mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
12433 update object list widget to correctly parameterize urls (#12434)
* 12433 update object list widget to correctly parameterize urls * Update netbox/extras/dashboard/widgets.py Co-authored-by: Jeremy Stretch <jstretch@netboxlabs.com> * 12433 fix indent * Correct per_page query parameter --------- Co-authored-by: Jeremy Stretch <jstretch@netboxlabs.com>
This commit is contained in:
@ -229,7 +229,11 @@ class ObjectListWidget(DashboardWidget):
|
|||||||
htmx_url = reverse(viewname)
|
htmx_url = reverse(viewname)
|
||||||
except NoReverseMatch:
|
except NoReverseMatch:
|
||||||
htmx_url = None
|
htmx_url = None
|
||||||
if parameters := self.config.get('url_params'):
|
parameters = self.config.get('url_params') or {}
|
||||||
|
if page_size := self.config.get('page_size'):
|
||||||
|
parameters['per_page'] = page_size
|
||||||
|
|
||||||
|
if parameters:
|
||||||
try:
|
try:
|
||||||
htmx_url = f'{htmx_url}?{urlencode(parameters, doseq=True)}'
|
htmx_url = f'{htmx_url}?{urlencode(parameters, doseq=True)}'
|
||||||
except ValueError:
|
except ValueError:
|
||||||
@ -238,7 +242,6 @@ class ObjectListWidget(DashboardWidget):
|
|||||||
'viewname': viewname,
|
'viewname': viewname,
|
||||||
'has_permission': has_permission,
|
'has_permission': has_permission,
|
||||||
'htmx_url': htmx_url,
|
'htmx_url': htmx_url,
|
||||||
'page_size': self.config.get('page_size'),
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
{% if htmx_url and has_permission %}
|
{% if htmx_url and has_permission %}
|
||||||
<div class="htmx-container" hx-get="{{ htmx_url }}{% if page_size %}?per_page={{ page_size }}{% endif %}" hx-trigger="load"></div>
|
<div class="htmx-container" hx-get="{{ htmx_url }}" hx-trigger="load"></div>
|
||||||
{% elif htmx_url %}
|
{% elif htmx_url %}
|
||||||
<div class="text-muted text-center">
|
<div class="text-muted text-center">
|
||||||
<i class="mdi mdi-lock-outline"></i> No permission to view this content.
|
<i class="mdi mdi-lock-outline"></i> No permission to view this content.
|
||||||
|
Reference in New Issue
Block a user