def upcoming_events(now=timezone.localtime(timezone.now()), finish=90, num=5): finish = now + timezone.timedelta(days=finish) all_upcoming = (UpcomingEvents(x, now, finish, num).get_upcoming_events() for x in Event.objects.live(now)) upcoming = heapq.nsmallest(num, (item for sublist in all_upcoming for item in sublist), key=lambda x: x[0]) return {'upcoming_events': upcoming}
def upcoming_events(now=None, finish=90, num=5): if now is None: now = get_now() finish = now + timezone.timedelta(days=finish) finish = finish.replace(hour=23, minute=59, second=59, microsecond=999) all_upcoming = (UpcomingEvents(x, now, finish, num).get_upcoming_events() for x in Event.objects.live(now)) upcoming = heapq.nsmallest( num, (item for sublist in all_upcoming for item in sublist), key=lambda x: x[0] ) return {'upcoming_events': upcoming}
def upcoming_events(self, event, d, fin, num=5): return UpcomingEvents(event, d, fin, num).get_upcoming_events()