mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Merge branch 'develop' into develop-2.7
This commit is contained in:
@ -24,6 +24,7 @@ from .signals import purge_changelog
|
||||
__all__ = [
|
||||
'BaseScript',
|
||||
'BooleanVar',
|
||||
'ChoiceVar',
|
||||
'FileVar',
|
||||
'IntegerVar',
|
||||
'IPNetworkVar',
|
||||
@ -133,6 +134,27 @@ class BooleanVar(ScriptVariable):
|
||||
self.field_attrs['required'] = False
|
||||
|
||||
|
||||
class ChoiceVar(ScriptVariable):
|
||||
"""
|
||||
Select one of several predefined static choices, passed as a list of two-tuples. Example:
|
||||
|
||||
color = ChoiceVar(
|
||||
choices=(
|
||||
('#ff0000', 'Red'),
|
||||
('#00ff00', 'Green'),
|
||||
('#0000ff', 'Blue')
|
||||
)
|
||||
)
|
||||
"""
|
||||
form_field = forms.ChoiceField
|
||||
|
||||
def __init__(self, choices, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
# Set field choices
|
||||
self.field_attrs['choices'] = choices
|
||||
|
||||
|
||||
class ObjectVar(ScriptVariable):
|
||||
"""
|
||||
NetBox object representation. The provided QuerySet will determine the choices available.
|
||||
|
Reference in New Issue
Block a user