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


Python Identity.find方法代码示例

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


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

示例1: create

# 需要导入模块: from indico.modules.auth import Identity [as 别名]
# 或者: from indico.modules.auth.Identity import find [as 别名]
def create(grant_admin):
    """Creates a new user"""
    user_type = 'user' if not grant_admin else 'admin'
    while True:
        email = prompt_email()
        if email is None:
            return
        email = email.lower()
        if not User.query.filter(User.all_emails == email, ~User.is_deleted, ~User.is_pending).has_rows():
            break
        print(cformat('%{red}Email already exists'))
    first_name = click.prompt("First name").strip()
    last_name = click.prompt("Last name").strip()
    affiliation = click.prompt("Affiliation", '').strip()
    print()
    while True:
        username = click.prompt("Enter username").lower().strip()
        if not Identity.find(provider='indico', identifier=username).count():
            break
        print(cformat('%{red}Username already exists'))
    password = prompt_pass()
    if password is None:
        return

    identity = Identity(provider='indico', identifier=username, password=password)
    user = create_user(email, {'first_name': to_unicode(first_name), 'last_name': to_unicode(last_name),
                               'affiliation': to_unicode(affiliation)}, identity)
    user.is_admin = grant_admin
    _print_user_info(user)

    if click.confirm(cformat("%{yellow}Create the new {}?").format(user_type), default=True):
        db.session.add(user)
        db.session.commit()
        print(cformat("%{green}New {} created successfully with ID: %{green!}{}").format(user_type, user.id))
开发者ID:ThiefMaster,项目名称:indico,代码行数:36,代码来源:user.py

示例2: user_create

# 需要导入模块: from indico.modules.auth import Identity [as 别名]
# 或者: from indico.modules.auth.Identity import find [as 别名]
def user_create(grant_admin):
    """Creates new user"""
    update_session_options(db)
    user_type = 'user' if not grant_admin else 'admin'
    while True:
        email = prompt_email()
        if email is None:
            return
        email = email.lower()
        if not User.find(User.all_emails.contains(email), ~User.is_deleted, ~User.is_pending).count():
            break
        error('Email already exists')
    first_name = prompt("First name")
    last_name = prompt("Last name")
    affiliation = prompt("Affiliation", '')
    print()
    while True:
        username = prompt("Enter username").lower()
        if not Identity.find(provider='indico', identifier=username).count():
            break
        error('Username already exists')
    password = prompt_pass()
    if password is None:
        return

    identity = Identity(provider='indico', identifier=username, password=password)
    user = create_user(email, {'first_name': to_unicode(first_name), 'last_name': to_unicode(last_name),
                               'affiliation': to_unicode(affiliation)}, identity)
    user.is_admin = grant_admin
    print_user_info(user)

    if prompt_bool(cformat("%{yellow}Create the new {}?").format(user_type), default=True):
        db.session.add(user)
        db.session.commit()
        success("New {} created successfully with ID: {}".format(user_type, user.id))
开发者ID:OmeGak,项目名称:indico,代码行数:37,代码来源:admin.py

示例3: validate_username

# 需要导入模块: from indico.modules.auth import Identity [as 别名]
# 或者: from indico.modules.auth.Identity import find [as 别名]
 def validate_username(self, field):
     query = Identity.find(
         Identity.provider == "indico",
         Identity.identifier == field.data,
         Identity.identifier != self.identity.identifier,
     )
     if query.count():
         raise ValidationError(_("This username is already in use."))
开发者ID:OmeGak,项目名称:indico,代码行数:10,代码来源:forms.py

示例4: _check_existing_username

# 需要导入模块: from indico.modules.auth import Identity [as 别名]
# 或者: from indico.modules.auth.Identity import find [as 别名]
def _check_existing_username(form, field):
    if Identity.find(provider='indico', identifier=field.data).count():
        raise ValidationError(_('This username is already in use.'))
开发者ID:fph,项目名称:indico,代码行数:5,代码来源:forms.py


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