def users_edit(id_user=None): if not id_user: id_user = request.args.get('id') user = User.get(User.id == id_user) if g.user.status == 4: form = UserEditFormAdmin(obj=user) else: form = UserEditForm(obj=user) if form.validate_on_submit(): status = user.status form.populate_obj(user) # don't allow to change status unless admin. if g.user.status != 4: user.status = status if g.user.status == 4 or g.user.id == user.id: user.save() flash(messages['updated'] + ' (' + str(user) + ')') if g.user.status == 4: return redirect(url_for('admin.users')) else: return redirect(url_for('admin.users_me')) return render_template('admin/users_edit.html', title=gettext('Edit - User'), user=user, form=form)
def users_edit(id_user=None): if not id_user: id_user = request.args.get('id') user = User.get(User.id == id_user) if g.user.status == 4: form = UserEditFormAdmin(obj=user) else: form = UserEditForm(obj=user) if form.validate_on_submit(): status = user.status form.populate_obj(user) # don't allow to change status unless admin. if g.user.status != 4: user.status = status if g.user.status == 4 or g.user.id == user.id: user.save() flash(messages['updated'] + ' (' + str(user) + ')') if g.user.status == 4: return redirect(url_for('admin.users')) else: return redirect(url_for('admin.users_me')) return render_template('admin/users_edit.html', title=gettext('Edit - User'), user=user, form=form)
def render_template(template, **kwargs): g.user = None if session.get('user_id'): g.user = User.get(User.id == session['user_id']) render = flask_render_template(template, **kwargs) if session.get('user_id') and g.user.status >= 4: render = render.replace('</html>', '') render += admin_render_template('admin/bar.html') render += '</html>' return render
def before_request(): g.user = None if 'user_id' in session: g.user = User.get(User.id == session['user_id']) fypress.options = Option.auto_load()
def before_request(): g.user = None if 'user_id' in session: g.user = User.get(User.id == session['user_id']) fypress.options = Option.auto_load()