From 4dd229e73ae245e4e60706fbcae47f502d26293c Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Fri, 22 Sep 2023 08:46:42 -0400 Subject: [PATCH] Fixes #13864: Remove 'default' choice for dashboard widget color --- netbox/extras/choices.py | 36 ++++++++++++++++++++++++++++++++ netbox/extras/dashboard/forms.py | 4 ++-- 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/netbox/extras/choices.py b/netbox/extras/choices.py index 1061bf87110..0572a33a129 100644 --- a/netbox/extras/choices.py +++ b/netbox/extras/choices.py @@ -244,3 +244,39 @@ class ChangeActionChoices(ChoiceSet): (ACTION_UPDATE, _('Update'), 'blue'), (ACTION_DELETE, _('Delete'), 'red'), ) + + +# +# Dashboard widgets +# + +class DashboardWidgetColorChoices(ChoiceSet): + BLUE = 'blue' + INDIGO = 'indigo' + PURPLE = 'purple' + PINK = 'pink' + RED = 'red' + ORANGE = 'orange' + YELLOW = 'yellow' + GREEN = 'green' + TEAL = 'teal' + CYAN = 'cyan' + GRAY = 'gray' + BLACK = 'black' + WHITE = 'white' + + CHOICES = ( + (BLUE, _('Blue')), + (INDIGO, _('Indigo')), + (PURPLE, _('Purple')), + (PINK, _('Pink')), + (RED, _('Red')), + (ORANGE, _('Orange')), + (YELLOW, _('Yellow')), + (GREEN, _('Green')), + (TEAL, _('Teal')), + (CYAN, _('Cyan')), + (GRAY, _('Gray')), + (BLACK, _('Black')), + (WHITE, _('White')), + ) diff --git a/netbox/extras/dashboard/forms.py b/netbox/extras/dashboard/forms.py index 1e9f15408f1..ab708228c8e 100644 --- a/netbox/extras/dashboard/forms.py +++ b/netbox/extras/dashboard/forms.py @@ -2,9 +2,9 @@ from django.urls import reverse_lazy from django.utils.translation import gettext as _ +from extras.choices import DashboardWidgetColorChoices from netbox.registry import registry from utilities.forms import BootstrapMixin, add_blank_choice -from utilities.choices import ButtonColorChoices __all__ = ( 'DashboardWidgetAddForm', @@ -21,7 +21,7 @@ class DashboardWidgetForm(BootstrapMixin, forms.Form): required=False ) color = forms.ChoiceField( - choices=add_blank_choice(ButtonColorChoices), + choices=add_blank_choice(DashboardWidgetColorChoices), required=False, )