From f66a54bb73201de5a0997b132b015052d690f1a5 Mon Sep 17 00:00:00 2001 From: Ludovic Stephan Date: Mon, 7 Jan 2019 16:24:30 +0100 Subject: [PATCH] Prettify `revente/manage` --- bda/forms.py | 32 +++--- .../bda/forms/attribution_label_table.html | 6 ++ .../bda/forms/revente_self_label_table.html | 7 ++ .../bda/forms/revente_sold_label_table.html | 7 ++ bda/templates/bda/revente/manage.html | 97 ++++++++++++------- 5 files changed, 101 insertions(+), 48 deletions(-) create mode 100644 bda/templates/bda/forms/attribution_label_table.html create mode 100644 bda/templates/bda/forms/revente_self_label_table.html create mode 100644 bda/templates/bda/forms/revente_sold_label_table.html 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 %} +{{ spectacle.title }} +{{ spectacle.date }} +{{ spectacle.location }} +{{ spectacle.price |floatformat }}€ +{% endwith %} \ No newline at end of file diff --git a/bda/templates/bda/forms/revente_self_label_table.html b/bda/templates/bda/forms/revente_self_label_table.html new file mode 100644 index 00000000..26700ee9 --- /dev/null +++ b/bda/templates/bda/forms/revente_self_label_table.html @@ -0,0 +1,7 @@ +{% with spectacle=revente.attribution.spectacle %} +{{ spectacle.title }} +{{ spectacle.date }} +{{ spectacle.location }} +{{ spectacle.price |floatformat }}€ +{% if revente.tirage_done %}Tirage infructueux{% else %}{{ revente.date_tirage }}{% endif %} +{% endwith %} \ No newline at end of file diff --git a/bda/templates/bda/forms/revente_sold_label_table.html b/bda/templates/bda/forms/revente_sold_label_table.html new file mode 100644 index 00000000..92b83c44 --- /dev/null +++ b/bda/templates/bda/forms/revente_sold_label_table.html @@ -0,0 +1,7 @@ +{% with spectacle=revente.attribution.spectacle user=revente.soldTo.user %} +{{ spectacle.title }} +{{ spectacle.date }} +{{ spectacle.location }} +{{ spectacle.price |floatformat }}€ +{{user.first_name}} {{user.last_name}} +{% endwith %} \ No newline at end of file diff --git a/bda/templates/bda/revente/manage.html b/bda/templates/bda/revente/manage.html index ef468403..45654960 100644 --- a/bda/templates/bda/revente/manage.html +++ b/bda/templates/bda/revente/manage.html @@ -11,19 +11,30 @@

Places non revendues

-
- - Cochez les places que vous souhaitez revendre, et validez. Vous aurez - ensuite 1h pour changer d'avis avant que la revente soit confirmée et - que les notifications soient envoyées aux intéressé·e·s. -
-
- {% csrf_token %} - {{ resellform|bootstrap }} -
-
- -
+
+ + Cochez les places que vous souhaitez revendre, et validez. Vous aurez + ensuite 1h pour changer d'avis avant que la revente soit confirmée et + que les notifications soient envoyées aux intéressé·e·s. +
+ {% csrf_token %} + + + + + + + + + + + + {% for checkbox in resellform.attributions %}{{ checkbox }}{% endfor %} + +
TitreLieuDatePrix
+
+ +

@@ -37,15 +48,21 @@ Vous pouvez annuler les reventes qui n'ont pas encore trouvé preneur·se. {% csrf_token %} -
-
-
    - {% for revente in annul_reventes %} -
  • {{ revente.tag }} {{ revente.choice_label }}
  • - {% endfor %} -
-
-
+ + + + + + + + + + + + + {% for checkbox in annulform.reventes %}{{ checkbox }}{% endfor %} + +
TitreDateLieuPrixTirage le
@@ -55,19 +72,31 @@ {% if sold_exists %}

Places revendues

-
- - Pour chaque revente, vous devez soit l'annuler soit la confirmer pour - transférer la place la place à la personne tirée au sort. +
+ + Pour chaque revente, vous devez soit l'annuler soit la confirmer pour + transférer la place la place à la personne tirée au sort. - L'annulation sert par exemple à pouvoir remettre la place en jeu si - vous ne parvenez pas à entrer en contact avec la personne tirée au - sort. -
-
- {% csrf_token %} - {{ soldform|bootstrap }} -
+ L'annulation sert par exemple à pouvoir remettre la place en jeu si + vous ne parvenez pas à entrer en contact avec la personne tirée au + sort. +
+ {% csrf_token %} + + + + + + + + + + + + + {% for checkbox in soldform.reventes %}{{ checkbox }}{% endfor %} + +
TitreDateLieuPrixVendue à