Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Commit

Permalink
Render occurrences for Event content listing, not events
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jmurty committed Feb 22, 2017
1 parent 820164a commit da7d6ab
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions icekit_events/plugins/event_content_listing/abstract_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)
Expand All @@ -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

0 comments on commit da7d6ab

Please sign in to comment.