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


Python EventPrincipal.replace_email_with_user方法代码示例

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


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

示例1: _associate_users_by_email

# 需要导入模块: from indico.modules.events.models.principals import EventPrincipal [as 别名]
# 或者: from indico.modules.events.models.principals.EventPrincipal import replace_email_with_user [as 别名]
    def _associate_users_by_email(self, event):
        # link objects to users by email where possible
        # event principals
        emails = [p.email for p in EventPrincipal.query.with_parent(event).filter_by(type=PrincipalType.email)]
        for user in User.query.filter(~User.is_deleted, User.all_emails.in_(emails)):
            EventPrincipal.replace_email_with_user(user, 'event')

        # session principals
        query = (SessionPrincipal.query
                 .filter(SessionPrincipal.session.has(Session.event == event),
                         SessionPrincipal.type == PrincipalType.email))
        emails = [p.email for p in query]
        for user in User.query.filter(~User.is_deleted, User.all_emails.in_(emails)):
            SessionPrincipal.replace_email_with_user(user, 'session')

        # contribution principals
        query = (ContributionPrincipal.query
                 .filter(ContributionPrincipal.contribution.has(Contribution.event == event),
                         ContributionPrincipal.type == PrincipalType.email))
        emails = [p.email for p in query]
        for user in User.query.filter(~User.is_deleted, User.all_emails.in_(emails)):
            ContributionPrincipal.replace_email_with_user(user, 'contribution')

        # event persons
        query = EventPerson.query.with_parent(event).filter(EventPerson.user_id.is_(None), EventPerson.email != '')
        for person in query:
            person.user = get_user_by_email(person.email)

        # registrations
        for registration in Registration.query.with_parent(event).filter(Registration.user_id.is_(None)):
            registration.user = get_user_by_email(registration.email)
开发者ID:indico,项目名称:indico,代码行数:33,代码来源:export.py

示例2: test_convert_email_principals_merge

# 需要导入模块: from indico.modules.events.models.principals import EventPrincipal [as 别名]
# 或者: from indico.modules.events.models.principals.EventPrincipal import replace_email_with_user [as 别名]
def test_convert_email_principals_merge(db, create_event, create_user):
    event = create_event()
    user = create_user(123, email='[email protected]')
    principal = EmailPrincipal('[email protected]')
    entry1 = event.update_principal(user, full_access=True, roles={'foo', 'foobar'})
    entry2 = event.update_principal(principal, read_access=True, roles={'foo', 'bar'})
    # different emails for now -> nothing updated
    assert not EventPrincipal.replace_email_with_user(user, 'event_new')
    assert set(event.acl_entries) == {entry1, entry2}
    user.secondary_emails.add(principal.email)
    assert EventPrincipal.replace_email_with_user(user, 'event_new') == {event}
    assert len(event.acl_entries) == 1
    entry = list(event.acl_entries)[0]
    assert entry.full_access
    assert entry.read_access
    assert set(entry.roles) == {'foo', 'bar', 'foobar'}
开发者ID:,项目名称:,代码行数:18,代码来源:

示例3: _convert_email_principals

# 需要导入模块: from indico.modules.events.models.principals import EventPrincipal [as 别名]
# 或者: from indico.modules.events.models.principals.EventPrincipal import replace_email_with_user [as 别名]
def _convert_email_principals(user, **kwargs):
    from indico.modules.events.models.principals import EventPrincipal
    events = EventPrincipal.replace_email_with_user(user, 'event')
    if events:
        num = len(events)
        flash(ngettext("You have been granted manager/submission privileges for an event.",
                       "You have been granted manager/submission privileges for {} events.", num).format(num), 'info')
开发者ID:DirkHoffmann,项目名称:indico,代码行数:9,代码来源:__init__.py

示例4: test_convert_email_principals

# 需要导入模块: from indico.modules.events.models.principals import EventPrincipal [as 别名]
# 或者: from indico.modules.events.models.principals.EventPrincipal import replace_email_with_user [as 别名]
def test_convert_email_principals(db, create_event, create_user, dummy_user):
    event = create_event()
    user = create_user(123, email='[email protected]')
    principal = EmailPrincipal('[email protected]')
    other_entry = event.update_principal(dummy_user, full_access=True, roles={'foo', 'foobar'})
    entry = event.update_principal(principal, read_access=True, roles={'foo', 'bar'})
    other_entry_data = other_entry.current_data
    entry_data = entry.current_data
    # different emails for now -> nothing updated
    assert not EventPrincipal.replace_email_with_user(user, 'event_new')
    assert set(event.acl_entries) == {entry, other_entry}
    user.secondary_emails.add(principal.email)
    assert EventPrincipal.replace_email_with_user(user, 'event_new') == {event}
    assert set(event.acl_entries) == {entry, other_entry}
    assert all(x.type == PrincipalType.user for x in event.acl_entries)
    db.session.expire(other_entry)
    db.session.expire(entry)
    assert entry.current_data == entry_data
    assert other_entry.current_data == other_entry_data
开发者ID:,项目名称:,代码行数:21,代码来源:


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