Skip to content

Commit

Permalink
Fix custom css generation fail
Browse files Browse the repository at this point in the history
closes:: #12950
  • Loading branch information
meel-hd authored and nijel committed Nov 7, 2024
1 parent f7dc7d8 commit 61399c5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion weblate/configuration/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def test_cache(self) -> None:
def test_split_colors(self):
self.assertEqual([None, None], CustomCSSView.split_colors(""))
self.assertEqual([None, None], CustomCSSView.split_colors(None))
self.assertEqual(["#ffffff"], CustomCSSView.split_colors("#ffffff"))
self.assertEqual(["#ffffff", "#ffffff"], CustomCSSView.split_colors("#ffffff"))
self.assertEqual(
["#ffffff", "#000000"], CustomCSSView.split_colors("#ffffff,#000000")
)
7 changes: 6 additions & 1 deletion weblate/configuration/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,12 @@ class CustomCSSView(TemplateView):
@classmethod
def split_colors(cls, hex_color_string):
if hex_color_string:
return hex_color_string.split(",")
colors = hex_color_string.split(",")
if len(colors) == 1:
return [colors[0], colors[0]]
if len(colors) == 2:
return colors
return [None, None]
return [None, None]

@classmethod
Expand Down

0 comments on commit 61399c5

Please sign in to comment.