Browse Source

Clean up & expand button color choices

jeremystretch 4 năm trước cách đây
mục cha
commit
9f53497e39
3 tập tin đã thay đổi với 31 bổ sung41 xóa
  1. 6 29
      netbox/extras/choices.py
  2. 1 1
      netbox/extras/models/models.py
  3. 24 11
      netbox/utilities/choices.py

+ 6 - 29
netbox/extras/choices.py

@@ -1,4 +1,4 @@
-from utilities.choices import ChoiceSet
+from utilities.choices import ButtonColorChoices, ChoiceSet
 
 
 #
@@ -47,36 +47,13 @@ class CustomFieldFilterLogicChoices(ChoiceSet):
 # CustomLinks
 #
 
-class CustomLinkButtonClassChoices(ChoiceSet):
-
-    CLASS_DEFAULT = 'outline-dark'
-    CLASS_LINK = 'ghost-dark'
-    CLASS_BLUE = 'blue'
-    CLASS_INDIGO = 'indigo'
-    CLASS_PURPLE = 'purple'
-    CLASS_PINK = 'pink'
-    CLASS_RED = 'red'
-    CLASS_ORANGE = 'orange'
-    CLASS_YELLOW = 'yellow'
-    CLASS_GREEN = 'green'
-    CLASS_TEAL = 'teal'
-    CLASS_CYAN = 'cyan'
-    CLASS_GRAY = 'secondary'
+class CustomLinkButtonClassChoices(ButtonColorChoices):
+
+    LINK = 'ghost-dark'
 
     CHOICES = (
-        (CLASS_DEFAULT, 'Default'),
-        (CLASS_LINK, 'Link'),
-        (CLASS_BLUE, 'Blue'),
-        (CLASS_INDIGO, 'Indigo'),
-        (CLASS_PURPLE, 'Purple'),
-        (CLASS_PINK, 'Pink'),
-        (CLASS_RED, 'Red'),
-        (CLASS_ORANGE, 'Orange'),
-        (CLASS_YELLOW, 'Yellow'),
-        (CLASS_GREEN, 'Green'),
-        (CLASS_TEAL, 'Teal'),
-        (CLASS_CYAN, 'Cyan'),
-        (CLASS_GRAY, 'Gray'),
+        *ButtonColorChoices.CHOICES,
+        (LINK, 'Link'),
     )
 
 #

+ 1 - 1
netbox/extras/models/models.py

@@ -212,7 +212,7 @@ class CustomLink(ChangeLoggedModel):
     button_class = models.CharField(
         max_length=30,
         choices=CustomLinkButtonClassChoices,
-        default=CustomLinkButtonClassChoices.CLASS_DEFAULT,
+        default=CustomLinkButtonClassChoices.DEFAULT,
         help_text="The class of the first link in a group will be used for the dropdown button"
     )
     new_window = models.BooleanField(

+ 24 - 11
netbox/utilities/choices.py

@@ -161,21 +161,34 @@ class ButtonColorChoices(ChoiceSet):
     Map standard button color choices to Bootstrap 3 button classes
     """
     DEFAULT = 'outline-dark'
-    BLUE = 'primary'
-    CYAN = 'info'
-    GREEN = 'success'
-    RED = 'danger'
-    YELLOW = 'warning'
-    GREY = 'secondary'
-    BLACK = 'dark'
+    BLUE = 'blue'
+    INDIGO = 'indigo'
+    PURPLE = 'purple'
+    PINK = 'pink'
+    RED = 'red'
+    ORANGE = 'orange'
+    YELLOW = 'yellow'
+    GREEN = 'green'
+    TEAL = 'teal'
+    CYAN = 'cyan'
+    GRAY = 'gray'
+    GREY = 'gray'  # Backward compatability for <3.2
+    BLACK = 'black'
+    WHITE = 'white'
 
     CHOICES = (
         (DEFAULT, 'Default'),
         (BLUE, 'Blue'),
-        (CYAN, 'Cyan'),
-        (GREEN, 'Green'),
+        (INDIGO, 'Indigo'),
+        (PURPLE, 'Purple'),
+        (PINK, 'Pink'),
         (RED, 'Red'),
+        (ORANGE, 'Orange'),
         (YELLOW, 'Yellow'),
-        (GREY, 'Grey'),
-        (BLACK, 'Black')
+        (GREEN, 'Green'),
+        (TEAL, 'Teal'),
+        (CYAN, 'Cyan'),
+        (GRAY, 'Gray'),
+        (BLACK, 'Black'),
+        (WHITE, 'White'),
     )