def profile_edit():
""" Edit profile information """
# Set the value of the user id of the user in the session
id = session.get('id')
# Query the database for the user
user_info = User.query.filter_by(id=id).first()
# Get information from the forms
name = request.form.get("profile-name")
email = request.form.get("profile-email")
password = request.form.get("new-password")
# Replace info in the database with new info
if name:
user_info.name = name
db.session.commit()
if password:
user_info.password = password
db.session.commit()
if email:
user_info.email = email
db.session.commit()
name_info = {
'name': name,
'email': email
}
# Return jsonified budget info to submit-new-account-info.js
return jsonify(name_info)
评论列表
文章目录