def user_settings(user_email): user_email_or_current = user_email or flask_login.current_user.email user = models.User.query.get(user_email_or_current) or flask.abort(404) form = forms.UserSettingsForm(obj=user) if form.validate_on_submit(): form.populate_obj(user) db.session.commit() flask.flash('Settings updated for %s' % user) if user_email: return flask.redirect( flask.url_for('.user_list', domain_name=user.domain.name)) return flask.render_template('user/settings.html', form=form, user=user)
def user_settings(user_email): user_email_or_current = user_email or flask_login.current_user.email user = models.User.query.get(user_email_or_current) or flask.abort(404) form = forms.UserSettingsForm(obj=user) if isinstance(form.forward_destination.data, str): data = form.forward_destination.data.replace(" ", "").split(",") else: data = form.forward_destination.data form.forward_destination.data = ", ".join(data) if form.validate_on_submit(): form.forward_destination.data = form.forward_destination.data.replace( " ", "").split(",") form.populate_obj(user) models.db.session.commit() form.forward_destination.data = ", ".join( form.forward_destination.data) flask.flash('Settings updated for %s' % user) if user_email: return flask.redirect( flask.url_for('.user_list', domain_name=user.domain.name)) return flask.render_template('user/settings.html', form=form, user=user)