From 47c02d72afd5571809c10bfb2faffce813116a01 Mon Sep 17 00:00:00 2001 From: Ludovic Stephan Date: Mon, 7 Jan 2019 16:43:46 +0100 Subject: [PATCH] =?UTF-8?q?R=C3=A9organisation=20de=20`bda/forms`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Suppression de code mort, tri des formulaires Remove bootstrap forms loading --- bda/forms.py | 78 ++++++++++----------------- bda/templates/bda/revente/manage.html | 1 - 2 files changed, 28 insertions(+), 51 deletions(-) diff --git a/bda/forms.py b/bda/forms.py index ad163ceb..b370f3ae 100644 --- a/bda/forms.py +++ b/bda/forms.py @@ -69,37 +69,7 @@ class TemplateLabelField(forms.ModelMultipleChoiceField): ) -class AttributionModelMultipleChoiceField(forms.ModelMultipleChoiceField): - def label_from_instance(self, obj): - return str(obj.spectacle) - - -class ReventeModelMultipleChoiceField(forms.ModelMultipleChoiceField): - def __init__(self, *args, own=True, **kwargs): - super().__init__(*args, **kwargs) - self.own = own - - def label_from_instance(self, obj): - label = "{show}{suffix}" - suffix = "" - if self.own: - # C'est notre propre revente : informations sur le statut - if obj.soldTo is not None: - suffix = " -- Vendue à {firstname} {lastname}".format( - firstname=obj.soldTo.user.first_name, - lastname=obj.soldTo.user.last_name, - ) - elif obj.shotgun: - suffix = " -- Tirage infructueux" - elif obj.notif_sent: - suffix = " -- Inscriptions au tirage en cours" - else: - # Ce n'est pas à nous : on ne voit jamais l'acheteur - suffix = " -- Vendue par {firstname} {lastname}".format( - firstname=obj.seller.user.first_name, lastname=obj.seller.user.last_name - ) - - return label.format(show=str(obj.attribution.spectacle), suffix=suffix) +# Formulaires pour revente_manage class ResellForm(forms.Form): @@ -139,6 +109,26 @@ class AnnulForm(forms.Form): ) +class SoldForm(forms.Form): + def __init__(self, participant, *args, **kwargs): + super().__init__(*args, **kwargs) + self.fields["reventes"] = TemplateLabelField( + label="", + queryset=participant.original_shows.filter(soldTo__isnull=False) + .exclude(soldTo=participant) + .select_related( + "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", + ) + + +# Formulaire pour revente_subscribe + + class InscriptionReventeForm(forms.Form): def __init__(self, tirage, *args, **kwargs): super().__init__(*args, **kwargs) @@ -154,6 +144,9 @@ class InscriptionReventeForm(forms.Form): ) +# Formulaires pour revente_tirages + + class ReventeTirageAnnulForm(forms.Form): def __init__(self, participant, *args, **kwargs): super().__init__(*args, **kwargs) @@ -180,7 +173,10 @@ class ReventeTirageForm(forms.Form): self.fields["reventes"] = TemplateLabelField( queryset=( SpectacleRevente.objects.filter( - notif_sent=True, shotgun=False, tirage_done=False + notif_sent=True, + shotgun=False, + tirage_done=False, + attribution__spectacle__tirage=participant.tirage, ) .exclude(confirmed_entry=participant) .select_related("attribution__spectacle") @@ -191,21 +187,3 @@ class ReventeTirageForm(forms.Form): option_template_name="bda/forms/checkbox_table.html", context_object_name="revente", ) - - -class SoldForm(forms.Form): - def __init__(self, participant, *args, **kwargs): - super().__init__(*args, **kwargs) - self.fields["reventes"] = TemplateLabelField( - label="", - queryset=participant.original_shows.filter(soldTo__isnull=False) - .exclude(soldTo=participant) - .select_related( - "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/revente/manage.html b/bda/templates/bda/revente/manage.html index a092664b..4e69aef7 100644 --- a/bda/templates/bda/revente/manage.html +++ b/bda/templates/bda/revente/manage.html @@ -1,5 +1,4 @@ {% extends "base_title.html" %} -{% load bootstrap %} {% load staticfiles %} {% block realcontent %}