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


Python events.Event類代碼示例

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


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

示例1: _process_args

 def _process_args(self):
     self.event = Event.find(id=request.view_args['event_id'], is_deleted=False).first_or_404()
     self._registration = (self.event.registrations
                           .filter_by(id=request.view_args['registrant_id'],
                                      is_deleted=False)
                           .options(joinedload('data').joinedload('field_data'))
                           .first_or_404())
開發者ID:indico,項目名稱:indico,代碼行數:7,代碼來源:api.py

示例2: _query_events

def _query_events(categ_ids, day_start, day_end):
    event = db.aliased(Event)
    dates_overlap = lambda t: (t.start_dt >= day_start) & (t.start_dt <= day_end)
    return (db.session.query(Event.id, TimetableEntry.start_dt)
            .filter(
                Event.category_chain_overlaps(categ_ids),
                ~Event.is_deleted,
                ((Event.timetable_entries.any(dates_overlap(TimetableEntry))) |
                 (Event.query.exists().where(
                     Event.happens_between(day_start, day_end) &
                     (Event.id == event.id)))))
            .group_by(Event.id, TimetableEntry.start_dt)
            .order_by(Event.id, TimetableEntry.start_dt)
            .join(TimetableEntry,
                  (TimetableEntry.event_id == Event.id) & (dates_overlap(TimetableEntry)),
                  isouter=True))
開發者ID:OmeGak,項目名稱:indico,代碼行數:16,代碼來源:util.py

示例3: migrate_layout_settings

    def migrate_layout_settings(self):
        print cformat('%{white!}migrating layout settings, event logos and custom stylesheets')

        default_styles = self.zodb_root['MaKaCInfo']['main']._styleMgr._defaultEventStylesheet
        for event, event_type, dmgr, logo, custom_css in committing_iterator(self._iter_event_layout_data()):
            if event_type != 'conference':
                theme = dmgr._defaultstyle
                if not theme or theme == default_styles[event_type]:
                    continue
                layout_settings.set(event, 'timetable_theme', theme)
                if not self.quiet:
                    self.print_success(cformat('- %{cyan}Default timetable theme: {}').format(theme), event_id=event.id)
                continue

            settings = self._get_event_settings(event, dmgr)
            layout_settings.set_multi(event, settings)
            if not self.quiet:
                self.print_success(cformat('- %{cyan}Layout settings'), event_id=event.id)
            if logo or custom_css:
                sa_event = Event.get(event.id)
                if not sa_event:
                    self.print_warning('Event does not exist (anymore)! Logo and/or CSS file not saved!',
                                       event_id=event.id)
                    continue
            if logo:
                self._process_logo(logo, sa_event)
            if custom_css:
                self._process_css(custom_css, sa_event)
開發者ID:OmeGak,項目名稱:indico,代碼行數:28,代碼來源:event_layout.py

示例4: get_not_deletable_templates

def get_not_deletable_templates(obj):
    """Get all non-deletable templates for an event/category"""

    not_deletable_criteria = [
        DesignerTemplate.is_system_template,
        DesignerTemplate.backside_template_of != None,  # noqa
        DesignerTemplate.ticket_for_regforms.any(RegistrationForm.event.has(Event.ends_after(now_utc())))
    ]
    return set(DesignerTemplate.query.filter(DesignerTemplate.owner == obj, db.or_(*not_deletable_criteria)))
開發者ID:bkolobara,項目名稱:indico,代碼行數:9,代碼來源:util.py

示例5: _get_upcoming_event

 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,代碼行數:10,代碼來源:display.py

示例6: _process

 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,代碼行數:22,代碼來源:display.py

示例7: get_room_events

def get_room_events(room, start_dt, end_dt, repeat_frequency, repeat_interval):
    occurrences = ReservationOccurrence.create_series(start_dt, end_dt, (repeat_frequency, repeat_interval))
    excluded_categories = rb_settings.get('excluded_categories')
    return (Event.query
            .filter(~Event.is_deleted,
                    Event.own_room == room,
                    db.or_(Event.happens_between(as_utc(occ.start_dt), as_utc(occ.end_dt)) for occ in occurrences),
                    Event.timezone == config.DEFAULT_TIMEZONE,
                    db.and_(Event.category_id != cat['id'] for cat in excluded_categories),
                    Event.acl_entries.any(db.and_(EventPrincipal.type == PrincipalType.user,
                                                  EventPrincipal.user_id == session.user.id,
                                                  EventPrincipal.full_access)))
            .all())
開發者ID:pferreir,項目名稱:indico,代碼行數:13,代碼來源:rooms.py

示例8: _category_moved

def _category_moved(category, old_parent, new_parent, **kwargs):
    events = Event.find(Event.category_chain.contains([int(category.id)])).all()
    # update the category chain of all events from the moved category
    for event in events:
        event.category_chain = map(int, reversed(event.category.getCategoryPath()))
    # update the category chain of all events from the target category
    for event in g.get('detached_events_moved', set()):
        # the event was in the target category of of the category move
        assert event.category_id == int(new_parent.id)
        # and it is now in the category that has just been moved
        assert int(event.as_legacy.getOwner().id) == int(category.id)
        # this will also update the chain (sqlalchemy hook)
        event.category_id = int(category.id)
開發者ID:belokop,項目名稱:indico_bare,代碼行數:13,代碼來源:__init__.py

示例9: _process_args

    def _process_args(self):
        data = request.json
        self.object = None
        if 'categId' in data:
            self.object = Category.get_one(data['categId'])
        elif 'contribId' in data:
            self.object = Contribution.get_one(data['contribId'])
        elif 'sessionId' in data:
            self.object = Session.get_one(data['sessionId'])
        elif 'confId' in data:
            self.object = Event.get_one(data['confId'])

        if self.object is None:
            raise BadRequest
開發者ID:bkolobara,項目名稱:indico,代碼行數:14,代碼來源:controllers.py

示例10: get_events_registered

def get_events_registered(user, dt=None):
    """Gets the IDs of events where the user is registered.

    :param user: A `User`
    :param dt: Only include events taking place on/after that date
    :return: A set of event ids
    """
    query = (user.registrations
             .options(load_only('event_id'))
             .options(joinedload(Registration.registration_form).load_only('event_id'))
             .join(Registration.registration_form)
             .join(RegistrationForm.event)
             .filter(Registration.is_active, ~RegistrationForm.is_deleted, ~Event.is_deleted,
                     Event.ends_after(dt)))
    return {registration.event_id for registration in query}
開發者ID:bkolobara,項目名稱:indico,代碼行數:15,代碼來源:util.py

示例11: add_contrib_data

 def add_contrib_data():
     has_contrib = (EventPerson.contribution_links.any(
         ContributionPersonLink.contribution.has(~Contribution.is_deleted)))
     has_subcontrib = EventPerson.subcontribution_links.any(
         SubContributionPersonLink.subcontribution.has(db.and_(
             ~SubContribution.is_deleted,
             SubContribution.contribution.has(~Contribution.is_deleted))))
     query = (Event.query
              .options(load_only('id'))
              .options(noload('*'))
              .filter(~Event.is_deleted,
                      Event.ends_after(dt),
                      Event.persons.any((EventPerson.user_id == user.id) & (has_contrib | has_subcontrib))))
     for event in query:
         data[event.id].add('contributor')
開發者ID:DirkHoffmann,項目名稱:indico,代碼行數:15,代碼來源:util.py

示例12: _process_cascaded_category_contents

def _process_cascaded_category_contents(records):
    """
    Travel from categories to subcontributions, flattening the whole event structure.

    Yields everything that it finds (except for elements whose protection has changed
    but are not inheriting their protection settings from anywhere).

    :param records: queue records to process
    """
    category_prot_records = {rec.category_id for rec in records if rec.type == EntryType.category
                             and rec.change == ChangeType.protection_changed}
    category_move_records = {rec.category_id for rec in records if rec.type == EntryType.category
                             and rec.change == ChangeType.moved}

    changed_events = set()

    category_prot_records -= category_move_records  # A move already implies sending the whole record

    # Protection changes are handled differently, as there may not be the need to re-generate the record
    if category_prot_records:
        for categ in Category.find(Category.id.in_(category_prot_records)):
            cte = categ.get_protection_parent_cte()
            # Update only children that inherit
            inheriting_categ_children = (Event.query
                                         .join(cte, db.and_((Event.category_id == cte.c.id),
                                                            (cte.c.protection_parent == categ.id))))
            inheriting_direct_children = Event.find((Event.category_id == categ.id) & Event.is_inheriting)

            changed_events.update(itertools.chain(inheriting_direct_children, inheriting_categ_children))

    # Add move operations and explicitly-passed event records
    if category_move_records:
        changed_events.update(Event.find(Event.category_chain_overlaps(category_move_records)))

    for elem in _process_cascaded_event_contents(records, additional_events=changed_events):
        yield elem
開發者ID:indico,項目名稱:indico-plugins,代碼行數:36,代碼來源:simplify.py

示例13: get_events_registered

def get_events_registered(user, from_dt=None, to_dt=None):
    """Gets the IDs of events where the user is registered.

    :param user: A `User`
    :param from_dt: The earliest event start time to look for
    :param to_dt: The latest event start time to look for
    :return: A set of event ids
    """
    query = (user.registrations
             .options(load_only('event_id'))
             .options(joinedload(Registration.registration_form).load_only('event_id'))
             .join(Registration.registration_form)
             .join(RegistrationForm.event_new)
             .filter(Registration.is_active, ~RegistrationForm.is_deleted, ~Event.is_deleted,
                     Event.starts_between(from_dt, to_dt)))
    return {registration.event_id for registration in query}
開發者ID:belokop,項目名稱:indico_bare,代碼行數:16,代碼來源:util.py

示例14: add_acl_data

 def add_acl_data():
     query = (user.in_contribution_acls
              .options(load_only('contribution_id', 'roles', 'full_access', 'read_access'))
              .options(noload('*'))
              .options(contains_eager(ContributionPrincipal.contribution).load_only('event_id'))
              .join(Contribution)
              .join(Event, Event.id == Contribution.event_id)
              .filter(~Contribution.is_deleted, ~Event.is_deleted, Event.ends_after(dt)))
     for principal in query:
         roles = data[principal.contribution.event_id]
         if 'submit' in principal.roles:
             roles.add('contribution_submission')
         if principal.full_access:
             roles.add('contribution_manager')
         if principal.read_access:
             roles.add('contribution_access')
開發者ID:DirkHoffmann,項目名稱:indico,代碼行數:16,代碼來源:util.py

示例15: _process_cascaded_event_contents

def _process_cascaded_event_contents(records, additional_events=None):
    """
    Flatten a series of records into its most basic elements (subcontribution level).

    Yields results.

    :param records: queue records to process
    :param additional_events: events whose content will be included in addition to those
                              found in records
    """
    changed_events = additional_events or set()
    changed_contributions = set()
    changed_subcontributions = set()

    session_records = {rec.session_id for rec in records if rec.type == EntryType.session}
    contribution_records = {rec.contrib_id for rec in records if rec.type == EntryType.contribution}
    subcontribution_records = {rec.subcontrib_id for rec in records if rec.type == EntryType.subcontribution}
    event_records = {rec.event_id for rec in records if rec.type == EntryType.event}

    if event_records:
        changed_events.update(Event.find(Event.id.in_(event_records)))

    for event in changed_events:
        yield event

    # Sessions are added (explicitly changed only, since they don't need to be sent anywhere)
    if session_records:
        changed_contributions.update(Contribution
                                     .find(Contribution.session_id.in_(session_records), ~Contribution.is_deleted))

    # Contributions are added (implictly + explicitly changed)
    changed_event_ids = {ev.id for ev in changed_events}

    condition = Contribution.event_id.in_(changed_event_ids) & ~Contribution.is_deleted
    if contribution_records:
        condition = db.or_(condition, Contribution.id.in_(contribution_records))
    contrib_query = Contribution.find(condition).options(joinedload('subcontributions'))

    for contribution in contrib_query:
        yield contribution
        changed_subcontributions.update(contribution.subcontributions)

    # Same for subcontributions
    if subcontribution_records:
        changed_subcontributions.update(SubContribution.find(SubContribution.id.in_(subcontribution_records)))
    for subcontrib in changed_subcontributions:
        yield subcontrib
開發者ID:indico,項目名稱:indico-plugins,代碼行數:47,代碼來源:simplify.py


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