diff --git a/bda/forms.py b/bda/forms.py index f3b41257..ad163ceb 100644 --- a/bda/forms.py +++ b/bda/forms.py @@ -103,27 +103,26 @@ class ReventeModelMultipleChoiceField(forms.ModelMultipleChoiceField): class ResellForm(forms.Form): - attributions = AttributionModelMultipleChoiceField( - label="", - queryset=Attribution.objects.none(), - widget=forms.CheckboxSelectMultiple, - required=False, - ) - def __init__(self, participant, *args, **kwargs): super().__init__(*args, **kwargs) - self.fields["attributions"].queryset = ( - participant.attribution_set.filter(spectacle__date__gte=timezone.now()) + self.fields["attributions"] = TemplateLabelField( + queryset=participant.attribution_set.filter( + spectacle__date__gte=timezone.now() + ) .exclude(revente__seller=participant) - .select_related("spectacle", "spectacle__location", "participant__user") + .select_related("spectacle", "spectacle__location", "participant__user"), + widget=forms.CheckboxSelectMultiple, + required=False, + label_template_name="bda/forms/attribution_label_table.html", + option_template_name="bda/forms/checkbox_table.html", + context_object_name="attribution", ) class AnnulForm(forms.Form): def __init__(self, participant, *args, **kwargs): super().__init__(*args, **kwargs) - self.fields["reventes"] = ReventeModelMultipleChoiceField( - own=True, + self.fields["reventes"] = TemplateLabelField( label="", queryset=participant.original_shows.filter( attribution__spectacle__date__gte=timezone.now(), soldTo__isnull=True @@ -134,6 +133,9 @@ class AnnulForm(forms.Form): .order_by("-date"), widget=forms.CheckboxSelectMultiple, required=False, + label_template_name="bda/forms/revente_self_label_table.html", + option_template_name="bda/forms/checkbox_table.html", + context_object_name="revente", ) @@ -194,8 +196,7 @@ class ReventeTirageForm(forms.Form): class SoldForm(forms.Form): def __init__(self, participant, *args, **kwargs): super().__init__(*args, **kwargs) - self.fields["reventes"] = ReventeModelMultipleChoiceField( - own=True, + self.fields["reventes"] = TemplateLabelField( label="", queryset=participant.original_shows.filter(soldTo__isnull=False) .exclude(soldTo=participant) @@ -203,5 +204,8 @@ class SoldForm(forms.Form): "attribution__spectacle", "attribution__spectacle__location" ), widget=forms.CheckboxSelectMultiple, + label_template_name="bda/forms/revente_sold_label_table.html", + option_template_name="bda/forms/checkbox_table.html", + context_object_name="revente", ) diff --git a/bda/templates/bda/forms/attribution_label_table.html b/bda/templates/bda/forms/attribution_label_table.html new file mode 100644 index 00000000..d47af32d --- /dev/null +++ b/bda/templates/bda/forms/attribution_label_table.html @@ -0,0 +1,6 @@ +{% with spectacle=attribution.spectacle %} +
+ | Titre | +Date | +Lieu | +Prix | +Tirage le | +
---|