def profile(): u = g.user mc = g.user.mark_count() bc = g.user.bookmark_count() fc = g.user.feed_count() lcm = g.user.mark_last_created() form = UserProfileForm(obj=u) if form.validate_on_submit(): form.populate_obj(u) if form.password.data: pm = bMan() u.password = pm.encode(form.password.data) else: del u.password db.session.add(u) db.session.commit() flash('User %s updated' % (form.username.data), category='info') return redirect(url_for('profile')) return render_template( 'account/profile.html', form=form, title='Profile', mc=mc, bc=bc, fc=fc, lcm=lcm, )
def profile(): u = g.user mc = g.user.mark_count() bc = g.user.bookmark_count() fc = g.user.feed_count() lcm = g.user.mark_last_created() form = UserProfileForm(obj=u) if form.validate_on_submit(): form.populate_obj(u) if form.password.data: pm = bMan() u.password = pm.encode(form.password.data) else: del u.password db.session.add(u) db.session.commit() flash('User %s updated' % (form.username.data), category='info') return redirect(url_for('profile')) return render_template('account/profile.html', form=form, title='Profile', mc=mc, bc=bc, fc=fc, lcm=lcm, )
def profile(): u = g.user bc = g.user.bookmark_count() lc = g.user.bookmark_last_created() form = UserProfileForm(obj=u) if form.validate_on_submit(): form.populate_obj(u) if form.password.data: pm = bMan() u.password = pm.encode(form.password.data) else: del u.password db.session.add(u) db.session.commit() flash("User %s updated" % (form.username.data), category="info") return redirect(url_for("login")) return render_template("profile.html", form=form, title="Profile", bc=bc, lc=lc)
def profile(): """Update profile for current user.""" form = UserProfileForm(obj=g.user) if request.method == 'GET': return render_template('users/edit.html', form=form) else: if form.validate_on_submit(): if User.authenticate(g.user.username, form.password.data): user = User.query.get_or_404(g.user.id) pwd = user.password form.populate_obj(user) user.password = pwd db.session.add(user) db.session.commit() return redirect(url_for('users_show', user_id=user.id)) flash(u'Invalid Password', category='danger') return render_template('users/edit.html', form=form) else: flash(u'Validation Problem', category='danger') return render_template('users/edit.html', form=form)