当前位置: 首页>>代码示例>>Python>>正文


Python Event.get方法代码示例

本文整理汇总了Python中indico.modules.events.Event.get方法的典型用法代码示例。如果您正苦于以下问题:Python Event.get方法的具体用法?Python Event.get怎么用?Python Event.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在indico.modules.events.Event的用法示例。


在下文中一共展示了Event.get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_deleted_relationships

# 需要导入模块: from indico.modules.events import Event [as 别名]
# 或者: from indico.modules.events.Event import get [as 别名]
def test_deleted_relationships(db, dummy_event_new):
    event = dummy_event_new
    assert not event.contributions
    assert not event.sessions
    s = Session(event_new=event, title='s')
    sd = Session(event_new=event, title='sd', is_deleted=True)
    c = Contribution(event_new=event, title='c', session=sd, duration=timedelta(minutes=30))
    cd = Contribution(event_new=event, title='cd', session=sd, duration=timedelta(minutes=30), is_deleted=True)
    sc = SubContribution(contribution=c, title='sc', duration=timedelta(minutes=10))
    scd = SubContribution(contribution=c, title='scd', duration=timedelta(minutes=10), is_deleted=True)
    db.session.flush()
    db.session.expire_all()
    # reload all the objects from the db
    event = Event.get(event.id)
    s = Session.get(s.id)
    sd = Session.get(sd.id)
    c = Contribution.get(c.id)
    cd = Contribution.get(cd.id)
    sc = SubContribution.get(sc.id)
    scd = SubContribution.get(scd.id)
    # deleted items should not be in the lists
    assert event.sessions == [s]
    assert event.contributions == [c]
    assert sd.contributions == [c]
    assert c.subcontributions == [sc]
    # the other direction should work fine even in case of deletion
    assert s.event_new == event
    assert sd.event_new == event
    assert c.event_new == event
    assert cd.event_new == event
    assert sc.contribution == c
    assert scd.contribution == c
开发者ID:belokop,项目名称:indico_bare,代码行数:34,代码来源:events_test.py

示例2: event_or_shorturl

# 需要导入模块: from indico.modules.events import Event [as 别名]
# 或者: from indico.modules.events.Event import get [as 别名]
def event_or_shorturl(confId, shorturl_namespace=False, force_overview=False):
    func = None
    event_ = Event.get(int(confId)) if confId.isdigit() else None
    if event_ and event_.is_deleted:
        raise NotFound(_('This event has been deleted.'))
    elif event_:
        # For obvious reasons an event id always comes first.
        # If it's used within the short url namespace we redirect to the event namespace, otherwise
        # we call the RH to display the event
        if shorturl_namespace:
            func = lambda: redirect(event_.url)
        else:
            request.view_args['confId'] = int(request.view_args['confId'])
            func = lambda: RHDisplayEvent().process()
    else:
        shorturl_event = (Event.query
                          .filter(db.func.lower(Event.url_shortcut) == confId.lower(),
                                  ~Event.is_deleted)
                          .one_or_none())
        if (shorturl_namespace or config.ROUTE_OLD_URLS) and shorturl_event:
            if shorturl_namespace:
                # Correct namespace => redirect to the event
                func = lambda: redirect(shorturl_event.url)
            else:
                # Old event namespace => 301-redirect to the new shorturl first to get Google etc. to update it
                func = lambda: redirect(shorturl_event.short_url, 301)
        elif is_legacy_id(confId):
            mapping = LegacyEventMapping.find_first(legacy_event_id=confId)
            if mapping is not None:
                url = url_for('events.display', confId=mapping.event_id)
                func = lambda: redirect(url, 301)

    if func is None:
        raise NotFound(_('An event with this ID/shortcut does not exist.'))
    return func()
开发者ID:bkolobara,项目名称:indico,代码行数:37,代码来源:entry.py

示例3: _getParams

# 需要导入模块: from indico.modules.events import Event [as 别名]
# 或者: from indico.modules.events.Event import get [as 别名]
 def _getParams(self):
     super(NoteExportHook, self)._getParams()
     event = self._obj = Event.get(self._pathParams['event_id'], is_deleted=False)
     if event is None:
         raise HTTPAPIError('No such event', 404)
     session_id = self._pathParams.get('session_id')
     if session_id:
         self._obj = Session.query.with_parent(event).filter_by(id=session_id).first()
         if self._obj is None:
             raise HTTPAPIError("No such session", 404)
     contribution_id = self._pathParams.get('contribution_id')
     if contribution_id:
         contribution = self._obj = (Contribution.query.with_parent(event)
                                     .filter_by(id=contribution_id, is_deleted=False)
                                     .first())
         if contribution is None:
             raise HTTPAPIError("No such contribution", 404)
         subcontribution_id = self._pathParams.get('subcontribution_id')
         if subcontribution_id:
             self._obj = SubContribution.query.with_parent(contribution).filter_by(id=subcontribution_id,
                                                                                   is_deleted=False).first()
             if self._obj is None:
                 raise HTTPAPIError("No such subcontribution", 404)
     self._note = EventNote.get_for_linked_object(self._obj, preload_event=False)
     if self._note is None or self._note.is_deleted:
         raise HTTPAPIError("No such note", 404)
开发者ID:DirkHoffmann,项目名称:indico,代码行数:28,代码来源:api.py

示例4: deserialize

# 需要导入模块: from indico.modules.events import Event [as 别名]
# 或者: from indico.modules.events.Event import get [as 别名]
 def deserialize(self):
     if not self.force and self.data['indico_version'] != indico.__version__:
         click.secho('Version mismatch: trying to import event exported with {} to version {}'
                     .format(self.data['indico_version'], indico.__version__), fg='red')
         return None
     self._load_users(self.data)
     for tablename, tabledata in self.data['objects']:
         self._deserialize_object(db.metadata.tables[tablename], tabledata)
     if self.deferred_idrefs:
         # Any reference to an ID that was exported need to be replaced
         # with an actual ID at some point - either immediately (if the
         # referenced row was already imported) or later (usually in case
         # of circular dependencies where one of the IDs is not available
         # when the row is inserted).
         click.secho('BUG: Not all deferred idrefs have been consumed', fg='red')
         for uuid, values in self.deferred_idrefs.iteritems():
             click.secho('{}:'.format(uuid), fg='yellow', bold=True)
             for table, col, pk_value in values:
                 click.secho('  - {}.{} ({})'.format(table.fullname, col, pk_value), fg='yellow')
         raise Exception('Not all deferred idrefs have been consumed')
     event = Event.get(self.event_id)
     event.log(EventLogRealm.event, EventLogKind.other, 'Event', 'Event imported from another Indico instance')
     self._associate_users_by_email(event)
     db.session.flush()
     return event
开发者ID:indico,项目名称:indico,代码行数:27,代码来源:export.py

示例5: _getParams

# 需要导入模块: from indico.modules.events import Event [as 别名]
# 或者: from indico.modules.events.Event import get [as 别名]
 def _getParams(self):
     super(AgreementExportHook, self)._getParams()
     type_ = self._pathParams['agreement_type']
     try:
         self._definition = get_agreement_definitions()[type_]
     except KeyError:
         raise HTTPAPIError('No such agreement type', 404)
     self.event = Event.get(self._pathParams['event_id'], is_deleted=False)
     if self.event is None:
         raise HTTPAPIError('No such event', 404)
开发者ID:OmeGak,项目名称:indico,代码行数:12,代码来源:api.py

示例6: restore

# 需要导入模块: from indico.modules.events import Event [as 别名]
# 或者: from indico.modules.events.Event import get [as 别名]
def restore(event_id):
    """Restores a deleted event."""
    event = Event.get(event_id)
    if event is None:
        click.secho('This event does not exist', fg='red')
        sys.exit(1)
    elif not event.is_deleted:
        click.secho('This event is not deleted', fg='yellow')
        sys.exit(1)
    event.is_deleted = False
    db.session.commit()
    click.secho('Event undeleted: "{}"'.format(event.title), fg='green')
开发者ID:bkolobara,项目名称:indico,代码行数:14,代码来源:event.py

示例7: validate_entries

# 需要导入模块: from indico.modules.events import Event [as 别名]
# 或者: from indico.modules.events.Event import get [as 别名]
 def validate_entries(self, field):
     if field.errors:
         return
     for entry in field.data:
         if entry['days'] < 0:
             raise ValidationError(_("'Days' must be a positive integer"))
         if entry['type'] not in {'category', 'event'}:
             raise ValidationError(_('Invalid type'))
         if entry['type'] == 'category' and not Category.get(entry['id'], is_deleted=False):
             raise ValidationError(_('Invalid category: {}').format(entry['id']))
         if entry['type'] == 'event' and not Event.get(entry['id'], is_deleted=False):
             raise ValidationError(_('Invalid event: {}').format(entry['id']))
开发者ID:fph,项目名称:indico,代码行数:14,代码来源:forms.py

示例8: obj_deref

# 需要导入模块: from indico.modules.events import Event [as 别名]
# 或者: from indico.modules.events.Event import get [as 别名]
def obj_deref(ref):
    """Returns the object identified by `ref`"""
    from indico_livesync.models.queue import EntryType
    if ref['type'] == EntryType.category:
        return CategoryManager().getById(ref['category_id'], True)
    elif ref['type'] == EntryType.event:
        return Event.get(ref['event_id'])
    elif ref['type'] == EntryType.contribution:
        return Contribution.get(ref['contrib_id'])
    elif ref['type'] == EntryType.subcontribution:
        return SubContribution.get(ref['subcontrib_id'])
    else:
        raise ValueError('Unexpected object type: {}'.format(ref['type']))
开发者ID:florv,项目名称:indico-plugins,代码行数:15,代码来源:util.py

示例9: is_feature_enabled

# 需要导入模块: from indico.modules.events import Event [as 别名]
# 或者: from indico.modules.events.Event import get [as 别名]
def is_feature_enabled(event, name):
    """Checks if a feature is enabled for an event.

    :param event: The event (or event ID) to check.
    :param name: The name of the feature.
    """
    feature = get_feature_definition(name)
    enabled_features = features_event_settings.get(event, 'enabled')
    if enabled_features is not None:
        return feature.name in enabled_features
    else:
        if isinstance(event, (basestring, int, long)):
            event = Event.get(event)
        return event and feature.is_default_for_event(event)
开发者ID:DirkHoffmann,项目名称:indico,代码行数:16,代码来源:util.py

示例10: session

# 需要导入模块: from indico.modules.events import Event [as 别名]
# 或者: from indico.modules.events.Event import get [as 别名]
 def session(self, idlist):
     event = Event.get(self._eventId, is_deleted=False)
     if not event:
         return []
     idlist = set(map(int, idlist))
     sessions = Session.query.with_parent(event).filter(Session.id.in_(idlist), ~Session.is_deleted).all()
     # Fallback for friendly_id
     sessions += (
         Session.query.with_parent(event)
         .filter(Session.friendly_id.in_(idlist - {s.id for s in sessions}), ~Session.is_deleted)
         .all()
     )
     self._detail_level = "contributions"
     return self._build_sessions_api_data(sessions)
开发者ID:OmeGak,项目名称:indico,代码行数:16,代码来源:api.py

示例11: export

# 需要导入模块: from indico.modules.events import Event [as 别名]
# 或者: from indico.modules.events.Event import get [as 别名]
def export(event_id, target_file):
    """Exports all data associated with an event.

    This exports the whole event as an archive which can be imported
    on another other Indico instance.  Importing an event is only
    guaranteed to work if it was exported on the same Indico version.
    """
    event = Event.get(event_id)
    if event is None:
        click.secho('This event does not exist', fg='red')
        sys.exit(1)
    elif event.is_deleted:
        click.secho('This event has been deleted', fg='yellow')
        click.confirm('Export it anyway?', abort=True)
    export_event(event, target_file)
开发者ID:bkolobara,项目名称:indico,代码行数:17,代码来源:event.py

示例12: get_linked_object

# 需要导入模块: from indico.modules.events import Event [as 别名]
# 或者: from indico.modules.events.Event import get [as 别名]
def get_linked_object(type_, id_):
    if type_ == LinkType.event:
        return Event.get(id_, is_deleted=False)
    elif type_ == LinkType.contribution:
        return (Contribution.query
                .filter(Contribution.id == id_,
                        ~Contribution.is_deleted,
                        Contribution.event.has(is_deleted=False))
                .first())
    elif type_ == LinkType.session_block:
        return (SessionBlock.query
                .filter(SessionBlock.id == id_,
                        SessionBlock.session.has(db.and_(~Session.is_deleted,
                                                         Session.event.has(is_deleted=False))))
                .first())
开发者ID:indico,项目名称:indico,代码行数:17,代码来源:util.py

示例13: _getParams

# 需要导入模块: from indico.modules.events import Event [as 别名]
# 或者: from indico.modules.events.Event import get [as 别名]
 def _getParams(self):
     super(AttachmentsExportHook, self)._getParams()
     event = self._obj = Event.get(self._pathParams['event_id'], is_deleted=False)
     if event is None:
         raise HTTPAPIError('No such event', 404)
     session_id = self._pathParams.get('session_id')
     if session_id:
         self._obj = Session.query.with_parent(event).filter_by(id=session_id).first()
         if self._obj is None:
             raise HTTPAPIError("No such session", 404)
     contribution_id = self._pathParams.get('contribution_id')
     if contribution_id:
         contribution = self._obj = Contribution.query.with_parent(event).filter_by(id=contribution_id).first()
         if contribution is None:
             raise HTTPAPIError("No such contribution", 404)
         subcontribution_id = self._pathParams.get('subcontribution_id')
         if subcontribution_id:
             self._obj = SubContribution.query.with_parent(contribution).filter_by(id=subcontribution_id).first()
             if self._obj is None:
                 raise HTTPAPIError("No such subcontribution", 404)
开发者ID:bkolobara,项目名称:indico,代码行数:22,代码来源:hooks.py

示例14: _migrate_menu

# 需要导入模块: from indico.modules.events import Event [as 别名]
# 或者: from indico.modules.events.Event import get [as 别名]
 def _migrate_menu(self, event, container, parent=None, used=None):
     if used is None:
         used = set()
     for pos, item in enumerate(container._listLink, 1):
         data = {"parent": parent, "event_id": int(event.id), "is_enabled": item._active, "position": pos}
         item_type = item.__class__.__name__
         if item_type == "SystemLink":
             if item._name in REMOVED_MENU_NAMES:
                 continue
             data["name"] = MENU_ENTRY_NAME_MAP[item._name]
             if not parent and data["name"] in NOT_TOP_LEVEL_NAMES:
                 self.print_warning(
                     cformat("%{yellow}Skipping top-level menu entry {}").format(data["name"]), event_id=event.id
                 )
                 continue
             elif data["name"] in used:
                 self.print_error(
                     cformat("%{red!}duplicate menu entry name {}; skipping").format(data["name"]), event_id=event.id
                 )
                 continue
             used.add(data["name"])
             data["title"] = _sanitize_title(item._caption)
             if not data["title"]:
                 data["title"] = None
                 self.print_warning(
                     cformat("%{yellow!}Menu entry {} has no title; using default").format(data["name"]),
                     event_id=event.id,
                 )
             elif data["title"].lower() in DEFAULT_MENU_TITLES[data["name"]]:
                 data["title"] = None
             if item._name == "chatrooms":
                 data["plugin"] = "chat"
                 data["type"] = MenuEntryType.plugin_link
             else:
                 data["type"] = MenuEntryType.internal_link
         elif item_type == "Spacer":
             data["type"] = MenuEntryType.separator
         elif item_type == "ExternLink":
             data["type"] = MenuEntryType.user_link
             data["title"] = _sanitize_title(item._caption)
             data["link_url"] = item._URL.strip()
             if not data["link_url"]:
                 if getattr(item, "_listLink", None):
                     self.print_warning(
                         cformat('%{yellow!}Link "{}" has no URL but children').format(data["title"]),
                         event_id=event.id,
                     )
                 else:
                     self.print_warning(
                         cformat('%{yellow}Skipping link "{}" with no URL').format(data["title"]), event_id=event.id
                     )
                     continue
             if not data["title"]:
                 if getattr(item, "_listLink", None):
                     self.print_warning(cformat("%{yellow!}Link has no title but children"), event_id=event.id)
                 else:
                     self.print_warning(cformat("%{yellow}Skipping link with no title"), event_id=event.id)
                     continue
         elif item_type == "PageLink":
             data["type"] = MenuEntryType.page
             data["title"] = _sanitize_title(item._caption)
             data["page"] = EventPage(event_id=event.id, html=item._page._content)
             data["page"].legacy_mapping = LegacyPageMapping(event_id=event.id, legacy_page_id=item._page._id)
             if item._page._isHome:
                 Event.get(event.id).default_page = data["page"]
         else:
             self.print_error("Unexpected menu item type: {}".format(item_type), event_id=event.id)
             continue
         entry = MenuEntry(**data)
         yield entry
         if getattr(item, "_listLink", None):
             # child entries
             if not parent:
                 for sub_entry in self._migrate_menu(event, item, entry, used):
                     yield sub_entry
             else:
                 self.print_warning("Skipping children inside nested entry", event_id=event.id)
开发者ID:MichelCordeiro,项目名称:indico,代码行数:79,代码来源:event_menus.py

示例15: _migrate_menu

# 需要导入模块: from indico.modules.events import Event [as 别名]
# 或者: from indico.modules.events.Event import get [as 别名]
 def _migrate_menu(self, event, container, parent=None, used=None):
     if used is None:
         used = set()
     for pos, item in enumerate(container._listLink, 1):
         data = {'parent': parent, 'event_id': int(event.id), 'is_enabled': item._active, 'position': pos}
         item_type = item.__class__.__name__
         if item_type == 'SystemLink':
             if item._name in REMOVED_MENU_NAMES:
                 continue
             data['name'] = MENU_ENTRY_NAME_MAP[item._name]
             if not parent and data['name'] in NOT_TOP_LEVEL_NAMES:
                 self.print_warning(cformat('%{yellow}Skipping top-level menu entry {}').format(data['name']),
                                    event_id=event.id)
                 continue
             elif data['name'] in used:
                 self.print_error(cformat('%{red!}duplicate menu entry name {}; skipping').format(data['name']),
                                  event_id=event.id)
                 continue
             used.add(data['name'])
             data['title'] = _sanitize_title(item._caption)
             if not data['title']:
                 data['title'] = None
                 self.print_warning(cformat('%{yellow!}Menu entry {} has no title; using default').format(
                     data['name']), event_id=event.id)
             elif data['title'].lower() in DEFAULT_MENU_TITLES[data['name']]:
                 data['title'] = None
             if item._name == 'chatrooms':
                 data['plugin'] = 'chat'
                 data['type'] = MenuEntryType.plugin_link
             else:
                 data['type'] = MenuEntryType.internal_link
         elif item_type == 'Spacer':
             data['type'] = MenuEntryType.separator
         elif item_type == 'ExternLink':
             data['type'] = MenuEntryType.user_link
             data['title'] = _sanitize_title(item._caption)
             data['link_url'] = item._URL.strip()
             if not data['link_url']:
                 if getattr(item, '_listLink', None):
                     self.print_warning(cformat('%{yellow!}Link "{}" has no URL but children').format(
                         data['title']), event_id=event.id)
                 else:
                     self.print_warning(cformat('%{yellow}Skipping link "{}" with no URL').format(
                         data['title']), event_id=event.id)
                     continue
             if not data['title']:
                 if getattr(item, '_listLink', None):
                     self.print_warning(cformat('%{yellow!}Link has no title but children'), event_id=event.id)
                 else:
                     self.print_warning(cformat('%{yellow}Skipping link with no title'), event_id=event.id)
                     continue
         elif item_type == 'PageLink':
             data['type'] = MenuEntryType.page
             data['title'] = _sanitize_title(item._caption)
             data['page'] = EventPage(event_id=event.id, html=item._page._content)
             data['page'].legacy_mapping = LegacyPageMapping(event_id=event.id, legacy_page_id=item._page._id)
             if item._page._isHome:
                 Event.get(event.id).default_page = data['page']
         else:
             self.print_error('Unexpected menu item type: {}'.format(item_type), event_id=event.id)
             continue
         entry = MenuEntry(**data)
         yield entry
         if getattr(item, '_listLink', None):
             # child entries
             if not parent:
                 for sub_entry in self._migrate_menu(event, item, entry, used):
                     yield sub_entry
             else:
                 self.print_warning('Skipping children inside nested entry', event_id=event.id)
开发者ID:OmeGak,项目名称:indico,代码行数:72,代码来源:event_menus.py


注:本文中的indico.modules.events.Event.get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。