forked from CGM_Public/pretix_original
Subevent calendar: Improve heuristic on when to show names (#2308)
This commit is contained in:
@@ -569,9 +569,14 @@ class EventIndex(EventViewMixin, EventListMixin, CartMixin, TemplateView):
|
|||||||
voucher,
|
voucher,
|
||||||
)
|
)
|
||||||
|
|
||||||
context['show_names'] = ebd.get('_subevents_different_names', False) or sum(
|
# Hide names of subevents in event series where it is always the same. No need to show the name of the museum thousands of times
|
||||||
len(i) for i in ebd.values() if isinstance(i, list)
|
# in the calendar. We previously only looked at the current time range for this condition which caused weird side-effects, so we need
|
||||||
) < 2
|
# an extra query to look at the entire series. For performance reasons, we have a limit on how many different names we look at.
|
||||||
|
context['show_names'] = sum(len(i) for i in ebd.values() if isinstance(i, list)) < 2 or self.request.event.cache.get_or_set(
|
||||||
|
'has_different_subevent_names',
|
||||||
|
lambda: len(set(str(n) for n in self.request.event.subevents.values_list('name', flat=True).annotate(c=Count('*'))[:250])) != 1,
|
||||||
|
timeout=120,
|
||||||
|
)
|
||||||
context['weeks'] = weeks_for_template(ebd, self.year, self.month)
|
context['weeks'] = weeks_for_template(ebd, self.year, self.month)
|
||||||
context['months'] = [date(self.year, i + 1, 1) for i in range(12)]
|
context['months'] = [date(self.year, i + 1, 1) for i in range(12)]
|
||||||
context['years'] = range(now().year - 2, now().year + 3)
|
context['years'] = range(now().year - 2, now().year + 3)
|
||||||
@@ -598,9 +603,14 @@ class EventIndex(EventViewMixin, EventListMixin, CartMixin, TemplateView):
|
|||||||
voucher,
|
voucher,
|
||||||
)
|
)
|
||||||
|
|
||||||
context['show_names'] = ebd.get('_subevents_different_names', False) or sum(
|
# Hide names of subevents in event series where it is always the same. No need to show the name of the museum thousands of times
|
||||||
len(i) for i in ebd.values() if isinstance(i, list)
|
# in the calendar. We previously only looked at the current time range for this condition which caused weird side-effects, so we need
|
||||||
) < 2
|
# an extra query to look at the entire series. For performance reasons, we have a limit on how many different names we look at.
|
||||||
|
context['show_names'] = sum(len(i) for i in ebd.values() if isinstance(i, list)) < 2 or self.request.event.cache.get_or_set(
|
||||||
|
'has_different_subevent_names',
|
||||||
|
lambda: len(set(str(n) for n in self.request.event.subevents.values_list('name', flat=True).annotate(c=Count('*'))[:250])) != 1,
|
||||||
|
timeout=120,
|
||||||
|
)
|
||||||
context['days'] = days_for_template(ebd, week)
|
context['days'] = days_for_template(ebd, week)
|
||||||
context['weeks'] = [
|
context['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))
|
||||||
|
|||||||
@@ -470,7 +470,6 @@ def add_subevents_for_days(qs, before, after, ebd, timezones, event=None, cart_n
|
|||||||
if se.presale_is_running:
|
if se.presale_is_running:
|
||||||
quotas_to_compute += se.active_quotas
|
quotas_to_compute += se.active_quotas
|
||||||
|
|
||||||
name = None
|
|
||||||
qcache = {}
|
qcache = {}
|
||||||
if quotas_to_compute:
|
if quotas_to_compute:
|
||||||
qa = QuotaAvailability()
|
qa = QuotaAvailability()
|
||||||
@@ -500,10 +499,6 @@ def add_subevents_for_days(qs, before, after, ebd, timezones, event=None, cart_n
|
|||||||
tz = pytz.timezone(s.timezone)
|
tz = pytz.timezone(s.timezone)
|
||||||
datetime_from = se.date_from.astimezone(tz)
|
datetime_from = se.date_from.astimezone(tz)
|
||||||
date_from = datetime_from.date()
|
date_from = datetime_from.date()
|
||||||
if name is None:
|
|
||||||
name = str(se.name)
|
|
||||||
elif str(se.name) != name:
|
|
||||||
ebd['_subevents_different_names'] = True
|
|
||||||
if s.show_date_to and se.date_to:
|
if s.show_date_to and se.date_to:
|
||||||
datetime_to = se.date_to.astimezone(tz)
|
datetime_to = se.date_to.astimezone(tz)
|
||||||
date_to = se.date_to.astimezone(tz).date()
|
date_to = se.date_to.astimezone(tz).date()
|
||||||
|
|||||||
Reference in New Issue
Block a user