diff --git a/bda/forms.py b/bda/forms.py
index 60fdb0fd..0c886e0f 100644
--- a/bda/forms.py
+++ b/bda/forms.py
@@ -52,8 +52,8 @@ class ResellForm(forms.Form):
def __init__(self, participant, *args, **kwargs):
super(ResellForm, self).__init__(*args, **kwargs)
self.fields['attributions'].queryset = participant.attribution_set\
- .filter(spectacle__date__gte=timezone.now(),
- revente__isnull=True)
+ .filter(spectacle__date__gte=timezone.now())\
+ .exclude(revente__seller=participant)
class AnnulForm(forms.Form):
@@ -67,7 +67,8 @@ class AnnulForm(forms.Form):
self.fields['attributions'].queryset = participant.attribution_set\
.filter(spectacle__date__gte=timezone.now(),
revente__isnull=False,
- revente__date__gte=timezone.now()-timedelta(hours=1))
+ revente__date__gte=timezone.now()-timedelta(hours=1),
+ revente__seller=participant)
class InscriptionReventeForm(forms.Form):
diff --git a/bda/models.py b/bda/models.py
index c3621a45..428dbfb7 100644
--- a/bda/models.py
+++ b/bda/models.py
@@ -221,6 +221,8 @@ class SpectacleRevente(models.Model):
interested = models.ManyToManyField(Participant,
related_name="wanted",
blank=True)
+ seller = models.ForeignKey(Participant,
+ related_name="original_shows")
soldTo = models.ForeignKey(Participant, blank=True, null=True)
def get_expiration_time(self):
@@ -235,7 +237,7 @@ class SpectacleRevente(models.Model):
shotgun = property(get_shotgun)
def __str__(self):
- return "%s -- %s" % (self.attribution.participant.user,
+ return "%s -- %s" % (self.seller,
self.attribution.spectacle.title)
def send_notif(self):
@@ -261,7 +263,7 @@ class SpectacleRevente(models.Model):
def tirage(self):
inscrits = self.interested
spectacle = self.attribution.spectacle
- user = self.attribution.participant.user
+ seller = self.seller
if inscrits.exists():
idx = random.randint(0, inscrits.count() - 1)
winner = inscrits.all()[idx]
@@ -273,7 +275,7 @@ Tu peux contacter le vendeur à l'adresse %s.
Chaleureusement,
Le BdA""" % (spectacle.title, spectacle.date_no_seconds(),
- spectacle.location, spectacle.price, user.email)
+ spectacle.location, spectacle.price, seller.email)
mail.send_mail("BdA-Revente : %s" % spectacle.title,
mail_buyer, "bda@ens.fr", [winner.user.email],
@@ -286,5 +288,5 @@ Chaleureusement,
Le BdA""" % (spectacle.title, winner.user.get_full_name(), winner.user.email)
mail.send_mail("BdA-Revente : %s" % spectacle.title,
- mail_seller, "bda@ens.fr", [user.email],
+ mail_seller, "bda@ens.fr", [seller.email],
fail_silently=False)
diff --git a/bda/templates/bda-revente.html b/bda/templates/bda-revente.html
index 0a5cffb3..a5f64678 100644
--- a/bda/templates/bda-revente.html
+++ b/bda/templates/bda-revente.html
@@ -24,6 +24,7 @@
+{% if annulform.attributions or overdue %}