Exemple #1
0
 def event(self, idlist):
     query = (Event.find(
         Event.id.in_(idlist), ~Event.is_deleted,
         Event.happens_between(self._fromDT, self._toDT)).options(
             *self._get_query_options(self._detail_level)))
     query = self._update_query(query)
     return self.serialize_events(
         x for x in query
         if self._filter_event(x) and x.can_access(self.user))
Exemple #2
0
 def category(self, idlist, format):
     try:
         idlist = map(int, idlist)
     except ValueError:
         raise HTTPAPIError('Category IDs must be numeric', 400)
     if format == 'ics':
         buf = serialize_categories_ical(idlist,
                                         self.user,
                                         event_filter=Event.happens_between(
                                             self._fromDT, self._toDT),
                                         event_filter_fn=self._filter_event,
                                         update_query=self._update_query)
         return send_file('events.ics', buf, 'text/calendar')
     else:
         query = (Event.query.filter(
             ~Event.is_deleted, Event.category_chain_overlaps(idlist),
             Event.happens_between(self._fromDT, self._toDT)).options(
                 *self._get_query_options(self._detail_level)))
     query = self._update_query(query)
     return self.serialize_events(
         x for x in query
         if self._filter_event(x) and x.can_access(self.user))
def _query_categ_events(categ, start_dt, end_dt):
    return (Event.query
            .with_parent(categ)
            .filter(Event.happens_between(start_dt, end_dt))
            .options(load_only('id', 'start_dt', 'end_dt')))