# Path: schedule/settings.py
# USE_FULLCALENDAR = getattr(settings, "USE_FULLCALENDAR", False)
# 
# Path: schedule/utils.py
# class EventListManager:
#     """
#     This class is responsible for doing functions on a list of events. It is
#     used to when one has a list of events and wants to access the occurrences
#     from these events in as a group
#     """
# 
#     def __init__(self, events):
#         self.events = events
# 
#     def occurrences_after(self, after=None):
#         """
#         It is often useful to know what the next occurrence is given a list of
#         events.  This function produces a generator that yields the
#         the most recent occurrence after the date ``after`` from any of the
#         events in ``self.events``
#         """
#         from schedule.models import Occurrence
# 
#         if after is None:
#             after = timezone.now()
#         occ_replacer = OccurrenceReplacer(
#             Occurrence.objects.filter(event__in=self.events)
#         )
#         generators = [
#             event._occurrences_after_generator(after) for event in self.events
#         ]
#         occurrences = []
# 
#         for generator in generators:
#             try:
#                 heapq.heappush(occurrences, (next(generator), generator))
#             except StopIteration:
#                 pass
# 
#         while occurrences:
#             generator = occurrences[0][1]
# 
#             try:
#                 next_occurrence = heapq.heapreplace(
#                     occurrences, (next(generator), generator)
#                 )[0]
#             except StopIteration:
#                 next_occurrence = heapq.heappop(occurrences)[0]
#             yield occ_replacer.get_occurrence(next_occurrence)


from django.contrib.contenttypes import fields
from django.contrib.contenttypes.models import ContentType
from django.db import models
from django.db.models import Q
from django.template.defaultfilters import slugify
from django.urls import reverse
from django.utils import timezone
from django.utils.translation import gettext_lazy as _
from schedule.settings import USE_FULLCALENDAR
from schedule.utils import EventListManager
        verbose_name = _("calendar")
        verbose_name_plural = _("calendars")

    def __str__(self):
        return self.name

    @property
    def events(self):
        return self.event_set

    def create_relation(self, obj, distinction="", inheritable=True):
        """
        Creates a CalendarRelation between self and obj.

        if Inheritable is set to true this relation will cascade to all events
        related to this calendar.
        """
        CalendarRelation.objects.create_relation(self, obj, distinction, inheritable)

    def get_recent(self, amount=5):
        """
        This shortcut function allows you to get events that have started
        recently.

        amount is the amount of events you want in the queryset. The default is
        5.
        """
        return self.events.order_by("-start").filter(start__lt=timezone.now())[:amount]

    def occurrences_after(self, date=None):

# Path: schedule/settings.py
# USE_FULLCALENDAR = getattr(settings, "USE_FULLCALENDAR", False)
# 
# Path: schedule/utils.py
# class EventListManager:
#     """
#     This class is responsible for doing functions on a list of events. It is
#     used to when one has a list of events and wants to access the occurrences
#     from these events in as a group
#     """
# 
#     def __init__(self, events):
#         self.events = events
# 
#     def occurrences_after(self, after=None):
#         """
#         It is often useful to know what the next occurrence is given a list of
#         events.  This function produces a generator that yields the
#         the most recent occurrence after the date ``after`` from any of the
#         events in ``self.events``
#         """
#         from schedule.models import Occurrence
# 
#         if after is None:
#             after = timezone.now()
#         occ_replacer = OccurrenceReplacer(
#             Occurrence.objects.filter(event__in=self.events)
#         )
#         generators = [
#             event._occurrences_after_generator(after) for event in self.events
#         ]
#         occurrences = []
# 
#         for generator in generators:
#             try:
#                 heapq.heappush(occurrences, (next(generator), generator))
#             except StopIteration:
#                 pass
# 
#         while occurrences:
#             generator = occurrences[0][1]
# 
#             try:
#                 next_occurrence = heapq.heapreplace(
#                     occurrences, (next(generator), generator)
#                 )[0]
#             except StopIteration:
#                 next_occurrence = heapq.heappop(occurrences)[0]
#             yield occ_replacer.get_occurrence(next_occurrence)


# Path: schedule/models/calendars.py
from django.contrib.contenttypes import fields
from django.contrib.contenttypes.models import ContentType
from django.db import models
from django.db.models import Q
from django.template.defaultfilters import slugify
from django.urls import reverse
from django.utils import timezone
from django.utils.translation import gettext_lazy as _
from schedule.settings import USE_FULLCALENDAR
from schedule.utils import EventListManager

        verbose_name = _("calendar")
        verbose_name_plural = _("calendars")

    def __str__(self):
        return self.name

    @property
    def events(self):
        return self.event_set

    def create_relation(self, obj, distinction="", inheritable=True):
        """
        Creates a CalendarRelation between self and obj.

        if Inheritable is set to true this relation will cascade to all events
        related to this calendar.
        """
        CalendarRelation.objects.create_relation(self, obj, distinction, inheritable)

    def get_recent(self, amount=5):
        """
        This shortcut function allows you to get events that have started
        recently.

        amount is the amount of events you want in the queryset. The default is
        5.
        """
        return self.events.order_by("-start").filter(start__lt=timezone.now())[:amount]

    def occurrences_after(self, date=None):

        return EventListManager(self.events.all()).occurrences_after(date)