forked from CGM_Public/pretix_original
End infinite link tree on organizer calendar pages
This commit is contained in:
@@ -19,24 +19,24 @@
|
||||
{% endfor %}
|
||||
<div class="row">
|
||||
<div class="col-sm-4 col-xs-12 text-left flip">
|
||||
<div class="btn-group" role="group">
|
||||
<a href="?{% url_replace request "style" "list" %}" type="button" class="btn btn-default">
|
||||
<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" "week" "" "year" "" "month" "" %}" type="button" class="btn btn-default">
|
||||
<span class="fa fa-list"></span>
|
||||
{% trans "List" %}
|
||||
</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">
|
||||
<span class="fa fa-calendar"></span>
|
||||
{% trans "Week" %}
|
||||
</a>
|
||||
<a href="?{% url_replace request "style" "calendar" %}"
|
||||
<a href="?{% url_replace request "style" "calendar" "old" "" "week" "" %}"
|
||||
type="button"
|
||||
class="btn btn-default active">
|
||||
<span class="fa fa-calendar"></span>
|
||||
{% trans "Month" %}
|
||||
</a>
|
||||
</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">
|
||||
<span class="fa fa-calendar-plus-o"></span>
|
||||
{% trans "iCal" %}
|
||||
@@ -58,14 +58,18 @@
|
||||
</button>
|
||||
</div>
|
||||
<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">
|
||||
<span class="fa fa-arrow-left"></span>
|
||||
{{ before|date:"F Y" }}
|
||||
</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>
|
||||
{% if has_before %}
|
||||
<a href="?{% url_replace request "year" before.year "month" before.month %}" class="btn btn-default">
|
||||
<span class="fa fa-arrow-left"></span>
|
||||
{{ before|date:"F Y" }}
|
||||
</a>
|
||||
{% endif %}
|
||||
{% if has_after %}
|
||||
<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>
|
||||
</form>
|
||||
|
||||
@@ -11,7 +11,8 @@
|
||||
</div>
|
||||
{% endif %}
|
||||
<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 %}
|
||||
{% if f != "week" and f != "year" %}
|
||||
<input type="hidden" name="{{ f }}" value="{{ v }}">
|
||||
@@ -20,24 +21,25 @@
|
||||
<div class="row">
|
||||
<div class="col-sm-4 hidden-xs text-left flip">
|
||||
<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>
|
||||
{% trans "List" %}
|
||||
</a>
|
||||
<a href="?{% url_replace request "style" "week" %}" type="button"
|
||||
class="btn btn-default active">
|
||||
<a href="?{% url_replace request "style" "week" "month" "" "old" "" %}" type="button"
|
||||
class="btn btn-default active">
|
||||
<span class="fa fa-calendar"></span>
|
||||
{% trans "Week" %}
|
||||
</a>
|
||||
<a href="?{% url_replace request "style" "calendar" %}"
|
||||
type="button"
|
||||
class="btn btn-default">
|
||||
<a href="?{% url_replace request "style" "calendar" "week" "" "old" "" "year" "" %}"
|
||||
type="button"
|
||||
class="btn btn-default">
|
||||
<span class="fa fa-calendar"></span>
|
||||
{% trans "Month" %}
|
||||
</a>
|
||||
</div>
|
||||
<a href="{% eventurl request.organizer "presale:organizer.ical" %}?{% url_replace request "locale" request.LANGUAGE_CODE "style" "" "month" "" "year" "" %}"
|
||||
class="btn btn-default">
|
||||
<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">
|
||||
<span class="fa fa-calendar-plus-o"></span>
|
||||
{% trans "iCal" %}
|
||||
</a>
|
||||
@@ -45,7 +47,10 @@
|
||||
<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>
|
||||
<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 %}
|
||||
</select>
|
||||
<select name="year" class="form-control">
|
||||
@@ -58,16 +63,20 @@
|
||||
</button>
|
||||
</div>
|
||||
<div class="col-sm-4 hidden-xs text-right flip">
|
||||
<a href="?{% url_replace request "year" before.isocalendar.0 "week" before.isocalendar.1 %}"
|
||||
class="btn btn-default">
|
||||
<span class="fa fa-arrow-left"></span>
|
||||
{{ before|date:week_format }}
|
||||
</a>
|
||||
<a href="?{% url_replace request "year" after.isocalendar.0 "week" after.isocalendar.1 %}"
|
||||
class="btn btn-default">
|
||||
{{ after|date:week_format }}
|
||||
<span class="fa fa-arrow-right"></span>
|
||||
</a>
|
||||
{% if has_before %}
|
||||
<a href="?{% url_replace request "year" before.isocalendar.0 "week" before.isocalendar.1 %}"
|
||||
class="btn btn-default">
|
||||
<span class="fa fa-arrow-left"></span>
|
||||
{{ before|date:week_format }}
|
||||
</a>
|
||||
{% endif %}
|
||||
{% if has_after %}
|
||||
<a href="?{% url_replace request "year" after.isocalendar.0 "week" after.isocalendar.1 %}"
|
||||
class="btn btn-default">
|
||||
{{ after|date:week_format }}
|
||||
<span class="fa fa-arrow-right"></span>
|
||||
</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% for f, v in request.GET.items %}
|
||||
@@ -78,16 +87,20 @@
|
||||
</form>
|
||||
{% include "pretixpresale/fragment_week_calendar.html" with show_avail=request.organizer.settings.event_list_availability %}
|
||||
<div class="col-sm-4 visible-xs text-center">
|
||||
<a href="?{% url_replace request "year" before.isocalendar.0 "week" before.isocalendar.1 %}"
|
||||
class="btn btn-default">
|
||||
<span class="fa fa-arrow-left"></span>
|
||||
{{ before|date:week_format }}
|
||||
</a>
|
||||
<a href="?{% url_replace request "year" after.isocalendar.0 "week" after.isocalendar.1 %}"
|
||||
class="btn btn-default">
|
||||
{{ after|date:week_format }}
|
||||
<span class="fa fa-arrow-right"></span>
|
||||
</a>
|
||||
{% if has_before %}
|
||||
<a href="?{% url_replace request "year" before.isocalendar.0 "week" before.isocalendar.1 %}"
|
||||
class="btn btn-default">
|
||||
<span class="fa fa-arrow-left"></span>
|
||||
{{ before|date:week_format }}
|
||||
</a>
|
||||
{% endif %}
|
||||
{% if has_after %}
|
||||
<a href="?{% url_replace request "year" after.isocalendar.0 "week" after.isocalendar.1 %}"
|
||||
class="btn btn-default">
|
||||
{{ after|date:week_format }}
|
||||
<span class="fa fa-arrow-right"></span>
|
||||
</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
{% if multiple_timezones %}
|
||||
|
||||
@@ -28,23 +28,23 @@
|
||||
{% endif %}
|
||||
<div>
|
||||
<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">
|
||||
<span class="fa fa-list"></span>
|
||||
{% trans "List" %}
|
||||
</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">
|
||||
<span class="fa fa-calendar"></span>
|
||||
{% trans "Week" %}
|
||||
</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">
|
||||
<span class="fa fa-calendar"></span>
|
||||
{% trans "Month" %}
|
||||
</a>
|
||||
</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">
|
||||
<span class="fa fa-calendar-plus-o"></span>
|
||||
{% trans "iCal" %}
|
||||
|
||||
@@ -299,6 +299,15 @@ class OrganizerIndex(OrganizerViewMixin, EventListMixin, ListView):
|
||||
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):
|
||||
qs = baseqs.filter(is_public=True, live=True, has_subevents=False).filter(
|
||||
Q(Q(date_to__gte=before) & Q(date_from__lte=after)) |
|
||||
@@ -478,6 +487,20 @@ class CalendarView(OrganizerViewMixin, EventListMixin, TemplateView):
|
||||
ctx['after'] = 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['weeks'] = weeks_for_template(ebd, self.year, self.month)
|
||||
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)
|
||||
|
||||
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['weeks'] = [
|
||||
(date_fromisocalendar(self.year, i + 1, 1), date_fromisocalendar(self.year, i + 1, 7))
|
||||
|
||||
Reference in New Issue
Block a user