revente de revente + confirmation de transfert de places

This commit is contained in:
Ludovic Stephan 2016-09-05 02:29:49 +02:00
parent 0b40ebb6f7
commit 3bc9880db1
4 changed files with 80 additions and 13 deletions

View file

@ -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)