فهرست منبع

Modify script ObjectVars to use DynamicModelChoiceFields

dansheps 5 سال پیش
والد
کامیت
0995e10d87
2فایلهای تغییر یافته به همراه6 افزوده شده و 8 حذف شده
  1. 4 4
      netbox/extras/scripts.py
  2. 2 4
      netbox/extras/tests/test_scripts.py

+ 4 - 4
netbox/extras/scripts.py

@@ -170,8 +170,8 @@ class ObjectVar(ScriptVariable):
     """
     form_field = DynamicModelChoiceField
 
-    def __init__(self, queryset, widget, *args, **kwargs):
-        super().__init__(widget=widget, *args, **kwargs)
+    def __init__(self, queryset, *args, **kwargs):
+        super().__init__(*args, **kwargs)
 
         # Queryset for field choices
         self.field_attrs['queryset'] = queryset
@@ -187,8 +187,8 @@ class MultiObjectVar(ScriptVariable):
     """
     form_field = DynamicModelMultipleChoiceField
 
-    def __init__(self, queryset, widget, *args, **kwargs):
-        super().__init__(widget=widget, *args, **kwargs)
+    def __init__(self, queryset, *args, **kwargs):
+        super().__init__(*args, **kwargs)
 
         # Queryset for field choices
         self.field_attrs['queryset'] = queryset

+ 2 - 4
netbox/extras/tests/test_scripts.py

@@ -130,8 +130,7 @@ class ScriptVariablesTest(TestCase):
         class TestScript(Script):
 
             var1 = ObjectVar(
-                queryset=DeviceRole.objects.all(),
-                widget=APISelect(api_url='/api/dcim/device-roles/')
+                queryset=DeviceRole.objects.all()
             )
 
         # Populate some objects
@@ -152,8 +151,7 @@ class ScriptVariablesTest(TestCase):
         class TestScript(Script):
 
             var1 = MultiObjectVar(
-                queryset=DeviceRole.objects.all(),
-                widget=APISelectMultiple(api_url='/api/dcim/device-roles/')
+                queryset=DeviceRole.objects.all()
             )
 
         # Populate some objects