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='')
|
||||
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:
|
||||
"""
|
||||
Returns whether this item is available according to its ``active`` flag
|
||||
and its ``available_from`` and ``available_until`` fields
|
||||
"""
|
||||
now_dt = now_dt or now()
|
||||
if not self.active:
|
||||
return False
|
||||
if self.available_from and self.available_from > now_dt:
|
||||
return False
|
||||
if self.available_until and self.available_until < now_dt:
|
||||
if not self.active or not self.is_available_by_time(now_dt):
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
@@ -54,8 +54,16 @@
|
||||
</td>
|
||||
<td>
|
||||
{% 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" %}">
|
||||
</span>
|
||||
{% if not i.is_available_by_time %}
|
||||
<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 %}
|
||||
</td>
|
||||
<td>
|
||||
@@ -69,10 +77,15 @@
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>
|
||||
{% if i.hide_without_voucher %}
|
||||
<span class="fa fa-ticket fa-fw text-muted" data-toggle="tooltip" title="{% trans "Only visible with a voucher" %}"></span>
|
||||
{% if i.category.is_addon %}
|
||||
<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 %}
|
||||
<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 %}
|
||||
</td>
|
||||
<td>{% if i.category %}{{ i.category.name }}{% endif %}</td>
|
||||
|
||||
Reference in New Issue
Block a user