mirror of
https://gitlab.crans.org/bde/nk20
synced 2025-06-11 04:17:33 +02:00
Fix de l'ajout d'équipe, le ColorWidget était défaillant
This commit is contained in:
parent
e88dbfd597
commit
136f636fda
@ -194,3 +194,4 @@ class BusTeamForm(forms.ModelForm):
|
||||
),
|
||||
"color": ColorWidget(),
|
||||
}
|
||||
# "color": ColorWidget(),
|
||||
|
18
apps/wei/migrations/0011_alter_weiclub_year.py
Normal file
18
apps/wei/migrations/0011_alter_weiclub_year.py
Normal file
@ -0,0 +1,18 @@
|
||||
# Generated by Django 4.2.21 on 2025-05-25 12:23
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('wei', '0010_remove_weiregistration_specific_diet'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='weiclub',
|
||||
name='year',
|
||||
field=models.PositiveIntegerField(default=2025, unique=True, verbose_name='year'),
|
||||
),
|
||||
]
|
@ -18,6 +18,8 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
||||
<div class="card-footer text-center">
|
||||
<a class="btn btn-primary btn-sm my-1" href="{% url 'wei:update_bus' pk=bus.pk %}"
|
||||
data-turbolinks="false">{% trans "Edit" %}</a>
|
||||
<a class="btn btn-primary btn-sm my-1" href="{% url 'wei:manage_bus' pk=bus.pk %}"
|
||||
data-turbolinks="false">{% trans "View" %}</a>
|
||||
<a class="btn btn-primary btn-sm my-1" href="{% url 'wei:add_team' pk=bus.pk %}"
|
||||
data-turbolinks="false">{% trans "Add team" %}</a>
|
||||
</div>
|
||||
|
@ -13,9 +13,17 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
||||
<div class="card-body">
|
||||
<form method="post">
|
||||
{% csrf_token %}
|
||||
{{ form.media }}
|
||||
{{ form|crispy }}
|
||||
<button class="btn btn-primary" type="submit">{% trans "Submit" %}</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
document.addEventListener("DOMContentLoaded", function () {
|
||||
if (window.jscolor && jscolor.install) {
|
||||
jscolor.install();
|
||||
}
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
@ -440,6 +440,13 @@ class BusTeamCreateView(ProtectQuerysetMixin, ProtectedCreateView):
|
||||
def get_success_url(self):
|
||||
self.object.refresh_from_db()
|
||||
return reverse_lazy("wei:manage_bus_team", kwargs={"pk": self.object.pk})
|
||||
|
||||
def get_template_names(self):
|
||||
names = super().get_template_names()
|
||||
return names
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class BusTeamUpdateView(ProtectQuerysetMixin, LoginRequiredMixin, UpdateView):
|
||||
@ -472,6 +479,13 @@ class BusTeamUpdateView(ProtectQuerysetMixin, LoginRequiredMixin, UpdateView):
|
||||
def get_success_url(self):
|
||||
self.object.refresh_from_db()
|
||||
return reverse_lazy("wei:manage_bus_team", kwargs={"pk": self.object.pk})
|
||||
|
||||
def get_template_names(self):
|
||||
names = super().get_template_names()
|
||||
return names
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class BusTeamManageView(ProtectQuerysetMixin, LoginRequiredMixin, DetailView):
|
||||
|
@ -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" %}>
|
Loading…
x
Reference in New Issue
Block a user