mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-14 01:41:22 -06:00
Closes #8794: Support dynamic configuration for JournalEntry kinds
This commit is contained in:
parent
48dc76a694
commit
ca44a654a5
@ -207,6 +207,7 @@ The following model fields support configurable choices:
|
||||
* `dcim.PowerFeed.status`
|
||||
* `dcim.Rack.status`
|
||||
* `dcim.Site.status`
|
||||
* `extras.JournalEntry.kind`
|
||||
* `ipam.IPAddress.status`
|
||||
* `ipam.IPRange.status`
|
||||
* `ipam.Prefix.status`
|
||||
|
@ -161,13 +161,16 @@ class StatusChoices(ChoiceSet):
|
||||
STATUS_BAR = 'bar'
|
||||
STATUS_BAZ = 'baz'
|
||||
|
||||
CHOICES = (
|
||||
CHOICES = [
|
||||
(STATUS_FOO, 'Foo', 'red'),
|
||||
(STATUS_BAR, 'Bar', 'green'),
|
||||
(STATUS_BAZ, 'Baz', 'blue'),
|
||||
)
|
||||
]
|
||||
```
|
||||
|
||||
!!! warning
|
||||
For dynamic configuration to work properly, `CHOICES` must be a mutable list, rather than a tuple.
|
||||
|
||||
```python
|
||||
# models.py
|
||||
from django.db import models
|
||||
|
@ -83,18 +83,19 @@ class ObjectChangeActionChoices(ChoiceSet):
|
||||
#
|
||||
|
||||
class JournalEntryKindChoices(ChoiceSet):
|
||||
key = 'JournalEntry.kind'
|
||||
|
||||
KIND_INFO = 'info'
|
||||
KIND_SUCCESS = 'success'
|
||||
KIND_WARNING = 'warning'
|
||||
KIND_DANGER = 'danger'
|
||||
|
||||
CHOICES = (
|
||||
CHOICES = [
|
||||
(KIND_INFO, 'Info', 'cyan'),
|
||||
(KIND_SUCCESS, 'Success', 'green'),
|
||||
(KIND_WARNING, 'Warning', 'yellow'),
|
||||
(KIND_DANGER, 'Danger', 'red'),
|
||||
)
|
||||
]
|
||||
|
||||
|
||||
#
|
||||
|
Loading…
Reference in New Issue
Block a user