forked from CGM_Public/pretix_original
Show Subevent start time in select2-pickers (#1630)
* Add Subevent time to __str__ * Show subevent-dates in select2 picker * Show event-dateblock (if enabled) on Widget Voucher redemption page * Update src/pretix/base/models/event.py Co-Authored-By: Raphael Michel <michel@rami.io> * Update src/pretix/control/templates/pretixcontrol/vouchers/index.html Co-Authored-By: Raphael Michel <michel@rami.io> * Update src/pretix/control/views/typeahead.py Co-Authored-By: Raphael Michel <michel@rami.io> * Remove date-block on non-subevent voucher redemption pages Co-authored-by: Raphael Michel <michel@rami.io>
This commit is contained in:
@@ -15,6 +15,7 @@ from django.db import models
|
|||||||
from django.db.models import Exists, F, OuterRef, Prefetch, Q, Subquery
|
from django.db.models import Exists, F, OuterRef, Prefetch, Q, Subquery
|
||||||
from django.template.defaultfilters import date as _date
|
from django.template.defaultfilters import date as _date
|
||||||
from django.utils.crypto import get_random_string
|
from django.utils.crypto import get_random_string
|
||||||
|
from django.utils.formats import date_format
|
||||||
from django.utils.functional import cached_property
|
from django.utils.functional import cached_property
|
||||||
from django.utils.timezone import make_aware, now
|
from django.utils.timezone import make_aware, now
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
@@ -1032,7 +1033,11 @@ class SubEvent(EventMixin, LoggedModel):
|
|||||||
ordering = ("date_from", "name")
|
ordering = ("date_from", "name")
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return '{} - {}'.format(self.name, self.get_date_range_display())
|
return '{} - {} {}'.format(
|
||||||
|
self.name,
|
||||||
|
self.get_date_range_display(),
|
||||||
|
date_format(self.date_from.astimezone(self.timezone), "TIME_FORMAT") if self.settings.show_times else ""
|
||||||
|
).strip()
|
||||||
|
|
||||||
def free_seats(self, ignore_voucher=None, sales_channel='web', include_blocked=False):
|
def free_seats(self, ignore_voucher=None, sales_channel='web', include_blocked=False):
|
||||||
from .orders import CartPosition, Order, OrderPosition
|
from .orders import CartPosition, Order, OrderPosition
|
||||||
|
|||||||
@@ -171,7 +171,12 @@
|
|||||||
{% if v.seat %}<br><small class="text-muted">{{ v.seat }}</small>{% endif %}
|
{% if v.seat %}<br><small class="text-muted">{{ v.seat }}</small>{% endif %}
|
||||||
</td>
|
</td>
|
||||||
{% if request.event.has_subevents %}
|
{% if request.event.has_subevents %}
|
||||||
<td>{{ v.subevent.name }} – {{ v.subevent.get_date_range_display }}</td>
|
<td>
|
||||||
|
{{ v.subevent.name }} – {{ v.subevent.get_date_range_display }}
|
||||||
|
{% if request.event.settings.show_times %}
|
||||||
|
{{ v.subevent.date_from|date:"TIME_FORMAT" }}
|
||||||
|
{% endif %}
|
||||||
|
</td>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<td class="text-right flip">
|
<td class="text-right flip">
|
||||||
<a href="{% url "control:event.vouchers.bulk" organizer=request.event.organizer.slug event=request.event.slug %}?copy_from={{ v.id }}"
|
<a href="{% url "control:event.vouchers.bulk" organizer=request.event.organizer.slug event=request.event.slug %}?copy_from={{ v.id }}"
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ from django.db.models.functions import Coalesce, Greatest
|
|||||||
from django.http import JsonResponse
|
from django.http import JsonResponse
|
||||||
from django.shortcuts import get_object_or_404
|
from django.shortcuts import get_object_or_404
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
from django.utils.formats import get_format
|
from django.utils.formats import date_format, get_format
|
||||||
from django.utils.timezone import make_aware
|
from django.utils.timezone import make_aware
|
||||||
from django.utils.translation import gettext as _, pgettext
|
from django.utils.translation import gettext as _, pgettext
|
||||||
|
|
||||||
@@ -261,8 +261,10 @@ def subevent_select2(request, **kwargs):
|
|||||||
{
|
{
|
||||||
'id': e.pk,
|
'id': e.pk,
|
||||||
'name': str(e.name),
|
'name': str(e.name),
|
||||||
'date_range': e.get_date_range_display(),
|
'date_range': e.get_date_range_display() + (
|
||||||
'text': '{} – {}'.format(e.name, e.get_date_range_display()),
|
" " + date_format(e.date_from.astimezone(tz), "TIME_FORMAT") if e.settings.show_times else ""
|
||||||
|
),
|
||||||
|
'text': str(e)
|
||||||
}
|
}
|
||||||
for e in qs[offset:offset + pagesize]
|
for e in qs[offset:offset + pagesize]
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -12,7 +12,48 @@
|
|||||||
<h2>{% trans "Voucher redemption" %}</h2>
|
<h2>{% trans "Voucher redemption" %}</h2>
|
||||||
{% if subevent %}
|
{% if subevent %}
|
||||||
<h3>{{ subevent.name }}</h3>
|
<h3>{{ subevent.name }}</h3>
|
||||||
|
{% with ev=subevent %}
|
||||||
|
<div class="info-row">
|
||||||
|
<span class="fa fa-clock-o fa-fw"></span>
|
||||||
|
<p>
|
||||||
|
{{ ev.get_date_range_display }}
|
||||||
|
{% if event.settings.show_times %}
|
||||||
|
<br>
|
||||||
|
{% blocktrans trimmed with time=ev.date_from|date:"TIME_FORMAT" %}
|
||||||
|
Begin: {{ time }}
|
||||||
|
{% endblocktrans %}
|
||||||
|
{% if event.settings.show_date_to and ev.date_to %}
|
||||||
|
<br>
|
||||||
|
{% blocktrans trimmed with time=ev.date_to|date:"TIME_FORMAT" %}
|
||||||
|
End: {{ time }}
|
||||||
|
{% endblocktrans %}
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
{% if ev.date_admission %}
|
||||||
|
<br>
|
||||||
|
{% if ev.date_admission|date:"SHORT_DATE_FORMAT" == ev.date_from|date:"SHORT_DATE_FORMAT" %}
|
||||||
|
{% blocktrans trimmed with time=ev.date_admission|date:"TIME_FORMAT" %}
|
||||||
|
Admission: {{ time }}
|
||||||
|
{% endblocktrans %}
|
||||||
|
{% else %}
|
||||||
|
{% blocktrans trimmed with datetime=ev.date_admission|date:"SHORT_DATETIME_FORMAT" %}
|
||||||
|
Admission: {{ datetime }}
|
||||||
|
{% endblocktrans %}
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
<br>
|
||||||
|
{% if subevent %}
|
||||||
|
<a href="{% eventurl event "presale:event.ical.download" subevent=subevent.pk %}">
|
||||||
|
{% else %}
|
||||||
|
<a href="{% eventurl event "presale:event.ical.download" %}">
|
||||||
|
{% endif %}
|
||||||
|
{% trans "Add to Calendar" %}
|
||||||
|
</a>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
{% endwith %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
{% blocktrans trimmed %}
|
{% blocktrans trimmed %}
|
||||||
You entered a voucher code that allows you to buy one of the following products at the specified price:
|
You entered a voucher code that allows you to buy one of the following products at the specified price:
|
||||||
|
|||||||
Reference in New Issue
Block a user