本文整理汇总了Python中models.Team.generate_team_id方法的典型用法代码示例。如果您正苦于以下问题:Python Team.generate_team_id方法的具体用法?Python Team.generate_team_id怎么用?Python Team.generate_team_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Team
的用法示例。
在下文中一共展示了Team.generate_team_id方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: register
# 需要导入模块: from models import Team [as 别名]
# 或者: from models.Team import generate_team_id [as 别名]
def register():
"""
Registration form
"""
from lib.forms.registration import RegistrationForm
from lib.database import db_session
form = RegistrationForm(request.form)
if request.method == 'POST' and form.validate():
from models import Team
team = Team(form.team_name.data, form.institution.data,
form.team_members.data, md5(form.password.data).hexdigest())
db_session.add(team)
# trying to add to db
try:
db_session.flush()
except:
form.team_name.errors.append(u'Команда с таким названием уже зарегистрирована.')
else:
# if success, generate TEAM_ID
team.generate_team_id()
db_session.commit()
# store session
session['team_id'] = team.team_id
return render_template('registration_success.html', team_id = team.team_id, active_register = True)
return render_template('registration.html', form = form, active_registration = True)