當前位置: 首頁>>代碼示例>>Python>>正文


Python Event.is_visible_in方法代碼示例

本文整理匯總了Python中indico.modules.events.models.events.Event.is_visible_in方法的典型用法代碼示例。如果您正苦於以下問題:Python Event.is_visible_in方法的具體用法?Python Event.is_visible_in怎麽用?Python Event.is_visible_in使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在indico.modules.events.models.events.Event的用法示例。


在下文中一共展示了Event.is_visible_in方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _get_upcoming_event

# 需要導入模塊: from indico.modules.events.models.events import Event [as 別名]
# 或者: from indico.modules.events.models.events.Event import is_visible_in [as 別名]
 def _get_upcoming_event(self):
     query = (Event.query
              .filter(Event.is_visible_in(self.category),
                      Event.start_dt > now_utc(),
                      ~Event.is_deleted)
              .options(subqueryload('acl_entries'))
              .order_by(Event.start_dt, Event.id))
     res = get_n_matching(query, 1, lambda event: event.can_access(session.user))
     if res:
         return res[0]
開發者ID:jas01,項目名稱:indico,代碼行數:12,代碼來源:display.py

示例2: _process

# 需要導入模塊: from indico.modules.events.models.events import Event [as 別名]
# 或者: from indico.modules.events.models.events.Event import is_visible_in [as 別名]
 def _process(self):
     if not request.is_xhr:
         return WPCategory.render_template('display/calendar.html', self.category,
                                           start_dt=request.args.get('start_dt'))
     tz = self.category.display_tzinfo
     start = tz.localize(dateutil.parser.parse(request.args['start'])).astimezone(utc)
     end = tz.localize(dateutil.parser.parse(request.args['end'])).astimezone(utc)
     query = (Event.query
              .filter(Event.starts_between(start, end),
                      Event.is_visible_in(self.category),
                      ~Event.is_deleted)
              .options(load_only('id', 'title', 'start_dt', 'end_dt', 'category_id')))
     events = self._get_event_data(query)
     ongoing_events = (Event.query
                       .filter(Event.is_visible_in(self.category),
                               Event.start_dt < start,
                               Event.end_dt > end)
                       .options(load_only('id', 'title', 'start_dt', 'end_dt', 'timezone'))
                       .order_by(Event.title)
                       .all())
     return jsonify_data(flash=False, events=events, ongoing_event_count=len(ongoing_events),
                         ongoing_events_html=self._render_ongoing_events(ongoing_events))
開發者ID:OmeGak,項目名稱:indico,代碼行數:24,代碼來源:display.py

示例3: get_category_timetable

# 需要導入模塊: from indico.modules.events.models.events import Event [as 別名]
# 或者: from indico.modules.events.models.events.Event import is_visible_in [as 別名]
def get_category_timetable(categ_ids, start_dt, end_dt, detail_level='event', tz=utc, from_categ=None, grouped=True):
    """Retrieve time blocks that fall within a specific time interval
       for a given set of categories.

       :param categ_ids: iterable containing list of category IDs
       :param start_dt: start of search interval (``datetime``, expected
                        to be in display timezone)
       :param end_dt: end of search interval (``datetime`` in expected
                      to be in display timezone)
       :param detail_level: the level of detail of information
                            (``event|session|contribution``)
       :param tz: the ``timezone`` information should be displayed in
       :param from_categ: ``Category`` that will be taken into account to calculate
                          visibility
       :param grouped: Whether to group results by start date
       :returns: a dictionary containing timetable information in a
                 structured way. See source code for examples.
    """
    day_start = start_dt.astimezone(utc)
    day_end = end_dt.astimezone(utc)
    dates_overlap = lambda t: (t.start_dt >= day_start) & (t.start_dt <= day_end)

    items = defaultdict(lambda: defaultdict(list))

    # first of all, query TimetableEntries/events that fall within
    # specified range of dates (and category set)
    events = _query_events(categ_ids, day_start, day_end)
    if from_categ:
        events = events.filter(Event.is_visible_in(from_categ))
    for eid, tt_start_dt in events:
        if tt_start_dt:
            items[eid][tt_start_dt.astimezone(tz).date()].append(tt_start_dt)
        else:
            items[eid] = None

    # then, retrieve detailed information about the events
    event_ids = set(items)
    query = (Event.find(Event.id.in_(event_ids))
             .options(subqueryload(Event.person_links).joinedload(EventPersonLink.person),
                      joinedload(Event.own_room).noload('owner'),
                      joinedload(Event.own_venue),
                      joinedload(Event.category).undefer('effective_icon_data'),
                      undefer('effective_protection_mode')))
    scheduled_events = defaultdict(list)
    ongoing_events = []
    events = []
    for e in query:
        if grouped:
            local_start_dt = e.start_dt.astimezone(tz).date()
            local_end_dt = e.end_dt.astimezone(tz).date()
            if items[e.id] is None:
                # if there is no TimetableEntry, this means the event has not timetable on that interval
                for day in iterdays(max(start_dt.date(), local_start_dt), min(end_dt.date(), local_end_dt)):
                    # if the event starts on this date, we've got a time slot
                    if day.date() == local_start_dt:
                        scheduled_events[day.date()].append((e.start_dt, e))
                    else:
                        ongoing_events.append(e)
            else:
                for start_d, start_dts in items[e.id].viewitems():
                    scheduled_events[start_d].append((start_dts[0], e))
        else:
            events.append(e)

    # result['events'][date(...)] -> [(datetime(....), Event(...))]
    # result[event_id]['contribs'][date(...)] -> [(TimetableEntry(...), Contribution(...))]
    # result['ongoing_events'] = [Event(...)]
    if grouped:
        result = defaultdict(lambda: defaultdict(lambda: defaultdict(list)))
    else:
        result = defaultdict(lambda: defaultdict(list))

    result.update({
        'events': scheduled_events if grouped else events,
        'ongoing_events': ongoing_events
    })

    # according to detail level, ask for extra information from the DB
    if detail_level != 'event':
        query = _query_blocks(event_ids, dates_overlap, detail_level)
        if grouped:
            for b in query:
                start_date = b.timetable_entry.start_dt.astimezone(tz).date()
                result[b.session.event_id]['blocks'][start_date].append((b.timetable_entry, b))
        else:
            for b in query:
                result[b.session.event_id]['blocks'].append(b)

    if detail_level == 'contribution':
        query = (Contribution.find(Contribution.event_id.in_(event_ids),
                                   dates_overlap(TimetableEntry),
                                   ~Contribution.is_deleted)
                 .options(contains_eager(Contribution.timetable_entry),
                          joinedload(Contribution.person_links))
                 .join(TimetableEntry))
        if grouped:
            for c in query:
                start_date = c.timetable_entry.start_dt.astimezone(tz).date()
                result[c.event_id]['contribs'][start_date].append((c.timetable_entry, c))
        else:
#.........這裏部分代碼省略.........
開發者ID:OmeGak,項目名稱:indico,代碼行數:103,代碼來源:util.py


注:本文中的indico.modules.events.models.events.Event.is_visible_in方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。