mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Remove unused arguments from APISelect widget
This commit is contained in:
@ -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(),
|
||||
|
@ -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):
|
||||
"""
|
||||
|
Reference in New Issue
Block a user