From da7d6ab927db1482c90540d723f259cd5ee37579 Mon Sep 17 00:00:00 2001 From: James Murty Date: Wed, 22 Feb 2017 12:46:26 +1100 Subject: [PATCH] Render occurrences for Event content listing, not events Generate and render Occurrence instances when listing events within the event content listing plugin, since the occurrences are what we really want especially for rendering them in the appropriate order. --- .../plugins/event_content_listing/abstract_models.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/icekit_events/plugins/event_content_listing/abstract_models.py b/icekit_events/plugins/event_content_listing/abstract_models.py index 2a0b777..65587ed 100644 --- a/icekit_events/plugins/event_content_listing/abstract_models.py +++ b/icekit_events/plugins/event_content_listing/abstract_models.py @@ -7,7 +7,7 @@ from timezone import timezone as djtz # django-timezone -from icekit_events.models import EventType +from icekit_events.models import EventType, Occurrence from icekit.plugins.content_listing.abstract_models import \ AbstractContentListingItem @@ -54,13 +54,12 @@ def __str__(self): return 'Event Content Listing of %s' % self.content_type def get_items(self): - qs = super(AbstractEventContentListingItem, self).get_items( - apply_limit=False) + qs = Occurrence.objects.visible().distinct() if self.limit_to_types.count(): types = self.limit_to_types.all() qs = qs.filter( - Q(primary_type__in=types) | - Q(secondary_types__in=types) + Q(event__primary_type__in=types) | + Q(event__secondary_types__in=types) ) # Apply `from_date` and `to_date` limits qs = qs.overlapping(self.from_date, self.to_date) @@ -72,8 +71,6 @@ def get_items(self): if self.to_days_ahead is not None: to_date = today + timedelta(days=self.to_days_ahead) qs = qs.overlapping(from_date, to_date) - # Apply a sensible default ordering - qs = qs.order_by_first_occurrence() if self.limit: qs = qs[:self.limit] return qs