From 1783196a9c137d52fcfe033a97c7c09bf2cec140 Mon Sep 17 00:00:00 2001 From: Ludovic Stephan Date: Tue, 19 Dec 2017 12:41:50 +0100 Subject: [PATCH] Management view only deals with Revente objects Except for Revente creation, every form is now handled with revente objects, to use the display option in the previous commit. --- bda/forms.py | 34 +++++++++++++------------- bda/templates/bda/revente/manage.html | 16 ++++++------ bda/templates/bda/revente/tirages.html | 4 +-- bda/views.py | 20 +++++++-------- 4 files changed, 37 insertions(+), 37 deletions(-) diff --git a/bda/forms.py b/bda/forms.py index 14e91ce2..90b0359f 100644 --- a/bda/forms.py +++ b/bda/forms.py @@ -91,7 +91,8 @@ class ResellForm(forms.Form): class AnnulForm(forms.Form): - attributions = AttributionModelMultipleChoiceField( + reventes = ReventeModelMultipleChoiceField( + own=True, label='', queryset=Attribution.objects.none(), widget=forms.CheckboxSelectMultiple, @@ -99,14 +100,13 @@ class AnnulForm(forms.Form): def __init__(self, participant, *args, **kwargs): super(AnnulForm, self).__init__(*args, **kwargs) - self.fields['attributions'].queryset = ( - participant.attribution_set - .filter(spectacle__date__gte=timezone.now(), - revente__isnull=False, - revente__notif_sent=False, - revente__soldTo__isnull=True) - .select_related('spectacle', 'spectacle__location', - 'participant__user') + self.fields['reventes'].queryset = ( + participant.original_shows + .filter(attribution__spectacle__date__gte=timezone.now(), + notif_sent=False, + soldTo__isnull=True) + .select_related('attribution__spectacle', + 'attribution__spectacle__location') ) @@ -165,18 +165,18 @@ class ReventeTirageForm(forms.Form): class SoldForm(forms.Form): - attributions = AttributionModelMultipleChoiceField( + reventes = ReventeModelMultipleChoiceField( + own=True, label='', queryset=Attribution.objects.none(), widget=forms.CheckboxSelectMultiple) def __init__(self, participant, *args, **kwargs): super(SoldForm, self).__init__(*args, **kwargs) - self.fields['attributions'].queryset = ( - participant.attribution_set - .filter(revente__isnull=False, - revente__soldTo__isnull=False) - .exclude(revente__soldTo=participant) - .select_related('spectacle', 'spectacle__location', - 'participant__user') + self.fields['reventes'].queryset = ( + participant.original_shows + .filter(soldTo__isnull=False) + .exclude(soldTo=participant) + .select_related('attribution__spectacle', + 'attribution__spectacle__location') ) diff --git a/bda/templates/bda/revente/manage.html b/bda/templates/bda/revente/manage.html index 8162d55d..cf0ba80e 100644 --- a/bda/templates/bda/revente/manage.html +++ b/bda/templates/bda/revente/manage.html @@ -4,7 +4,7 @@ {% block realcontent %}

Gestion des places que je revends

-{% with resell_attributions=resellform.attributions annul_attributions=annulform.attributions sold_attributions=soldform.attributions %} +{% with resell_attributions=resellform.attributions annul_reventes=annulform.reventes sold_reventes=soldform.reventes %} {% if resellform.attributions %}
@@ -29,10 +29,10 @@
{% endif %} -{% if annul_attributions or overdue %} +{% if annul_reventes or overdue %}

Places en cours de revente

- {% if annul_attributions %} + {% if annul_reventes %}
Vous pouvez annuler les places mises en vente il y a moins d'une heure. @@ -42,8 +42,8 @@
    - {% for attrib in annul_attributions %} -
  • {{ attrib.tag }} {{ attrib.choice_label }}
  • + {% for revente in annul_reventes %} +
  • {{ revente.tag }} {{ revente.choice_label }}
  • {% endfor %} {% for attrib in overdue %}
  • @@ -54,7 +54,7 @@
- {% if annul_attributions %} + {% if annul_reventes %} {% endif %} @@ -62,7 +62,7 @@
{% endif %} -{% if sold_attributions %} +{% if sold_reventes %}

Places revendues

@@ -82,7 +82,7 @@ {% endif %} -{% if not resell_attributions and not annul_attributions and not overdue and not sold_attributions %} +{% if not resell_attributions and not annul_attributions and not overdue and not sold_reventes %}

Plus de reventes possibles !

{% endif %} diff --git a/bda/templates/bda/revente/tirages.html b/bda/templates/bda/revente/tirages.html index 91d39c90..b7017806 100644 --- a/bda/templates/bda/revente/tirages.html +++ b/bda/templates/bda/revente/tirages.html @@ -11,7 +11,7 @@
Vous pouvez vous désinscrire des reventes suivantes tant que le tirage n'a - pas eu lieu + pas eu lieu.
{% csrf_token %} @@ -34,7 +34,7 @@
- Vous pouvez vous inscrire aux tirage en cours suivants + Vous pouvez vous inscrire aux tirage en cours suivants.
{% csrf_token %} diff --git a/bda/views.py b/bda/views.py index 67fa2486..4cb35c52 100644 --- a/bda/views.py +++ b/bda/views.py @@ -401,18 +401,18 @@ def revente_manage(request, tirage_id): elif 'annul' in request.POST: annulform = AnnulForm(participant, request.POST, prefix='annul') if annulform.is_valid(): - attributions = annulform.cleaned_data["attributions"] - for attribution in attributions: - attribution.revente.delete() + reventes = annulform.cleaned_data["reventes"] + for revente in reventes: + revente.delete() # On confirme une vente en transférant la place à la personne qui a # gagné le tirage elif 'transfer' in request.POST: soldform = SoldForm(participant, request.POST, prefix='sold') if soldform.is_valid(): - attributions = soldform.cleaned_data['attributions'] - for attribution in attributions: - attribution.participant = attribution.revente.soldTo - attribution.save() + reventes = soldform.cleaned_data['reventes'] + for reventes in reventes: + revente.attribution.participant = revente.soldTo + revente.attribution.save() # On annule la revente après le tirage au sort (par exemple si # la personne qui a gagné le tirage ne se manifeste pas). La place est @@ -420,9 +420,9 @@ def revente_manage(request, tirage_id): elif 'reinit' in request.POST: soldform = SoldForm(participant, request.POST, prefix='sold') if soldform.is_valid(): - attributions = soldform.cleaned_data['attributions'] - for attribution in attributions: - if attribution.spectacle.date > timezone.now(): + reventes = soldform.cleaned_data['reventes'] + for revente in reventes: + if revente.attribution.spectacle.date > timezone.now(): # On antidate pour envoyer le mail plus vite new_date = (timezone.now() - SpectacleRevente.remorse_time)