diff --git a/bda/forms.py b/bda/forms.py index 4560d3e5..94a52128 100644 --- a/bda/forms.py +++ b/bda/forms.py @@ -52,12 +52,16 @@ class ReventeModelMultipleChoiceField(forms.ModelMultipleChoiceField): label = "{show}{suffix}" suffix = "" if self.own: - # C'est notre propre revente : pas besoin de spécifier le vendeur + # 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( @@ -95,11 +99,15 @@ class AnnulForm(forms.Form): def __init__(self, participant, *args, **kwargs): super().__init__(*args, **kwargs) - 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") + self.fields["reventes"].queryset = ( + participant.original_shows.filter( + attribution__spectacle__date__gte=timezone.now(), soldTo__isnull=True + ) + .select_related( + "attribution__spectacle", "attribution__spectacle__location" + ) + .order_by("-date") + ) class InscriptionReventeForm(forms.Form): diff --git a/bda/templates/bda/revente/manage.html b/bda/templates/bda/revente/manage.html index cf0ba80e..5147ff16 100644 --- a/bda/templates/bda/revente/manage.html +++ b/bda/templates/bda/revente/manage.html @@ -6,7 +6,7 @@

Gestion des places que je revends

{% with resell_attributions=resellform.attributions annul_reventes=annulform.reventes sold_reventes=soldform.reventes %} -{% if resellform.attributions %} +{% if resell_attributions %}

Places non revendues

@@ -29,34 +29,24 @@
{% endif %} -{% if annul_reventes or overdue %} +{% if annul_reventes %}

Places en cours de revente

- {% if annul_reventes %} -
- - Vous pouvez annuler les places mises en vente il y a moins d'une heure. -
- {% endif %} - {% csrf_token %} -
-
-
    - {% for revente in annul_reventes %} -
  • {{ revente.tag }} {{ revente.choice_label }}
  • - {% endfor %} - {% for attrib in overdue %} -
  • - - {{ attrib.spectacle }} -
  • - {% endfor %} -
-
-
- {% if annul_reventes %} - - {% endif %} +
+ + 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 %} +
+
+
+

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

Plus de reventes possibles !

{% endif %} diff --git a/bda/views.py b/bda/views.py index cbad0b1b..050d6851 100644 --- a/bda/views.py +++ b/bda/views.py @@ -12,7 +12,7 @@ from django.contrib.auth.decorators import login_required from django.core import serializers from django.core.urlresolvers import reverse from django.db import transaction -from django.db.models import Count, Prefetch, Q +from django.db.models import Count, Prefetch from django.forms.models import inlineformset_factory from django.http import HttpResponseBadRequest, HttpResponseRedirect, JsonResponse from django.shortcuts import get_object_or_404, render @@ -445,19 +445,11 @@ def revente_manage(request, tirage_id): new_date = timezone.now() - SpectacleRevente.remorse_time revente.reset(new_date=new_date) - overdue = participant.attribution_set.filter( - spectacle__date__gte=timezone.now(), - revente__isnull=False, - revente__seller=participant, - revente__notif_sent=True, - ).filter(Q(revente__soldTo__isnull=True) | Q(revente__soldTo=participant)) - return render( request, "bda/revente/manage.html", { "tirage": tirage, - "overdue": overdue, "soldform": soldform, "annulform": annulform, "resellform": resellform,