From 9e14e28d89c3d755bd7f7bbd7e10bc57cc4dbacf Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Wed, 12 Aug 2020 13:57:34 -0400 Subject: [PATCH] Remove unused arguments from APISelect widget --- netbox/dcim/forms.py | 10 ++++------ netbox/utilities/forms/widgets.py | 24 ++---------------------- 2 files changed, 6 insertions(+), 28 deletions(-) diff --git a/netbox/dcim/forms.py b/netbox/dcim/forms.py index 7824f0346..71e5bc10f 100644 --- a/netbox/dcim/forms.py +++ b/netbox/dcim/forms.py @@ -1686,9 +1686,9 @@ class DeviceForm(BootstrapMixin, TenancyForm, CustomFieldModelForm): help_text="The lowest-numbered unit occupied by the device", widget=APISelect( api_url='/api/dcim/racks/{{rack}}/elevation/', - disabled_indicator='device', - additional_query_params={ - 'face': '$face' + attrs={ + 'disabled-indicator': 'device', + 'data-additional-query-param-face': "[\"$face\"]", } ) ) @@ -2077,9 +2077,7 @@ class DeviceFilterForm(BootstrapMixin, LocalConfigContextFilterForm, TenancyFilt role = DynamicModelMultipleChoiceField( queryset=DeviceRole.objects.all(), to_field_name='slug', - required=False, - widget=APISelectMultiple( - ) + required=False ) manufacturer = DynamicModelMultipleChoiceField( queryset=Manufacturer.objects.all(), diff --git a/netbox/utilities/forms/widgets.py b/netbox/utilities/forms/widgets.py index 58aca97c7..fc4c83545 100644 --- a/netbox/utilities/forms/widgets.py +++ b/netbox/utilities/forms/widgets.py @@ -123,22 +123,9 @@ class APISelect(SelectWithDisabled): A select widget populated via an API call :param api_url: API endpoint URL. Required if not set automatically by the parent field. - :param display_field: (Optional) Field to display for child in selection list. Defaults to `name`. - :param disabled_indicator: (Optional) Mark option as disabled if this field equates true. - :param additional_query_params: Optional) A dict of query params to append to the API request. The key is the - name of the query param and the value if the query param's value. + :param full: Omit brief=true when fetching REST API results """ - def __init__( - self, - api_url=None, - display_field=None, - disabled_indicator=None, - additional_query_params=None, - full=False, - *args, - **kwargs - ): - + def __init__(self, api_url=None, full=False, *args, **kwargs): super().__init__(*args, **kwargs) self.attrs['class'] = 'netbox-select2-api' @@ -146,13 +133,6 @@ class APISelect(SelectWithDisabled): self.attrs['data-url'] = '/{}{}'.format(settings.BASE_PATH, api_url.lstrip('/')) # Inject BASE_PATH if full: self.attrs['data-full'] = full - if display_field: - self.attrs['display-field'] = display_field - if disabled_indicator: - self.attrs['disabled-indicator'] = disabled_indicator - if additional_query_params: - for key, value in additional_query_params.items(): - self.add_additional_query_param(key, value) def add_additional_query_param(self, name, value): """