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


Python User.verified方法代码示例

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


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

示例1: assembl_register_user

# 需要导入模块: from assembl.models import User [as 别名]
# 或者: from assembl.models.User import verified [as 别名]

#.........这里部分代码省略.........
            else:
                errors.add_error(localizer.translate(
                    generic_error_message),
                    ErrorTypes.GENERIC,
                    HTTPConflict.code)
                logger.error("We already have a user with username %s" % username)
        if len(username) > 20:
            errors.add_error(localizer.translate(_(
                "The username must be less than 20 characters.")),
                ErrorTypes.USERNAME_TOO_LONG,
                HTTPBadRequest.code)
    if discussion:
        check_subscription = discussion.preferences['whitelist_on_register']
        whitelist = discussion.preferences['require_email_domain']
        if check_subscription and whitelist:
            status = discussion.check_email(email)
            if not status:
                admin_emails = discussion.get_admin_emails()
                num = len(admin_emails)
                errors.add_error(
                    localizer.pluralize(
                        _("Your email domain has not been approved for registration. Please contact ${emails} for support."),
                        _("Your email domain has not been approved for registration. Please contact one of ${emails} for support."),
                        num,
                        mapping={'emails': ", ".join(admin_emails)}
                    )
                )
    if errors:
        raise errors

    # This logic needs to be above the JSONError checks to ensure that whitelisting is applied
    # even if the discussion does not have a P_SELF_REGISTER on system.Everyone
    if discussion and not (
            P_SELF_REGISTER in permissions or
            P_SELF_REGISTER_REQUEST in permissions):
        # Consider it without context
        discussion = None

    validate_registration = asbool(config.get(
        'assembl.validate_registration_emails'))

    old_autoflush = session.autoflush
    session.autoflush = False
    try:
        now = datetime.utcnow()
        user = User(
            name=name,
            password=password,
            verified=not validate_registration,
            creation_date=now
        )

        session.add(user)
        session.flush()

        user.update_from_json(json, user_id=user.id)
        account = user.accounts[0]
        email = account.email
        account.verified = not validate_registration
        if discussion:
            agent_status = AgentStatusInDiscussion(
                agent_profile=user, discussion=discussion,
                first_visit=now, last_visit=now,
                user_created_on_this_discussion=True)
            session.add(agent_status)
        session.flush()

        # create the profile fields for custom fields
        for global_id, value in json.get('profileFields', {}).iteritems():
            configurable_field_id = from_global_id(global_id)[1]
            configurable_field = AbstractConfigurableField.get(configurable_field_id)
            profile_field = ProfileField(
                agent_profile=user,
                configurable_field=configurable_field,
                discussion=configurable_field.discussion,
                value_data={ u'value': value }
            )
            session.add(profile_field)

        session.flush()

        if validate_registration:
            send_confirmation_email(request, account)
        else:
            user.verified = True
            for account in user.accounts:
                account.verified = True
            user.successful_login()
            if asbool(config.get('pyramid.debug_authorization')):
                # for debugging purposes
                from assembl.auth.password import email_token
                print "email token:", request.route_url(
                    'user_confirm_email', token=email_token(account))
            if discussion:
                check_subscription = discussion.preferences['whitelist_on_register']
                maybe_auto_subscribe(user, discussion, check_authorization=check_subscription)
        session.flush()
        return CreationResponse(user, Everyone, permissions)
    finally:
        session.autoflush = old_autoflush
开发者ID:assembl,项目名称:assembl,代码行数:104,代码来源:auth.py


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