mirror of
https://github.com/pretix/pretix.git
synced 2026-05-05 15:14:04 +00:00
Highlight items that are unavailable by time
This commit is contained in:
@@ -364,17 +364,21 @@ class Item(LoggedModel):
|
|||||||
rate=Decimal('0.00'), name='')
|
rate=Decimal('0.00'), name='')
|
||||||
return self.tax_rule.tax(price, base_price_is=base_price_is)
|
return self.tax_rule.tax(price, base_price_is=base_price_is)
|
||||||
|
|
||||||
|
def is_available_by_time(self, now_dt: datetime=None) -> bool:
|
||||||
|
now_dt = now_dt or now()
|
||||||
|
if self.available_from and self.available_from > now_dt:
|
||||||
|
return False
|
||||||
|
if self.available_until and self.available_until < now_dt:
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
def is_available(self, now_dt: datetime=None) -> bool:
|
def is_available(self, now_dt: datetime=None) -> bool:
|
||||||
"""
|
"""
|
||||||
Returns whether this item is available according to its ``active`` flag
|
Returns whether this item is available according to its ``active`` flag
|
||||||
and its ``available_from`` and ``available_until`` fields
|
and its ``available_from`` and ``available_until`` fields
|
||||||
"""
|
"""
|
||||||
now_dt = now_dt or now()
|
now_dt = now_dt or now()
|
||||||
if not self.active:
|
if not self.active or not self.is_available_by_time(now_dt):
|
||||||
return False
|
|
||||||
if self.available_from and self.available_from > now_dt:
|
|
||||||
return False
|
|
||||||
if self.available_until and self.available_until < now_dt:
|
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|||||||
@@ -54,8 +54,16 @@
|
|||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
{% if i.available_from or i.available_until %}
|
{% if i.available_from or i.available_until %}
|
||||||
<span class="fa fa-clock-o fa-fw text-muted" data-toggle="tooltip" title="{% trans "Only available in a limited timeframe" %}">
|
{% if not i.is_available_by_time %}
|
||||||
</span>
|
<span class="label label-danger" data-toggle="tooltip"
|
||||||
|
title="{% trans "Currently unavailable since a limited timeframe for this product has been set" %}">
|
||||||
|
<span class="fa fa-clock-o fa-fw" data-toggle="tooltip">
|
||||||
|
</span>
|
||||||
|
</span>
|
||||||
|
{% else %}
|
||||||
|
<span class="fa fa-clock-o fa-fw text-muted" data-toggle="tooltip" title="{% trans "Only available in a limited timeframe" %}">
|
||||||
|
</span>
|
||||||
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
@@ -69,10 +77,15 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
{% if i.hide_without_voucher %}
|
{% if i.category.is_addon %}
|
||||||
<span class="fa fa-ticket fa-fw text-muted" data-toggle="tooltip" title="{% trans "Only visible with a voucher" %}"></span>
|
<span class="fa fa-puzzle-piece fa-fw text-muted" data-toggle="tooltip"
|
||||||
|
title="{% trans "Only available as an add-on product" %}"></span>
|
||||||
|
{% elif i.hide_without_voucher %}
|
||||||
|
<span class="fa fa-tags fa-fw text-muted" data-toggle="tooltip"
|
||||||
|
title="{% trans "Only visible with a voucher" %}"></span>
|
||||||
{% elif i.require_voucher %}
|
{% elif i.require_voucher %}
|
||||||
<span class="fa fa-ticket fa-fw text-muted" data-toggle="tooltip" title="{% trans "Can only bought using a voucher" %}"></span>
|
<span class="fa fa-tags fa-fw text-muted" data-toggle="tooltip"
|
||||||
|
title="{% trans "Can only bought using a voucher" %}"></span>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
<td>{% if i.category %}{{ i.category.name }}{% endif %}</td>
|
<td>{% if i.category %}{{ i.category.name }}{% endif %}</td>
|
||||||
|
|||||||
Reference in New Issue
Block a user