Fix presale date display in calendar (Z#23216645) (#5710)

Fix presale date display in calendar and introduce a template tag
This commit is contained in:
Phin Wolkwitz
2025-12-17 16:18:59 +01:00
committed by GitHub
parent 2e89fc0a94
commit 11df4398e1
8 changed files with 106 additions and 39 deletions

View File

@@ -1,3 +1,4 @@
{% load html_time %}
{% load i18n %}
{% load icon %}
{% load eventurl %}
@@ -21,20 +22,18 @@
{% if event.settings.show_times %}
<br>
<span data-time="{{ ev.date_from.isoformat }}" data-timezone="{{ request.event.timezone }}">
{% with time_human=ev.date_from|date:"TIME_FORMAT" time_24=ev.date_from|time:"H:i" %}
{% blocktrans trimmed with time='<time datetime="'|add:time_24|add:'">'|add:time_human|add:"</time>"|safe %}
Begin: {{ time }}
{% endblocktrans %}
{% endwith %}
{% html_time ev.date_from "TIME_FORMAT" attr_fmt="H:i" as time%}
{% blocktrans with time=time %}
Begin: {{ time }}
{% endblocktrans %}
</span>
{% if event.settings.show_date_to and ev.date_to %}
<br>
<span data-time="{{ ev.date_to.isoformat }}" data-timezone="{{ request.event.timezone }}">
{% with time_human=ev.date_to|date:"TIME_FORMAT" time_24=ev.date_to|time:"H:i" %}
{% blocktrans trimmed with time='<time datetime="'|add:time_24|add:'">'|add:time_human|add:"</time>"|safe %}
End: {{ time }}
{% endblocktrans %}
{% endwith %}
{% html_time ev.date_to "TIME_FORMAT" attr_fmt="H:i" as time%}
{% blocktrans with time=time %}
End: {{ time }}
{% endblocktrans %}
</span>
{% endif %}
{% endif %}
@@ -42,19 +41,17 @@
<br>
{% if ev.date_admission|date:"SHORT_DATE_FORMAT" == ev.date_from|date:"SHORT_DATE_FORMAT" %}
<span data-time="{{ ev.date_admission.isoformat }}" data-timezone="{{ request.event.timezone }}">
{% with time_human=ev.date_admission|date:"TIME_FORMAT" time_24=ev.date_admission|time:"H:i" %}
{% blocktrans trimmed with time='<time datetime="'|add:time_24|add:'">'|add:time_human|add:"</time>"|safe %}
Admission: {{ time }}
{% endblocktrans %}
{% endwith %}
{% html_time ev.date_admission "TIME_FORMAT" attr_fmt="H:i" as time%}
{% blocktrans trimmed with time=time %}
Admission: {{ time }}
{% endblocktrans %}
</span>
{% else %}
<span data-time="{{ ev.date_admission.isoformat }}" data-timezone="{{ request.event.timezone }}">
{% with datetime_human=ev.date_admission|date:"SHORT_DATETIME_FORMAT" datetime_iso=ev.date_admission|time:"Y-m-d H:i" %}
{% blocktrans trimmed with datetime='<time datetime="'|add:datetime_iso|add:'">'|add:datetime_human|add:"</time>"|safe %}
Admission: {{ datetime }}
{% endblocktrans %}
{% endwith %}
{% html_time ev.date_admission "SHORT_DATETIME_FORMAT" attr_fmt="Y-m-d H:i" as datetime%}
{% blocktrans trimmed with datetime=datetime %}
Admission: {{ datetime }}
{% endblocktrans %}
</span>
{% endif %}
{% endif %}

View File

@@ -1,4 +1,5 @@
{% extends "pretixpresale/event/base.html" %}
{% load html_time %}
{% load i18n %}
{% load bootstrap3 %}
{% load eventsignal %}
@@ -92,11 +93,10 @@
A payment of {{ total }} is still pending for this order.
{% endblocktrans %}</strong>
<strong>
{% with date_human=order|format_expires|safe date_iso=order.expires|date:"c" %}
{% blocktrans trimmed with date='<time datetime="'|add:date_iso|add:'">'|add:date_human|add:"</time>"|safe %}
{% html_time order.expires "format_expires" as date %}
{% blocktrans trimmed with date=date %}
Please complete your payment before {{ date }}
{% endblocktrans %}
{% endwith %}
</strong>
</p>
{% if last_payment %}

View File

@@ -1,3 +1,4 @@
{% load html_time %}
{% load i18n %}
{% load date_fast %}
{% load calendarhead %}
@@ -55,7 +56,7 @@
running
{% elif event.event.presale_has_ended %}
over
{% elif event.event.settings.presale_start_show_date and event.event.presale_start %}
{% elif event.event.settings.presale_start_show_date and event.event.effective_presale_start %}
soon
{% else %}
soon
@@ -108,13 +109,12 @@
<span class="fa fa-ticket" aria-hidden="true"></span> {% trans "Book now" %}
{% elif event.event.presale_has_ended %}
{% trans "Sale over" %}
{% elif event.event.settings.presale_start_show_date and event.event.presale_start %}
{% elif event.event.settings.presale_start_show_date and event.event.effective_presale_start %}
<span class="fa fa-ticket" aria-hidden="true"></span>
{% with date_human=event.event.presale_start|date_fast:"SHORT_DATE_FORMAT" date_iso=event.event.presale_start|date_fast:"c" %}
{% blocktrans with start_date="<time datetime='"|add:date_iso|add:"'>"|add:date_human|add:"</time>"|safe %}
{% html_time event.event.effective_presale_start "SHORT_DATE_FORMAT" as start_date %}
{% blocktrans with start_date=start_date %}
from {{ start_date }}
{% endblocktrans %}
{% endwith %}
{% else %}
<span class="fa fa-ticket" aria-hidden="true"></span> {% trans "Soon" %}
{% endif %}

View File

@@ -1,3 +1,4 @@
{% load html_time %}
{% load i18n %}
{% load eventurl %}
<div class="day-calendar cal-size-{{ raster_to_shortest_ratio }}{% if no_headlines %} no-headlines{% endif %}"
@@ -52,7 +53,7 @@
running
{% elif event.event.presale_has_ended %}
over
{% elif event.event.settings.presale_start_show_date and event.event.presale_start %}
{% elif event.event.settings.presale_start_show_date and event.event.effective_presale_start %}
soon
{% else %}
soon
@@ -114,9 +115,10 @@
<span class="fa fa-ticket" aria-hidden="true"></span> {% trans "Book now" %}
{% elif event.event.presale_has_ended %}
<span class="fa fa-ticket" aria-hidden="true"></span> {% trans "Sale over" %}
{% elif event.event.settings.presale_start_show_date and event.event.presale_start %}
{% elif event.event.settings.presale_start_show_date and event.event.effective_presale_start %}
<span class="fa fa-ticket" aria-hidden="true"></span>
{% blocktrans with start_date=event.event.presale_start|date:"SHORT_DATE_FORMAT" %}
{% html_time event.event.effective_presale_start "SHORT_DATE_FORMAT" as start_date %}
{% blocktrans with start_date=start_date %}
from {{ start_date }}
{% endblocktrans %}
{% else %}

View File

@@ -1,3 +1,4 @@
{% load html_time %}
{% load i18n %}
{% load icon %}
{% load textbubble %}
@@ -52,11 +53,10 @@
{% endtextbubble %}
{% if event.settings.presale_start_show_date %}
<br><span class="text-muted">
{% with date_iso=event.effective_presale_start.isoformat date_human=event.effective_presale_start|date:"SHORT_DATE_FORMAT" %}
{% blocktrans trimmed with date='<time datetime="'|add:date_iso|add:'">'|add:date_human|add:"</time>"|safe %}
{% html_time event.event.effective_presale_start "SHORT_DATE_FORMAT" as date %}
{% blocktrans with date=date %}
Sale starts {{ date }}
{% endblocktrans %}
{% endwith %}
</span>
{% endif %}
{% endif %}

View File

@@ -1,3 +1,4 @@
{% load html_time %}
{% load i18n %}
{% load date_fast %}
<div class="week-calendar">
@@ -24,7 +25,7 @@
running
{% elif event.event.presale_has_ended %}
over
{% elif event.event.settings.presale_start_show_date and event.event.presale_start %}
{% elif event.event.settings.presale_start_show_date and event.event.effective_presale_start %}
soon
{% else %}
soon
@@ -77,9 +78,10 @@
<span class="fa fa-ticket" aria-hidden="true"></span> {% trans "Book now" %}
{% elif event.event.presale_has_ended %}
{% trans "Sale over" %}
{% elif event.event.settings.presale_start_show_date and event.event.presale_start %}
{% elif event.event.settings.presale_start_show_date and event.event.effective_presale_start %}
<span class="fa fa-ticket" aria-hidden="true"></span>
{% blocktrans with start_date=event.event.presale_start|date_fast:"SHORT_DATE_FORMAT" %}
{% html_time event.event.effective_presale_start "SHORT_DATE_FORMAT" as start_date %}
{% blocktrans with start_date=start_date %}
from {{ start_date }}
{% endblocktrans %}
{% else %}

View File

@@ -471,10 +471,11 @@ class WidgetAPIProductList(EventListMixin, View):
availability['color'] = 'red'
availability['text'] = gettext('Sale over')
availability['reason'] = 'over'
elif event.settings.presale_start_show_date and ev.presale_start:
elif event.settings.presale_start_show_date and ev.effective_presale_start:
availability['color'] = 'orange'
availability['text'] = gettext('from %(start_date)s') % {
'start_date': date_format(ev.presale_start.astimezone(tz or event.timezone), "SHORT_DATE_FORMAT")
'start_date': date_format(ev.effective_presale_start.astimezone(tz or event.timezone),
"SHORT_DATE_FORMAT")
}
availability['reason'] = 'soon'
else: