Performance: Cache complete organizer index page, cache subevent list template fragment (#2125)

This commit is contained in:
Raphael Michel
2021-06-14 17:12:11 +02:00
committed by GitHub
parent cd88659351
commit ba895270fa
6 changed files with 108 additions and 31 deletions

View File

@@ -9,21 +9,21 @@
{% endfor %}
<div class="row">
<div class="col-sm-4 hidden-xs text-left flip">
<a href="?{% url_replace request "year" before.year "month" before.month %}"
<a href="?{% url_replace request "year" subevent_list.before.year "month" subevent_list.before.month %}"
class="btn btn-default">
<span class="fa fa-arrow-left" aria-hidden="true"></span>
{{ before|date:"F Y" }}
{{ subevent_list.before|date:"F Y" }}
</a>
</div>
<div class="col-sm-4 col-xs-12 text-center">
<select name="month" class="form-control">
{% for m in months %}
<option value="{{ m|date:"m" }}" {% if m == date %}selected{% endif %}>{{ m|date:"F" }}</option>
{% for m in subevent_list.months %}
<option value="{{ m|date:"m" }}" {% if m == subevent_list.date.month %}selected{% endif %}>{{ m|date:"F" }}</option>
{% endfor %}
</select>
<select name="year" class="form-control">
{% for y in years %}
<option value="{{ y }}" {% if y == date.year %}selected{% endif %}>{{ y }}</option>
{% for y in subevent_list.years %}
<option value="{{ y }}" {% if y == subevent_list.date.year %}selected{% endif %}>{{ y }}</option>
{% endfor %}
</select>
<button type="submit" class="js-hidden btn btn-default">
@@ -31,11 +31,11 @@
</button>
</div>
<div class="col-sm-4 hidden-xs text-right flip">
<a href="?{% url_replace request "year" after.year "month" after.month %}" class="btn btn-default">
{{ after|date:"F Y" }}
<a href="?{% url_replace request "year" subevent_list.after.year "month" subevent_list.after.month %}" class="btn btn-default">
{{ subevent_list.after|date:"F Y" }}
<span class="fa fa-arrow-right" aria-hidden="true"></span>
</a>
</div>
</div>
</form>
{% include "pretixpresale/fragment_calendar.html" with show_avail=event.settings.event_list_availability %}
{% include "pretixpresale/fragment_calendar.html" with show_avail=event.settings.event_list_availability weeks=subevent_list.weeks %}

View File

@@ -9,21 +9,21 @@
{% endfor %}
<div class="row">
<div class="col-sm-4 hidden-xs text-left flip">
<a href="?{% url_replace request "year" before.isocalendar.0 "week" before.isocalendar.1 %}"
<a href="?{% url_replace request "year" subevent_list.before.isocalendar.0 "week" subevent_list.before.isocalendar.1 %}"
class="btn btn-default">
<span class="fa fa-arrow-left" aria-hidden="true"></span>
{{ before|date:week_format }}
{{ before|date:subevent_list.week_format }}
</a>
</div>
<div class="col-sm-4 col-xs-12 text-center">
<select name="week" class="form-control select-calendar-week-short">
{% for w in weeks %}
<option value="{{ w.0.isocalendar.1 }}" {% if w.0.isocalendar.1 == date.isocalendar.1 %}selected{% endif %}>{% trans "W" %} {{ w.0.isocalendar.1 }} ({{ w.0|date:"SHORT_DATE_FORMAT" }} {{ w.1|date:"SHORT_DATE_FORMAT" }})</option>
{% for w in subevent_list.weeks %}
<option value="{{ w.0.isocalendar.1 }}" {% if w.0.isocalendar.1 == subevent_list.date.isocalendar.1 %}selected{% endif %}>{% trans "W" %} {{ w.0.isocalendar.1 }} ({{ w.0|date:"SHORT_DATE_FORMAT" }} {{ w.1|date:"SHORT_DATE_FORMAT" }})</option>
{% endfor %}
</select>
<select name="year" class="form-control">
{% for y in years %}
<option value="{{ y }}" {% if y == date.isocalendar.0 %}selected{% endif %}>{{ y }}</option>
{% for y in subevent_list.years %}
<option value="{{ y }}" {% if y == subevent_list.date.isocalendar.0 %}selected{% endif %}>{{ y }}</option>
{% endfor %}
</select>
<button type="submit" class="js-hidden btn btn-default">
@@ -31,24 +31,24 @@
</button>
</div>
<div class="col-sm-4 hidden-xs text-right flip">
<a href="?{% url_replace request "year" after.isocalendar.0 "week" after.isocalendar.1 %}"
<a href="?{% url_replace request "year" subevent_list.after.isocalendar.0 "week" subevent_list.after.isocalendar.1 %}"
class="btn btn-default">
{{ after|date:week_format }}
{{ subevent_list.after|date:subevent_list.week_format }}
<span class="fa fa-arrow-right" aria-hidden="true"></span>
</a>
</div>
</div>
</form>
{% include "pretixpresale/fragment_week_calendar.html" with show_avail=event.settings.event_list_availability %}
{% include "pretixpresale/fragment_week_calendar.html" with show_avail=event.settings.event_list_availability days=subevent_list.days %}
<div class="col-sm-4 visible-xs text-center">
<a href="?{% url_replace request "year" before.isocalendar.0 "week" before.isocalendar.1 %}"
<a href="?{% url_replace request "year" subevent_list.before.isocalendar.0 "week" subevent_list.before.isocalendar.1 %}"
class="btn btn-default">
<span class="fa fa-arrow-left" aria-hidden="true"></span>
{{ before|date:week_format }}
{{ subevent_list.before|date:subevent_list.week_format }}
</a>
<a href="?{% url_replace request "year" after.isocalendar.0 "week" after.isocalendar.1 %}"
<a href="?{% url_replace request "year" subevent_list.after.isocalendar.0 "week" subevent_list.after.isocalendar.1 %}"
class="btn btn-default">
{{ after|date:week_format }}
{{ subevent_list.after|date:subevent_list.week_format }}
<span class="fa fa-arrow-right" aria-hidden="true"></span>
</a>
</div>

View File

@@ -1,6 +1,6 @@
{% load i18n %}
{% load eventurl %}
{% for subev in subevent_list %}
{% for subev in subevent_list.subevent_list %}
<a href="{% if request.GET.voucher %}{% eventurl event "presale:event.redeem" cart_namespace=cart_namespace %}?voucher={{ request.GET.voucher|urlencode }}&subevent={{ subev.pk }}{% else %}{% eventurl event "presale:event.index" subevent=subev.id cart_namespace=cart_namespace %}{% endif %}"
class="subevent-row">
<div class="row">

View File

@@ -2,6 +2,7 @@
{% load i18n %}
{% load l10n %}
{% load eventurl %}
{% load cache %}
{% load money %}
{% load thumb %}
{% load eventsignal %}
@@ -73,13 +74,15 @@
</div>
<div class="panel-body">
<div>
{% if list_type == "calendar" %}
{% include "pretixpresale/event/fragment_subevent_calendar.html" %}
{% elif list_type == "week" %}
{% include "pretixpresale/event/fragment_subevent_calendar_week.html" %}
{% else %}
{% include "pretixpresale/event/fragment_subevent_list.html" %}
{% endif %}
{% cache 15 subevent_lits subevent_list_cache_key %}
{% if subevent_list.list_type == "calendar" %}
{% include "pretixpresale/event/fragment_subevent_calendar.html" %}
{% elif subevent_list.list_type == "week" %}
{% include "pretixpresale/event/fragment_subevent_calendar_week.html" %}
{% else %}
{% include "pretixpresale/event/fragment_subevent_list.html" %}
{% endif %}
{% endcache %}
</div>
</div>
</div>