Fix missing expiry of Inquiries
This commit is contained in:
parent
08ffc0fc5c
commit
c6156ebf21
2 changed files with 27 additions and 1 deletions
|
@ -1,6 +1,8 @@
|
||||||
from django.contrib.gis.db import models
|
from django.contrib.gis.db import models
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
from django.contrib.gis.db.models.functions import Distance
|
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 clients.models import ClientProfile
|
||||||
from partners.models import Establishment, RoomCategory
|
from partners.models import Establishment, RoomCategory
|
||||||
|
@ -30,6 +32,7 @@ class Inquiry(models.Model):
|
||||||
comment = models.TextField(null=True, blank=True)
|
comment = models.TextField(null=True, blank=True)
|
||||||
activated = models.DateTimeField(null=True, blank=True)
|
activated = models.DateTimeField(null=True, blank=True)
|
||||||
bidding_end = 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)
|
gateway = models.CharField(max_length=128, null=True, blank=True)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -89,4 +92,10 @@ class Offer(models.Model):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def distance(self):
|
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()
|
|
@ -54,6 +54,23 @@
|
||||||
</div><!-- end modal-content -->
|
</div><!-- end modal-content -->
|
||||||
</div><!-- end modal-dialog -->
|
</div><!-- end modal-dialog -->
|
||||||
</div><!-- end edit-profile -->
|
</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">×</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 %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block "scripts" %}
|
{% block "scripts" %}
|
||||||
|
|
Loading…
Reference in a new issue