forked from DGNum/gestioCOF
Réorganisation de bda/forms
Suppression de code mort, tri des formulaires Remove bootstrap forms loading
This commit is contained in:
parent
ae0abb5cb3
commit
47c02d72af
2 changed files with 28 additions and 51 deletions
78
bda/forms.py
78
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",
|
||||
)
|
||||
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
{% extends "base_title.html" %}
|
||||
{% load bootstrap %}
|
||||
{% load staticfiles %}
|
||||
|
||||
{% block realcontent %}
|
||||
|
|
Loading…
Reference in a new issue