Move variables into database
Improve auction activation logic
This commit is contained in:
parent
b586fb89b5
commit
2b175339dc
2 changed files with 14 additions and 13 deletions
|
@ -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 process_payment(self):
|
||||
if 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()
|
||||
|
||||
@property
|
||||
def expiry(self):
|
||||
if self.activated:
|
||||
return self.activated + relativedelta(days=settings.INQUIRY_RUNTIME)
|
||||
def process_payment(self):
|
||||
if self.invoice.is_paid:
|
||||
self.activate()
|
||||
|
||||
@property
|
||||
def expired(self):
|
||||
|
|
|
@ -58,7 +58,3 @@ JOKER_COUNTRIES = ["AT"]
|
|||
CURRENCY_SYMBOL = "€"
|
||||
CURRENCY_CODE = "EUR"
|
||||
CURRENCY_NAME = "Euro"
|
||||
|
||||
# Run time of inquiries in days
|
||||
|
||||
INQUIRY_RUNTIME = 7
|
Loading…
Reference in a new issue