Skip to content

Commit 80d200a

Browse files
committed
fixed colour validation
1 parent 2f56abd commit 80d200a

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

events/ui.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ def create(error: str | None = None) -> str | Response: # noqa: PLR0911
4646
flash(colour, "error")
4747
return redirect(url_for("events_ui.create"))
4848

49-
colour = color_colour if color_colour else text_colour
49+
# prefer text_colour if both are provided (in case these colours change)
50+
colour = text_colour if text_colour else color_colour
5051

5152
# parse dates and duration
5253
start_time = get_datetime_from_string(request.form["start_time"])

schema.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ def validate(self) -> str | None:
181181
# check if colour is valid
182182
colour_regex = re.compile(r"^#[0-9a-fA-F]{6}$")
183183
if self.colour and (
184-
not colour_regex.match(self.colour) or self.colour not in colours
184+
not colour_regex.match(self.colour) and self.colour not in colours
185185
):
186186
return "Colour must be a valid hex code or one of: " + ", ".join(colours)
187187

0 commit comments

Comments
 (0)