JourneyJoker/auction/models.py

48 lines
1.5 KiB
Python
Raw Normal View History

from django.contrib.gis.db import models
from clients.models import ClientProfile
from partners.models import Establishment
import uuid
2021-04-18 06:12:15 +00:00
class LengthChoices(models.IntegerChoices):
ANY = 0
SHORT = 1
LONG = 2
class Inquiry(models.Model):
uuid = models.UUIDField(default=uuid.uuid4, unique=True)
client = models.ForeignKey(ClientProfile, models.PROTECT, null=True, blank=True)
destination_name = models.CharField(max_length=128)
destination_coords = models.PointField()
destination_radius = models.IntegerField()
arrival = models.DateField()
2021-04-18 06:12:15 +00:00
min_nights = models.IntegerField(default=0, choices=LengthChoices.choices)
budget = models.DecimalField(max_digits=10, decimal_places=2)
adults = models.IntegerField()
children = models.IntegerField()
2021-03-24 09:44:52 +00:00
comment = models.TextField(null=True, blank=True)
active = models.BooleanField(default=False)
gateway = models.CharField(max_length=128, null=True, blank=True)
@property
def is_paid(self):
2021-03-24 06:43:47 +00:00
if not self.invoice:
return False
2021-03-24 06:43:47 +00:00
return self.invoice.is_paid
2021-03-24 09:44:52 +00:00
@property
def accepted(self):
qset = Offer.objects.filter(inquiry=self, accepted=True)
if qset:
return qset[0]
class Offer(models.Model):
inquiry = models.ForeignKey(Inquiry, models.PROTECT)
establishment = models.ForeignKey(Establishment, models.PROTECT)
nights = models.IntegerField()
2021-03-24 09:44:52 +00:00
comment = models.TextField(null=True, blank=True)
accepted = models.BooleanField(default=False)
hidden = models.BooleanField(default=False)