Fix products not available for purchased anymore
This commit is contained in:
parent
ffb7fb38e4
commit
77422417ec
|
@ -282,6 +282,16 @@ class Product(CreatedUpdatedModel, UUIDModel):
|
|||
now = timezone.now()
|
||||
return now in self.available_in
|
||||
|
||||
def is_old(self):
|
||||
now = timezone.now()
|
||||
if hasattr(self.available_in, 'upper') and self.available_in.upper:
|
||||
return self.available_in.upper < now
|
||||
return False
|
||||
|
||||
def is_upcoming(self):
|
||||
now = timezone.now()
|
||||
return self.available_in.lower > now
|
||||
|
||||
|
||||
class OrderProductRelation(CreatedUpdatedModel):
|
||||
order = models.ForeignKey('shop.Order')
|
||||
|
|
|
@ -40,8 +40,12 @@
|
|||
{% else %}
|
||||
|
||||
<p>
|
||||
{% if product.is_old %}
|
||||
This product is not available anymore.
|
||||
{% elif product.is_upcoming %}
|
||||
This product is available from
|
||||
{{ product.available_in.lower|date:"Y-m-d H:i T" }}
|
||||
{% endif %}
|
||||
</p>
|
||||
|
||||
{% endif %}
|
||||
|
|
Loading…
Reference in a new issue