1
0
mirror of https://gitlab.crans.org/bde/nk20 synced 2025-06-21 18:08:21 +02:00

Fix de l'ajout d'équipe, le ColorWidget était défaillant

This commit is contained in:
Ehouarn
2025-05-25 23:31:09 +02:00
parent e88dbfd597
commit 136f636fda
7 changed files with 58 additions and 2 deletions

View File

@ -63,8 +63,16 @@ class ColorWidget(Widget):
def format_value(self, value):
if value is None:
value = 0xFFFFFF
return "#{:06X}".format(value)
if isinstance(value, str):
return value # Assume it's already a hex string like "#FFAA33"
try:
return "#{:06X}".format(value)
except Exception:
return "#FFFFFF"
def value_from_datadict(self, data, files, name):
val = super().value_from_datadict(data, files, name)
return int(val[1:], 16)
if val:
return int(val[1:], 16)
return None

View File

@ -0,0 +1,5 @@
<input type="text"
name="{{ widget.name }}"
value="{{ widget.value }}"
class="jscolor"
{% include "django/forms/widgets/attrs.html" %}>