Improve offer and inquiry classes

This commit is contained in:
Kumi 2021-03-24 10:44:52 +01:00
parent d465d05d90
commit 5b4d51341d

View file

@ -13,7 +13,7 @@ class Inquiry(models.Model):
budget = models.DecimalField(max_digits=10, decimal_places=2)
adults = models.IntegerField()
children = models.IntegerField()
comment = models.TextField()
comment = models.TextField(null=True, blank=True)
@property
def is_paid(self):
@ -25,8 +25,18 @@ class Inquiry(models.Model):
def get_hotels(self):
pass
@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)
arrival = models.DateTimeField()
departure = models.DateTimeField()
comment = models.TextField(null=True, blank=True)
accepted = models.BooleanField(default=False)
hidden = models.BooleanField(default=False)