Przeglądaj źródła

Fix tag background color

jeremystretch 4 lat temu
rodzic
commit
6604ebfd01

+ 1 - 1
netbox/netbox/tables/columns.py

@@ -217,7 +217,7 @@ class ChoiceFieldColumn(tables.Column):
 
 
         # Determine the background color to use (try calling object.get_FOO_color())
         # Determine the background color to use (try calling object.get_FOO_color())
         try:
         try:
-            bg_color = getattr(record, f'get_{bound_column.name}_color')()
+            bg_color = getattr(record, f'get_{bound_column.name}_color')() or self.DEFAULT_BG_COLOR
         except AttributeError:
         except AttributeError:
             bg_color = self.DEFAULT_BG_COLOR
             bg_color = self.DEFAULT_BG_COLOR
 
 

+ 2 - 2
netbox/utilities/templatetags/builtins/tags.py

@@ -19,7 +19,7 @@ def tag(value, viewname=None):
 
 
 
 
 @register.inclusion_tag('builtins/badge.html')
 @register.inclusion_tag('builtins/badge.html')
-def badge(value, bg_color='secondary', show_empty=False):
+def badge(value, bg_color=None, show_empty=False):
     """
     """
     Display the specified number as a badge.
     Display the specified number as a badge.
 
 
@@ -30,7 +30,7 @@ def badge(value, bg_color='secondary', show_empty=False):
     """
     """
     return {
     return {
         'value': value,
         'value': value,
-        'bg_color': bg_color,
+        'bg_color': bg_color or 'secondary',
         'show_empty': show_empty,
         'show_empty': show_empty,
     }
     }