mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Remove second variables, make widget mandatory on ObjectVar and MultiObjectVar
This commit is contained in:
@ -26,8 +26,6 @@ __all__ = [
|
||||
'BaseScript',
|
||||
'BooleanVar',
|
||||
'ChoiceVar',
|
||||
'DynamicObjectVar',
|
||||
'DynamicMultiObjectVar',
|
||||
'FileVar',
|
||||
'IntegerVar',
|
||||
'IPAddressVar',
|
||||
@ -170,10 +168,10 @@ class ObjectVar(ScriptVariable):
|
||||
"""
|
||||
NetBox object representation. The provided QuerySet will determine the choices available.
|
||||
"""
|
||||
form_field = forms.ModelChoiceField
|
||||
form_field = DynamicModelChoiceField
|
||||
|
||||
def __init__(self, queryset, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
def __init__(self, queryset, widget, *args, **kwargs):
|
||||
super().__init__(widget=widget, *args, **kwargs)
|
||||
|
||||
# Queryset for field choices
|
||||
self.field_attrs['queryset'] = queryset
|
||||
@ -187,10 +185,10 @@ class MultiObjectVar(ScriptVariable):
|
||||
"""
|
||||
Like ObjectVar, but can represent one or more objects.
|
||||
"""
|
||||
form_field = forms.ModelMultipleChoiceField
|
||||
form_field = DynamicModelMultipleChoiceField
|
||||
|
||||
def __init__(self, queryset, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
def __init__(self, queryset, widget, *args, **kwargs):
|
||||
super().__init__(widget=widget, *args, **kwargs)
|
||||
|
||||
# Queryset for field choices
|
||||
self.field_attrs['queryset'] = queryset
|
||||
@ -200,20 +198,6 @@ class MultiObjectVar(ScriptVariable):
|
||||
self.form_field = TreeNodeMultipleChoiceField
|
||||
|
||||
|
||||
class DynamicObjectVar(ObjectVar):
|
||||
"""
|
||||
A dynamic netbox object variable. APISelect will determine the available choices
|
||||
"""
|
||||
form_field = DynamicModelChoiceField
|
||||
|
||||
|
||||
class DynamicMultiObjectVar(MultiObjectVar):
|
||||
"""
|
||||
A multiple choice version of DynamicObjectVar
|
||||
"""
|
||||
form_field = DynamicModelMultipleChoiceField
|
||||
|
||||
|
||||
class FileVar(ScriptVariable):
|
||||
"""
|
||||
An uploaded file.
|
||||
|
Reference in New Issue
Block a user