From c9275c5ea0ac823bbffcb7e4d8f7d2636c765d6c Mon Sep 17 00:00:00 2001 From: Jean-Marie Favreau Date: Wed, 27 Nov 2024 12:25:59 +0100 Subject: [PATCH] on propose les tags uniquement dans la liste des existants: Fix #217 --- src/agenda_culturel/forms.py | 14 ++++++-- .../agenda_culturel/recurrentimport_form.html | 33 +++++++++++++++++++ 2 files changed, 44 insertions(+), 3 deletions(-) diff --git a/src/agenda_culturel/forms.py b/src/agenda_culturel/forms.py index 4a93e3e..fec1e18 100644 --- a/src/agenda_culturel/forms.py +++ b/src/agenda_culturel/forms.py @@ -159,12 +159,20 @@ class DynamicArrayWidgetTags(DynamicArrayWidget): class RecurrentImportForm(ModelForm): required_css_class = 'required' + defaultTags = MultipleChoiceField( + label=_("Tags"), + initial=None, + choices=[], + required=False + ) + class Meta: model = RecurrentImport fields = "__all__" - widgets = { - "defaultTags": DynamicArrayWidgetTags(), - } + + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + self.fields["defaultTags"].choices = Tag.get_tag_groups(all=True) class CategorisationRuleImportForm(ModelForm): diff --git a/src/agenda_culturel/templates/agenda_culturel/recurrentimport_form.html b/src/agenda_culturel/templates/agenda_culturel/recurrentimport_form.html index 6b3831b..6deebaa 100644 --- a/src/agenda_culturel/templates/agenda_culturel/recurrentimport_form.html +++ b/src/agenda_culturel/templates/agenda_culturel/recurrentimport_form.html @@ -6,6 +6,8 @@ {% block configurer-bouton %}{% endblock %} {% block entete_header %} + + @@ -26,4 +28,35 @@ + + {% endblock %} \ No newline at end of file