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:
@ -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
|
5
note_kfet/templates/colorfield/color.html
Normal file
5
note_kfet/templates/colorfield/color.html
Normal file
@ -0,0 +1,5 @@
|
||||
<input type="text"
|
||||
name="{{ widget.name }}"
|
||||
value="{{ widget.value }}"
|
||||
class="jscolor"
|
||||
{% include "django/forms/widgets/attrs.html" %}>
|
Reference in New Issue
Block a user