End infinite link tree on organizer calendar pages

This commit is contained in:
Raphael Michel
2021-01-17 22:36:40 +01:00
parent 190ffe8d24
commit fc6b644587
4 changed files with 101 additions and 47 deletions

View File

@@ -19,24 +19,24 @@
{% endfor %} {% endfor %}
<div class="row"> <div class="row">
<div class="col-sm-4 col-xs-12 text-left flip"> <div class="col-sm-4 col-xs-12 text-left flip">
<div class="btn-group" role="group"> <div class="btn-group" role="group" <a href="{% eventurl request.organizer "presale:organizer.ical" %}?{% url_replace request "locale" request.LANGUAGE_CODE "page" "" "old" "" "week" "" "style" "" "month" "" "year" "" %}">
<a href="?{% url_replace request "style" "list" %}" type="button" class="btn btn-default"> <a href="?{% url_replace request "style" "list" "week" "" "year" "" "month" "" %}" type="button" class="btn btn-default">
<span class="fa fa-list"></span> <span class="fa fa-list"></span>
{% trans "List" %} {% trans "List" %}
</a> </a>
<a href="?{% url_replace request "style" "week" %}" type="button" <a href="?{% url_replace request "style" "week" "old" "" "month" "" "year" "" %}" type="button"
class="btn btn-default"> class="btn btn-default">
<span class="fa fa-calendar"></span> <span class="fa fa-calendar"></span>
{% trans "Week" %} {% trans "Week" %}
</a> </a>
<a href="?{% url_replace request "style" "calendar" %}" <a href="?{% url_replace request "style" "calendar" "old" "" "week" "" %}"
type="button" type="button"
class="btn btn-default active"> class="btn btn-default active">
<span class="fa fa-calendar"></span> <span class="fa fa-calendar"></span>
{% trans "Month" %} {% trans "Month" %}
</a> </a>
</div> </div>
<a href="{% eventurl request.organizer "presale:organizer.ical" %}?{% url_replace request "locale" request.LANGUAGE_CODE "style" "" "month" "" "year" "" %}" <a href="{% eventurl request.organizer "presale:organizer.ical" %}?{% url_replace request "locale" request.LANGUAGE_CODE "page" "" "old" "" "week" "" "style" "" "month" "" "year" "" %}"
class="btn btn-default"> class="btn btn-default">
<span class="fa fa-calendar-plus-o"></span> <span class="fa fa-calendar-plus-o"></span>
{% trans "iCal" %} {% trans "iCal" %}
@@ -58,14 +58,18 @@
</button> </button>
</div> </div>
<div class="col-sm-4 hidden-xs text-right flip"> <div class="col-sm-4 hidden-xs text-right flip">
<a href="?{% url_replace request "year" before.year "month" before.month %}" class="btn btn-default"> {% if has_before %}
<span class="fa fa-arrow-left"></span> <a href="?{% url_replace request "year" before.year "month" before.month %}" class="btn btn-default">
{{ before|date:"F Y" }} <span class="fa fa-arrow-left"></span>
</a> {{ before|date:"F Y" }}
<a href="?{% url_replace request "year" after.year "month" after.month %}" class="btn btn-default"> </a>
<span class="fa fa-arrow-right"></span> {% endif %}
{{ after|date:"F Y" }} {% if has_after %}
</a> <a href="?{% url_replace request "year" after.year "month" after.month %}" class="btn btn-default">
<span class="fa fa-arrow-right"></span>
{{ after|date:"F Y" }}
</a>
{% endif %}
</div> </div>
</div> </div>
</form> </form>

View File

@@ -11,7 +11,8 @@
</div> </div>
{% endif %} {% endif %}
<h3>{{ date|date:"F Y" }}</h3> <h3>{{ date|date:"F Y" }}</h3>
<form class="form-inline" method="get" id="monthselform" action="{% eventurl request.organizer "presale:organizer.index" %}"> <form class="form-inline" method="get" id="monthselform"
action="{% eventurl request.organizer "presale:organizer.index" %}">
{% for f, v in request.GET.items %} {% for f, v in request.GET.items %}
{% if f != "week" and f != "year" %} {% if f != "week" and f != "year" %}
<input type="hidden" name="{{ f }}" value="{{ v }}"> <input type="hidden" name="{{ f }}" value="{{ v }}">
@@ -20,24 +21,25 @@
<div class="row"> <div class="row">
<div class="col-sm-4 hidden-xs text-left flip"> <div class="col-sm-4 hidden-xs text-left flip">
<div class="btn-group" role="group"> <div class="btn-group" role="group">
<a href="?{% url_replace request "style" "list" %}" type="button" class="btn btn-default"> <a href="?{% url_replace request "style" "list" "week" "" "year" "" "month" "" %}" type="button"
class="btn btn-default">
<span class="fa fa-list"></span> <span class="fa fa-list"></span>
{% trans "List" %} {% trans "List" %}
</a> </a>
<a href="?{% url_replace request "style" "week" %}" type="button" <a href="?{% url_replace request "style" "week" "month" "" "old" "" %}" type="button"
class="btn btn-default active"> class="btn btn-default active">
<span class="fa fa-calendar"></span> <span class="fa fa-calendar"></span>
{% trans "Week" %} {% trans "Week" %}
</a> </a>
<a href="?{% url_replace request "style" "calendar" %}" <a href="?{% url_replace request "style" "calendar" "week" "" "old" "" "year" "" %}"
type="button" type="button"
class="btn btn-default"> class="btn btn-default">
<span class="fa fa-calendar"></span> <span class="fa fa-calendar"></span>
{% trans "Month" %} {% trans "Month" %}
</a> </a>
</div> </div>
<a href="{% eventurl request.organizer "presale:organizer.ical" %}?{% url_replace request "locale" request.LANGUAGE_CODE "style" "" "month" "" "year" "" %}" <a href="{% eventurl request.organizer "presale:organizer.ical" %}?{% url_replace request "locale" request.LANGUAGE_CODE "page" "" "old" "" "week" "" "style" "" "month" "" "year" "" %}"
class="btn btn-default"> class="btn btn-default">
<span class="fa fa-calendar-plus-o"></span> <span class="fa fa-calendar-plus-o"></span>
{% trans "iCal" %} {% trans "iCal" %}
</a> </a>
@@ -45,7 +47,10 @@
<div class="col-sm-4 col-xs-12 text-center"> <div class="col-sm-4 col-xs-12 text-center">
<select name="week" class="form-control select-calendar-week-short"> <select name="week" class="form-control select-calendar-week-short">
{% for w in weeks %} {% 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> <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>
{% endfor %} {% endfor %}
</select> </select>
<select name="year" class="form-control"> <select name="year" class="form-control">
@@ -58,16 +63,20 @@
</button> </button>
</div> </div>
<div class="col-sm-4 hidden-xs text-right flip"> <div class="col-sm-4 hidden-xs text-right flip">
<a href="?{% url_replace request "year" before.isocalendar.0 "week" before.isocalendar.1 %}" {% if has_before %}
class="btn btn-default"> <a href="?{% url_replace request "year" before.isocalendar.0 "week" before.isocalendar.1 %}"
<span class="fa fa-arrow-left"></span> class="btn btn-default">
{{ before|date:week_format }} <span class="fa fa-arrow-left"></span>
</a> {{ before|date:week_format }}
<a href="?{% url_replace request "year" after.isocalendar.0 "week" after.isocalendar.1 %}" </a>
class="btn btn-default"> {% endif %}
{{ after|date:week_format }} {% if has_after %}
<span class="fa fa-arrow-right"></span> <a href="?{% url_replace request "year" after.isocalendar.0 "week" after.isocalendar.1 %}"
</a> class="btn btn-default">
{{ after|date:week_format }}
<span class="fa fa-arrow-right"></span>
</a>
{% endif %}
</div> </div>
</div> </div>
{% for f, v in request.GET.items %} {% for f, v in request.GET.items %}
@@ -78,16 +87,20 @@
</form> </form>
{% include "pretixpresale/fragment_week_calendar.html" with show_avail=request.organizer.settings.event_list_availability %} {% include "pretixpresale/fragment_week_calendar.html" with show_avail=request.organizer.settings.event_list_availability %}
<div class="col-sm-4 visible-xs text-center"> <div class="col-sm-4 visible-xs text-center">
<a href="?{% url_replace request "year" before.isocalendar.0 "week" before.isocalendar.1 %}" {% if has_before %}
class="btn btn-default"> <a href="?{% url_replace request "year" before.isocalendar.0 "week" before.isocalendar.1 %}"
<span class="fa fa-arrow-left"></span> class="btn btn-default">
{{ before|date:week_format }} <span class="fa fa-arrow-left"></span>
</a> {{ before|date:week_format }}
<a href="?{% url_replace request "year" after.isocalendar.0 "week" after.isocalendar.1 %}" </a>
class="btn btn-default"> {% endif %}
{{ after|date:week_format }} {% if has_after %}
<span class="fa fa-arrow-right"></span> <a href="?{% url_replace request "year" after.isocalendar.0 "week" after.isocalendar.1 %}"
</a> class="btn btn-default">
{{ after|date:week_format }}
<span class="fa fa-arrow-right"></span>
</a>
{% endif %}
</div> </div>
{% if multiple_timezones %} {% if multiple_timezones %}

View File

@@ -28,23 +28,23 @@
{% endif %} {% endif %}
<div> <div>
<div class="btn-group" role="group"> <div class="btn-group" role="group">
<a href="?{% url_replace request "style" "list" %}" type="button" <a href="?{% url_replace request "style" "list" "week" "" "year" "" "month" "" %}" type="button"
class="btn btn-default active"> class="btn btn-default active">
<span class="fa fa-list"></span> <span class="fa fa-list"></span>
{% trans "List" %} {% trans "List" %}
</a> </a>
<a href="?{% url_replace request "style" "week" %}" type="button" <a href="?{% url_replace request "style" "week" "month" "" "old" "" "page" "" %}" type="button"
class="btn btn-default"> class="btn btn-default">
<span class="fa fa-calendar"></span> <span class="fa fa-calendar"></span>
{% trans "Week" %} {% trans "Week" %}
</a> </a>
<a href="?{% url_replace request "style" "calendar" %}" type="button" <a href="?{% url_replace request "style" "calendar" "week" "" "old" "" "page" "" %}" type="button"
class="btn btn-default"> class="btn btn-default">
<span class="fa fa-calendar"></span> <span class="fa fa-calendar"></span>
{% trans "Month" %} {% trans "Month" %}
</a> </a>
</div> </div>
<a href="{% eventurl request.organizer "presale:organizer.ical" %}?{% eventurl request.organizer "presale:organizer.ical" %}?{% url_replace request "locale" request.LANGUAGE_CODE "style" "" "month" "" "year" "" %}" <a href="{% eventurl request.organizer "presale:organizer.ical" %}?{% url_replace request "locale" request.LANGUAGE_CODE "page" "" "old" "" "week" "" "style" "" "month" "" "year" "" %}"
class="btn btn-default"> class="btn btn-default">
<span class="fa fa-calendar-plus-o"></span> <span class="fa fa-calendar-plus-o"></span>
{% trans "iCal" %} {% trans "iCal" %}

View File

@@ -299,6 +299,15 @@ class OrganizerIndex(OrganizerViewMixin, EventListMixin, ListView):
return ctx return ctx
def has_before_after(eventqs, subeventqs, before, after):
eqs = eventqs.filter(is_public=True, live=True, has_subevents=False)
sqs = subeventqs.filter(active=True, is_public=True)
return (
eqs.filter(Q(date_from__lte=before)).exists() or sqs.filter(Q(date_from__lte=before)).exists(),
eqs.filter(Q(date_to__gte=after) | Q(date_from__gte=after)).exists() or sqs.filter(Q(date_to__gte=after) | Q(date_from__gte=after)).exists()
)
def add_events_for_days(request, baseqs, before, after, ebd, timezones): def add_events_for_days(request, baseqs, before, after, ebd, timezones):
qs = baseqs.filter(is_public=True, live=True, has_subevents=False).filter( qs = baseqs.filter(is_public=True, live=True, has_subevents=False).filter(
Q(Q(date_to__gte=before) & Q(date_from__lte=after)) | Q(Q(date_to__gte=before) & Q(date_from__lte=after)) |
@@ -478,6 +487,20 @@ class CalendarView(OrganizerViewMixin, EventListMixin, TemplateView):
ctx['after'] = after ctx['after'] = after
ebd = self._events_by_day(before, after) ebd = self._events_by_day(before, after)
ctx['has_before'], ctx['has_after'] = has_before_after(
self.request.organizer.events.filter(
sales_channels__contains=self.request.sales_channel.identifier
),
SubEvent.objects.filter(
event__organizer=self.request.organizer,
event__is_public=True,
event__live=True,
event__sales_channels__contains=self.request.sales_channel.identifier
),
before,
after,
)
ctx['multiple_timezones'] = self._multiple_timezones ctx['multiple_timezones'] = self._multiple_timezones
ctx['weeks'] = weeks_for_template(ebd, self.year, self.month) ctx['weeks'] = weeks_for_template(ebd, self.year, self.month)
ctx['months'] = [date(self.year, i + 1, 1) for i in range(12)] ctx['months'] = [date(self.year, i + 1, 1) for i in range(12)]
@@ -529,6 +552,20 @@ class WeekCalendarView(OrganizerViewMixin, EventListMixin, TemplateView):
ebd = self._events_by_day(before, after) ebd = self._events_by_day(before, after)
ctx['has_before'], ctx['has_after'] = has_before_after(
self.request.organizer.events.filter(
sales_channels__contains=self.request.sales_channel.identifier
),
SubEvent.objects.filter(
event__organizer=self.request.organizer,
event__is_public=True,
event__live=True,
event__sales_channels__contains=self.request.sales_channel.identifier
),
before,
after,
)
ctx['days'] = days_for_template(ebd, week) ctx['days'] = days_for_template(ebd, week)
ctx['weeks'] = [ ctx['weeks'] = [
(date_fromisocalendar(self.year, i + 1, 1), date_fromisocalendar(self.year, i + 1, 7)) (date_fromisocalendar(self.year, i + 1, 1), date_fromisocalendar(self.year, i + 1, 7))