Fix missing expiry of Inquiries

This commit is contained in:
Kumi 2021-05-31 08:35:17 +02:00
parent 08ffc0fc5c
commit c6156ebf21
2 changed files with 27 additions and 1 deletions

View file

@ -1,6 +1,8 @@
from django.contrib.gis.db import models
from django.utils import timezone
from django.contrib.gis.db.models.functions import Distance
from django.dispatch import receiver
from django.db.models.signals import post_save
from clients.models import ClientProfile
from partners.models import Establishment, RoomCategory
@ -30,6 +32,7 @@ class Inquiry(models.Model):
comment = models.TextField(null=True, blank=True)
activated = models.DateTimeField(null=True, blank=True)
bidding_end = models.DateTimeField(null=True, blank=True)
expiry = models.DateTimeField(null=True, blank=True)
gateway = models.CharField(max_length=128, null=True, blank=True)
@property
@ -89,4 +92,10 @@ class Offer(models.Model):
@property
def distance(self):
return self.inquiry.destination_coords.distance(self.roomcategory.establishment.coords)
return self.inquiry.destination_coords.distance(self.roomcategory.establishment.coords)
@receiver(post_save, sender=Inquiry)
def inquiry_expiry(sender, instance, created, **kwargs):
if not instance.expiry:
instance.expiry = min(inquiry.arrival, timezone.now() + timedelta(getValue("auction.payment_period", 168)))
instance.save()

View file

@ -54,6 +54,23 @@
</div><!-- end modal-content -->
</div><!-- end modal-dialog -->
</div><!-- end edit-profile -->
{% for offer in offer.object_set.all %}
<div id="gallery{{ offer.id }}" class="modal custom-modal fade" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h3 class="modal-title">Galerie</h3>
<button type="button" class="close" data-dismiss="modal">&times;</button>
</div><!-- end modal-header -->
<div class="modal-body">
</div><!-- end modal-bpdy -->
</div><!-- end modal-content -->
</div><!-- end modal-dialog -->
</div><!-- end edit-profile -->
{% endfor %}
{% endblock %}
{% block "scripts" %}