diff --git a/auction/models.py b/auction/models.py index ee8af6d..f8146f4 100644 --- a/auction/models.py +++ b/auction/models.py @@ -1,6 +1,8 @@ from django.contrib.gis.db import models from django.utils import timezone from django.contrib.gis.db.models.functions import Distance +from django.dispatch import receiver +from django.db.models.signals import post_save from clients.models import ClientProfile from partners.models import Establishment, RoomCategory @@ -30,6 +32,7 @@ class Inquiry(models.Model): comment = models.TextField(null=True, blank=True) activated = models.DateTimeField(null=True, blank=True) bidding_end = models.DateTimeField(null=True, blank=True) + expiry = models.DateTimeField(null=True, blank=True) gateway = models.CharField(max_length=128, null=True, blank=True) @property @@ -89,4 +92,10 @@ class Offer(models.Model): @property def distance(self): - return self.inquiry.destination_coords.distance(self.roomcategory.establishment.coords) \ No newline at end of file + return self.inquiry.destination_coords.distance(self.roomcategory.establishment.coords) + +@receiver(post_save, sender=Inquiry) +def inquiry_expiry(sender, instance, created, **kwargs): + if not instance.expiry: + instance.expiry = min(inquiry.arrival, timezone.now() + timedelta(getValue("auction.payment_period", 168))) + instance.save() \ No newline at end of file diff --git a/templates/auction/offer_select.html b/templates/auction/offer_select.html index 70898b1..1328d7c 100644 --- a/templates/auction/offer_select.html +++ b/templates/auction/offer_select.html @@ -54,6 +54,23 @@ + +{% for offer in offer.object_set.all %} +