nautobot.apps.choices
¶
Utilities for implementing choices.
nautobot.apps.choices.BannerClassChoices
¶
nautobot.apps.choices.ButtonActionColorChoices
¶
Bases: ChoiceSet
Map standard button actions to Bootstrap color classes.
Source code in nautobot/core/choices.py
nautobot.apps.choices.ButtonActionIconChoices
¶
Bases: ChoiceSet
Map standard button actions to Material Design Icons classes.
Source code in nautobot/core/choices.py
nautobot.apps.choices.ChoiceSet
¶
Base class for defining choices for a model and/or menu.
Subclasses should define a CHOICES constant which consists of a list of tuples of the form (value, display_str)
,
or optionally as tuples of the form (grouping, ((value, display_str), (value, display_str), ...))
.
Example
Source code in nautobot/core/choices.py
nautobot.apps.choices.JobResultStatusChoices
¶
Bases: ChoiceSet
These status choices are using the same taxonomy as within Celery core. A Nautobot Job status is equivalent to a Celery task state.
Source code in nautobot/extras/choices.py
precedence(state)
staticmethod
¶
Get the precedence for a state. Lower index means higher precedence.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
state |
str
|
One of the status choices. |
required |
Returns:
Type | Description |
---|---|
int
|
Precedence value. |
Examples:
Source code in nautobot/extras/choices.py
nautobot.apps.choices.unpack_grouped_choices(choices)
¶
Unpack a grouped choices hierarchy into a flat list of two-tuples. For example:
choices = ( ('Foo', ( (1, 'A'), (2, 'B') )), ('Bar', ( (3, 'C'), (4, 'D') )) )
becomes:
choices = ( (1, 'A'), (2, 'B'), (3, 'C'), (4, 'D') )