diff --git a/auction/models.py b/auction/models.py index 42d773c..ee8af6d 100644 --- a/auction/models.py +++ b/auction/models.py @@ -1,12 +1,13 @@ from django.contrib.gis.db import models from django.utils import timezone -from django.conf import settings from django.contrib.gis.db.models.functions import Distance from clients.models import ClientProfile from partners.models import Establishment, RoomCategory -from dateutil.relativedelta import relativedelta +from dbsettings.functions import getValue + +from datetime import timedelta import uuid @@ -28,6 +29,7 @@ class Inquiry(models.Model): children = models.IntegerField() comment = models.TextField(null=True, blank=True) activated = models.DateTimeField(null=True, blank=True) + bidding_end = models.DateTimeField(null=True, blank=True) gateway = models.CharField(max_length=128, null=True, blank=True) @property @@ -37,15 +39,18 @@ class Inquiry(models.Model): return self.invoice.is_paid + def activate(self): + if self.activated: + return False + + self.activated = timezone.now() + self.bidding_end = self.activated + timedelta(hours=getValue("auction.bidding_period", 24)) + self.auction_end = self.bidding_end + timedelta(hours=getValue("auction.selection_period", 24)) + self.save() + def process_payment(self): if self.invoice.is_paid: - self.activated = timezone.now() - self.save() - - @property - def expiry(self): - if self.activated: - return self.activated + relativedelta(days=settings.INQUIRY_RUNTIME) + self.activate() @property def expired(self): diff --git a/localsettings.dist.py b/localsettings.dist.py index c12118d..9ea126d 100644 --- a/localsettings.dist.py +++ b/localsettings.dist.py @@ -58,7 +58,3 @@ JOKER_COUNTRIES = ["AT"] CURRENCY_SYMBOL = "€" CURRENCY_CODE = "EUR" CURRENCY_NAME = "Euro" - -# Run time of inquiries in days - -INQUIRY_RUNTIME = 7 \ No newline at end of file