diff --git a/bda/models.py b/bda/models.py index b0dd8aeb..1e80b248 100644 --- a/bda/models.py +++ b/bda/models.py @@ -185,7 +185,8 @@ class Attribution(models.Model): @python_2_unicode_compatible class SpectacleRevente(models.Model): - attribution = models.OneToOneField(Attribution) + attribution = models.OneToOneField(Attribution, + related_name="revente") date = models.DateTimeField("Date de mise en vente", default=timezone.now) sold = models.BooleanField("Vendue", default=False) @@ -194,13 +195,17 @@ class SpectacleRevente(models.Model): remaining_time = (self.attribution.spectacle.date - self.date) delay = max(datetime.timedelta(hours=2), min(remaining_time//2, datetime.timedelta(days=2))) - return self.date + delay + return self.date + delay + datetime.timedelta(hours=1) expiration_time = property(get_expiration_time) def get_shotgun(self): return timezone.now() > self.expiration_time shotgun = property(get_shotgun) + def get_cancellable(self): + return timezone.now() < self.date + datetime.timedelta(hours=1) + cancellable = property(get_cancellable) + def __str__(self): return "%s -- %s" % (self.attribution.participant.user, self.attribution.spectacle.title) diff --git a/bda/templates/bda-revente.html b/bda/templates/bda-revente.html index 9527a28b..16fbc0e2 100644 --- a/bda/templates/bda-revente.html +++ b/bda/templates/bda-revente.html @@ -16,14 +16,18 @@ {%endif%} +{% if resell %}