本文整理汇总了Python中model.User.last_name方法的典型用法代码示例。如果您正苦于以下问题:Python User.last_name方法的具体用法?Python User.last_name怎么用?Python User.last_name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类model.User
的用法示例。
在下文中一共展示了User.last_name方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: register_post
# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import last_name [as 别名]
def register_post():
# Create the user object to store our data
user = User()
user.first_name = request.form.get('first_name')
user.last_name = request.form.get('last_name')
user.email = request.form.get('email')
user.phone = request.form.get('phone')
user.password = request.form.get('password')
user.role = request.form.get('role')
existing = db_session.query(User).filter_by(email=user.email).first()
if existing:
flash("Email already in use", "error")
return redirect(url_for("user_login_get"))
# Add the user object to the database
db_session.add(user)
# Save the user in the database
db_session.commit()
# # Redirect user to landing page
return redirect(url_for("traveler_view_trip"))
示例2: authenticate
# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import last_name [as 别名]
def authenticate():
if request.form['btn'] == "login":
form_login = forms.LoginForm(request.form)
if not form_login.validate():
flash("Incorrect username or password")
return render_template("create_info")
email = form_login.email.data
password = form_login.password.data
user = User.query.filter_by(email=email).first()
if not user or not user.authenticate(password):
flash("Incorrect username or password")
return render_template("login.html")
login_user(user)
session["user_id"] = user.id
return redirect(request.args.get("next", url_for("browse")))
elif request.form['btn'] == "register":
password = request.form.get("password")
email = request.form.get("email")
first_name=request.form.get("first_name")
last_name=request.form.get("last_name")
new_user = User(email=email)
new_user.set_password(password=password)
new_user.first_name=first_name
new_user.last_name=last_name
model.session.add(new_user)
model.session.commit()
return redirect(url_for("create_info"))
elif request.form['btn'] == "fb_login":
fb_name = request.form.get("name")
if current_user.is_anonymous == False:
current_user.fb_id = fb_id
current_user.fb_img_url = "https://graph.facebook.com/%s/picture?type=small" % fb_id
print current_user.fb_img_url
model.session.commit()
model.session.refresh()
return redirect(url_for("browse"))
示例3: register_submit
# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import last_name [as 别名]
def register_submit():
""" Register new user """
firstname = request.form.get('firstname')
lastname = request.form.get('lastname')
email = request.form.get('newemail')
password1 = request.form.get('password1')
if User.query.filter_by(email=email).first():
flash("A user already exists with this email")
return render_template("register.html")
else:
new_user = User(email, password1)
db.session.add(new_user)
new_user.first_name = firstname
new_user.last_name = lastname
db.session.commit()
if not session.get('new_user.user_id'):
session['user_id'] = new_user.user_id
flash("You have been registered successfully.")
return redirect("/dashboard")