def profile(): user = User.query.filter_by(name=current_user.name).first_or_404() form = ProfileForm(obj=user, next=request.args.get('next')) if form.validate_on_submit(): form.populate_obj(user) db.session.add(user) db.session.commit() flash(_('Profile updated.'), 'success') return render_template('settings/profile.html', user=user, active="profile", form=form)
def profile(): user = User.query.filter_by(name=current_user.name).first_or_404() form = ProfileForm( name = current_user.name, email = current_user.email, real_name = current_user.user_detail.real_name, role_id = current_user.role_id, age = current_user.user_detail.age, url = current_user.user_detail.url, location = current_user.user_detail.location, bio = current_user.user_detail.bio, next = request.args.get('next'), ) if form.validate_on_submit(): form.populate_obj(user) form.populate_obj(user.user_detail) db.session.add(user) db.session.commit() flash('Profile updated.', 'success') return render_template('settings/profile.html', user=user, active="profile", form=form)