From 010ce0df3e1d64c6a6efdf30959a7b9c42c72594 Mon Sep 17 00:00:00 2001 From: Ludovic Stephan Date: Mon, 7 Jan 2019 15:27:41 +0100 Subject: [PATCH] Bugfixes : add staticfiles and typo --- bda/forms.py | 62 ++++++++++++------------ bda/templates/bda/revente/manage.html | 1 + bda/templates/bda/revente/subscribe.html | 1 - bda/templates/bda/revente/tirages.html | 1 - 4 files changed, 32 insertions(+), 33 deletions(-) diff --git a/bda/forms.py b/bda/forms.py index 02939de4..f3b41257 100644 --- a/bda/forms.py +++ b/bda/forms.py @@ -39,6 +39,36 @@ class TokenForm(forms.Form): token = forms.CharField(widget=forms.widgets.Textarea()) +class TemplateLabelField(forms.ModelMultipleChoiceField): + """ + Extends ModelMultipleChoiceField to offer two more customization options : + - `label_from_instance` can be used with a template file + - the widget rendering template can be specified with `option_template_name` + """ + + def __init__( + self, + label_template_name=None, + context_object_name="obj", + option_template_name=None, + *args, + **kwargs + ): + super().__init__(*args, **kwargs) + self.label_template_name = label_template_name + self.context_object_name = context_object_name + if option_template_name is not None: + self.widget.option_template_name = option_template_name + + def label_from_instance(self, obj): + if self.label_template_name is None: + return super().label_from_instance(obj) + else: + return loader.render_to_string( + self.label_template_name, context={self.context_object_name: obj} + ) + + class AttributionModelMultipleChoiceField(forms.ModelMultipleChoiceField): def label_from_instance(self, obj): return str(obj.spectacle) @@ -107,36 +137,6 @@ class AnnulForm(forms.Form): ) -class TemplateLabelField(forms.ModelMultipleChoiceField): - """ - Extends ModelMultipleChoiceField to offer two more customization options : - - `label_from_instance` can be used with a template file - - the widget rendering template can be specified with `option_template_name` - """ - - def __init__( - self, - label_template_name=None, - context_object_name="obj", - option_template_name=None, - *args, - **kwargs - ): - super().__init__(*args, **kwargs) - self.label_template_name = label_template_name - self.context_object_name = context_object_name - if option_template_name is not None: - self.widget.option_template_name = option_template_name - - def label_from_instance(self, obj): - if self.label_template_name is None: - return super().label_from_instance(obj) - else: - return loader.render_to_string( - self.label_template_name, context={self.context_object_name: obj} - ) - - class InscriptionReventeForm(forms.Form): def __init__(self, tirage, *args, **kwargs): super().__init__(*args, **kwargs) @@ -194,7 +194,7 @@ class ReventeTirageForm(forms.Form): class SoldForm(forms.Form): def __init__(self, participant, *args, **kwargs): super().__init__(*args, **kwargs) - self.fields["reventes"].queryset = ReventeModelMultipleChoiceField( + self.fields["reventes"] = ReventeModelMultipleChoiceField( own=True, label="", queryset=participant.original_shows.filter(soldTo__isnull=False) diff --git a/bda/templates/bda/revente/manage.html b/bda/templates/bda/revente/manage.html index 4f1d014e..ef468403 100644 --- a/bda/templates/bda/revente/manage.html +++ b/bda/templates/bda/revente/manage.html @@ -1,5 +1,6 @@ {% extends "base_title.html" %} {% load bootstrap %} +{% load staticfiles %} {% block realcontent %} diff --git a/bda/templates/bda/revente/subscribe.html b/bda/templates/bda/revente/subscribe.html index 8a9545eb..b26bc79e 100644 --- a/bda/templates/bda/revente/subscribe.html +++ b/bda/templates/bda/revente/subscribe.html @@ -42,7 +42,6 @@ value="S'inscrire pour les places sélectionnées"> -