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


Python User.has_rows方法代码示例

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


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

示例1: _process_POST

# 需要导入模块: from indico.modules.users import User [as 别名]
# 或者: from indico.modules.users.User import has_rows [as 别名]
    def _process_POST(self):
        if User.has_rows():
            return redirect(url_for('misc.index'))
        setup_form = BootstrapForm(request.form)
        if not setup_form.validate():
            flash(_("Some fields are invalid. Please, correct them and submit the form again."), 'error')
            return redirect(url_for('bootstrap.index'))

        # Creating new user
        user = User()
        user.first_name = to_unicode(setup_form.first_name.data)
        user.last_name = to_unicode(setup_form.last_name.data)
        user.affiliation = to_unicode(setup_form.affiliation.data)
        user.email = to_unicode(setup_form.email.data)
        user.is_admin = True

        identity = Identity(provider='indico', identifier=setup_form.username.data, password=setup_form.password.data)
        user.identities.add(identity)

        db.session.add(user)
        db.session.flush()

        user.settings.set('timezone', Config.getInstance().getDefaultTimezone())
        user.settings.set('lang', to_unicode(setup_form.language.data))

        login_user(user, identity)
        full_name = user.full_name  # needed after the session closes

        transaction.commit()

        # Configuring server's settings
        minfo = HelperMaKaCInfo.getMaKaCInfoInstance()
        minfo.setOrganisation(setup_form.affiliation.data)
        minfo.setLang(setup_form.language.data)

        message = get_template_module('bootstrap/flash_messages.html').bootstrap_success(name=full_name)
        flash(Markup(message), 'success')

        # Activate instance tracking
        if setup_form.enable_tracking.data:
            contact_name = setup_form.contact_name.data
            contact_email = setup_form.contact_email.data

            try:
                register_instance(contact_name, contact_email)
            except (HTTPError, ValueError) as err:
                message = get_template_module('bootstrap/flash_messages.html').community_error(err=err)
                category = 'error'
            except Timeout:
                message = get_template_module('bootstrap/flash_messages.html').community_timeout()
                category = 'error'
            except RequestException as exc:
                message = get_template_module('bootstrap/flash_messages.html').community_exception(exc=exc)
                category = 'error'
            else:
                message = get_template_module('bootstrap/flash_messages.html').community_success()
                category = 'success'
            flash(Markup(message), category)

        return redirect(url_for('misc.index'))
开发者ID:MichelCordeiro,项目名称:indico,代码行数:62,代码来源:controllers.py

示例2: _process

# 需要导入模块: from indico.modules.users import User [as 别名]
# 或者: from indico.modules.users.User import has_rows [as 别名]
 def _process(self):
     if not User.has_rows():
         self._redirect(url_for('bootstrap.index'))
     else:
         wfReg = webFactoryRegistry.WebFactoryRegistry()
         p = welcome.WPWelcome(self, self._target, wfReg)
         return p.display()
开发者ID:MichelCordeiro,项目名称:indico,代码行数:9,代码来源:welcome.py

示例3: _process_GET

# 需要导入模块: from indico.modules.users import User [as 别名]
# 或者: from indico.modules.users.User import has_rows [as 别名]
 def _process_GET(self):
     if User.has_rows():
         return redirect(url_for_index())
     return render_template('bootstrap/bootstrap.html',
                            form=BootstrapForm(),
                            timezone=Config.getInstance().getDefaultTimezone(),
                            indico_version=MaKaC.__version__,
                            python_version=python_version())
开发者ID:fph,项目名称:indico,代码行数:10,代码来源:controllers.py

示例4: _process_GET

# 需要导入模块: from indico.modules.users import User [as 别名]
# 或者: from indico.modules.users.User import has_rows [as 别名]
 def _process_GET(self):
     if User.has_rows():
         return redirect(url_for('misc.index'))
     return render_template('bootstrap/bootstrap.html',
                            selected_lang_name=parse_locale(get_current_locale()).language_name,
                            language_options=sorted(get_all_locales().items(), key=itemgetter(1)),
                            form=BootstrapForm(language=session.lang),
                            timezone=Config.getInstance().getDefaultTimezone(),
                            indico_version=MaKaC.__version__,
                            python_version=python_version())
开发者ID:MichelCordeiro,项目名称:indico,代码行数:12,代码来源:controllers.py


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