2021-03-21 15:50:50 +00:00
|
|
|
from django.contrib.gis.db import models
|
|
|
|
|
2021-03-24 06:43:05 +00:00
|
|
|
from clients.models import ClientProfile
|
|
|
|
from partners.models import Establishment
|
2021-03-21 15:50:50 +00:00
|
|
|
|
|
|
|
class Inquiry(models.Model):
|
2021-03-24 06:43:05 +00:00
|
|
|
client = models.ForeignKey(ClientProfile, models.PROTECT)
|
2021-03-21 15:50:50 +00:00
|
|
|
destination_name = models.CharField(max_length=128)
|
|
|
|
destination_coords = models.PointField()
|
|
|
|
destination_radius = models.IntegerField()
|
2021-03-24 06:43:05 +00:00
|
|
|
arrival_from = models.DateTimeField()
|
|
|
|
departure_until = models.DateTimeField()
|
2021-03-21 15:50:50 +00:00
|
|
|
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)
|
2021-03-21 15:50:50 +00:00
|
|
|
|
2021-03-24 06:43:05 +00:00
|
|
|
@property
|
|
|
|
def is_paid(self):
|
2021-03-24 06:43:47 +00:00
|
|
|
if not self.invoice:
|
2021-03-24 06:43:05 +00:00
|
|
|
return False
|
|
|
|
|
2021-03-24 06:43:47 +00:00
|
|
|
return self.invoice.is_paid
|
2021-03-24 06:43:05 +00:00
|
|
|
|
2021-03-21 15:50:50 +00:00
|
|
|
def get_hotels(self):
|
2021-03-24 06:43:05 +00:00
|
|
|
pass
|
|
|
|
|
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]
|
|
|
|
|
2021-03-24 06:43:05 +00:00
|
|
|
class Offer(models.Model):
|
|
|
|
inquiry = models.ForeignKey(Inquiry, models.PROTECT)
|
|
|
|
establishment = models.ForeignKey(Establishment, models.PROTECT)
|
|
|
|
arrival = models.DateTimeField()
|
|
|
|
departure = models.DateTimeField()
|
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)
|