Просмотр исходного кода

Remove unused arguments from APISelect widget

Jeremy Stretch 5 лет назад
Родитель
Сommit
9e14e28d89
2 измененных файлов с 7 добавлено и 29 удалено
  1. 4 6
      netbox/dcim/forms.py
  2. 3 23
      netbox/utilities/forms/widgets.py

+ 4 - 6
netbox/dcim/forms.py

@@ -1686,9 +1686,9 @@ class DeviceForm(BootstrapMixin, TenancyForm, CustomFieldModelForm):
         help_text="The lowest-numbered unit occupied by the device",
         help_text="The lowest-numbered unit occupied by the device",
         widget=APISelect(
         widget=APISelect(
             api_url='/api/dcim/racks/{{rack}}/elevation/',
             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(
     role = DynamicModelMultipleChoiceField(
         queryset=DeviceRole.objects.all(),
         queryset=DeviceRole.objects.all(),
         to_field_name='slug',
         to_field_name='slug',
-        required=False,
-        widget=APISelectMultiple(
-        )
+        required=False
     )
     )
     manufacturer = DynamicModelMultipleChoiceField(
     manufacturer = DynamicModelMultipleChoiceField(
         queryset=Manufacturer.objects.all(),
         queryset=Manufacturer.objects.all(),

+ 3 - 23
netbox/utilities/forms/widgets.py

@@ -123,22 +123,9 @@ class APISelect(SelectWithDisabled):
     A select widget populated via an API call
     A select widget populated via an API call
 
 
     :param api_url: API endpoint URL. Required if not set automatically by the parent field.
     :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.
-    """
-    def __init__(
-        self,
-        api_url=None,
-        display_field=None,
-        disabled_indicator=None,
-        additional_query_params=None,
-        full=False,
-        *args,
-        **kwargs
-    ):
-
+    :param full: Omit brief=true when fetching REST API results
+    """
+    def __init__(self, api_url=None, full=False, *args, **kwargs):
         super().__init__(*args, **kwargs)
         super().__init__(*args, **kwargs)
 
 
         self.attrs['class'] = 'netbox-select2-api'
         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
             self.attrs['data-url'] = '/{}{}'.format(settings.BASE_PATH, api_url.lstrip('/'))  # Inject BASE_PATH
         if full:
         if full:
             self.attrs['data-full'] = 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):
     def add_additional_query_param(self, name, value):
         """
         """