879 |
879 |
if e.desk_id == desk.pk or e.unavailability_calendar_id in uc_ids
|
880 |
880 |
]
|
881 |
881 |
|
|
882 |
@staticmethod
|
|
883 |
def prefetch_recurring_events(qs):
|
|
884 |
recurring_event_queryset = Event.objects.filter(
|
|
885 |
Q(publication_datetime__isnull=True) | Q(publication_datetime__lte=now()),
|
|
886 |
recurrence_days__isnull=False,
|
|
887 |
)
|
|
888 |
qs = qs.prefetch_related(
|
|
889 |
Prefetch(
|
|
890 |
'event_set',
|
|
891 |
queryset=recurring_event_queryset,
|
|
892 |
to_attr='prefetched_recurring_events',
|
|
893 |
)
|
|
894 |
)
|
|
895 |
return qs
|
|
896 |
|
882 |
897 |
@staticmethod
|
883 |
898 |
def prefetch_events_and_exceptions(
|
884 |
899 |
qs, user_external_id=None, show_past_events=False, min_start=None, max_start=None
|
... | ... | |
898 |
913 |
if max_start:
|
899 |
914 |
event_queryset = event_queryset.filter(start_datetime__lt=max_start)
|
900 |
915 |
|
901 |
|
recurring_event_queryset = Event.objects.filter(
|
902 |
|
Q(publication_datetime__isnull=True) | Q(publication_datetime__lte=now()),
|
903 |
|
recurrence_days__isnull=False,
|
904 |
|
)
|
905 |
916 |
exceptions_desk = Desk.objects.filter(slug='_exceptions_holder').prefetch_related(
|
906 |
917 |
'unavailability_calendars'
|
907 |
918 |
)
|
... | ... | |
911 |
922 |
queryset=event_queryset,
|
912 |
923 |
to_attr='prefetched_events',
|
913 |
924 |
),
|
914 |
|
Prefetch(
|
915 |
|
'event_set',
|
916 |
|
queryset=recurring_event_queryset,
|
917 |
|
to_attr='prefetched_recurring_events',
|
918 |
|
),
|
919 |
925 |
Prefetch(
|
920 |
926 |
'desk_set',
|
921 |
927 |
queryset=exceptions_desk,
|
922 |
928 |
to_attr='prefetched_desks',
|
923 |
929 |
),
|
924 |
930 |
)
|
|
931 |
qs = Agenda.prefetch_recurring_events(qs)
|
925 |
932 |
agendas_exceptions = TimePeriodException.objects.filter(
|
926 |
933 |
Q(desk__slug='_exceptions_holder', desk__agenda__in=qs)
|
927 |
934 |
| Q(
|
928 |
|
-
|