mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-24 17:38:37 -06:00
Fixes: #4255 - Add new script variable types based on dynamic model fields
This commit is contained in:
parent
d9dcc92300
commit
d0bd1ad25b
@ -18,6 +18,7 @@ from ipam.formfields import IPAddressFormField, IPNetworkFormField
|
|||||||
from ipam.validators import MaxPrefixLengthValidator, MinPrefixLengthValidator, prefix_validator
|
from ipam.validators import MaxPrefixLengthValidator, MinPrefixLengthValidator, prefix_validator
|
||||||
from .constants import LOG_DEFAULT, LOG_FAILURE, LOG_INFO, LOG_SUCCESS, LOG_WARNING
|
from .constants import LOG_DEFAULT, LOG_FAILURE, LOG_INFO, LOG_SUCCESS, LOG_WARNING
|
||||||
from utilities.exceptions import AbortTransaction
|
from utilities.exceptions import AbortTransaction
|
||||||
|
from utilities.forms import DynamicModelChoiceField, DynamicModelMultipleChoiceField
|
||||||
from .forms import ScriptForm
|
from .forms import ScriptForm
|
||||||
from .signals import purge_changelog
|
from .signals import purge_changelog
|
||||||
|
|
||||||
@ -197,6 +198,20 @@ class MultiObjectVar(ScriptVariable):
|
|||||||
self.form_field = TreeNodeMultipleChoiceField
|
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):
|
class FileVar(ScriptVariable):
|
||||||
"""
|
"""
|
||||||
An uploaded file.
|
An uploaded file.
|
||||||
|
Loading…
Reference in New Issue
Block a user