本文整理汇总了Python中app.users.models.User.make_unique_nickname方法的典型用法代码示例。如果您正苦于以下问题:Python User.make_unique_nickname方法的具体用法?Python User.make_unique_nickname怎么用?Python User.make_unique_nickname使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app.users.models.User
的用法示例。
在下文中一共展示了User.make_unique_nickname方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: after_login
# 需要导入模块: from app.users.models import User [as 别名]
# 或者: from app.users.models.User import make_unique_nickname [as 别名]
def after_login(resp):
if resp.email is None or resp.email == "":
flash(gettext('Invalid login. Please try again.'))
return redirect(url_for('login_view'))
user = User.query.filter_by(email = resp.email).first()
userdetails = UserDetails(user=user)
if user is None:
nickname = resp.nickname
if nickname is None or nickname == "":
nickname = resp.email.split('@')[0]
nickname = User.make_valid_nickname(nickname)
nickname = User.make_unique_nickname(nickname)
user = User(nickname = nickname, email = resp.email, role = ROLE_USER)
db.session.add(user)
db.session.add(userdetails)
db.session.commit()
# make the user follow him/herself
db.session.add(user.follow(user))
db.session.commit()
userdetails = UserDetails.query.filter_by(user=user).first()
if userdetails is None:
userdetails = UserDetails(user=user)
db.session.add(userdetails)
db.session.commit()
remember_me = False
if 'remember_me' in session:
remember_me = session['remember_me']
session.pop('remember_me', None)
login_user(user, remember = True)
return redirect(request.args.get('next') or url_for('main_flow.index'))