def user_delete(user_email): user = utils.get_user(user_email, True) db.session.delete(user) db.session.commit() flask.flash('User %s deleted' % user) return flask.redirect( flask.url_for('.user_list', domain_name=user.domain.name))
def user_reply(user_email): user = utils.get_user(user_email) form = forms.UserReplyForm(obj=user) if form.validate_on_submit(): form.populate_obj(user) db.session.commit() flask.flash('Auto-reply message 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/reply.html', form=form, user=user)
def manager_delete(manager): user = utils.get_user(manager, admin=True) domain = utils.get_domain_admin(user.domain_name) if user in domain.managers: domain.managers.remove(user) db.session.commit() flask.flash('User %s can no longer manager %s' % (user, domain)) else: flask.flash('User %s is not manager' % user, 'error') return flask.redirect( flask.url_for('.manager_list', domain_name=domain.name))
def user_settings(user_email): user = utils.get_user(user_email) 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 fetch_create(user_email): user = utils.get_user(user_email) form = forms.FetchForm() if form.validate_on_submit(): fetch = models.Fetch(user=user) form.populate_obj(fetch) db.session.add(fetch) db.session.commit() flask.flash('Fetch configuration created') return flask.redirect( flask.url_for('.fetch_list', user_email=user.email)) return flask.render_template('fetch/create.html', form=form)
def user_password(user_email): user = utils.get_user(user_email) form = forms.UserPasswordForm() if form.validate_on_submit(): if form.pw.data != form.pw2.data: flask.flash('Passwords do not match', 'error') else: user.set_password(form.pw.data) db.session.commit() flask.flash('Password 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/password.html', form=form, user=user)
def user_edit(user_email): user = utils.get_user(user_email, True) form = forms.UserForm(obj=user) wtforms_components.read_only(form.localpart) form.pw.validators = [] if form.validate_on_submit(): form.populate_obj(user) if form.pw.data: user.set_password(form.pw.data) db.session.commit() flask.flash('User %s updated' % user) return flask.redirect( flask.url_for('.user_list', domain_name=user.domain.name)) return flask.render_template('user/edit.html', form=form, user=user, domain=user.domain)
def user_password(user_email): user = utils.get_user(user_email) form = forms.UserPasswordForm() if form.validate_on_submit(): if form.pw.data != form.pw2.data: flask.flash('Passwords do not match', 'error') else: user.set_password(form.pw.data) db.session.commit() flask.flash('Password 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/password.html', form=form, user=user)
def user_settings(user_email): user = utils.get_user(user_email) form = forms.UserSettingsForm(obj=user) if form.validate_on_submit(): user.displayed_name = form.displayed_name.data user.spam_enabled = form.spam_enabled.data user.spam_threshold = form.spam_threshold.data db.session.add(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_forward(user_email): user = utils.get_user(user_email) form = forms.UserForwardForm(obj=user) if form.validate_on_submit(): if form.forward_enabled: user.forward = form.forward.data else: user.forward = None db.session.add(user) db.session.commit() flask.flash('Forward destination 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/forward.html', form=form, user=user)
def manager_create(domain_name): domain = utils.get_domain_admin(domain_name) form = forms.ManagerForm() if form.validate_on_submit(): user = utils.get_user(form.manager.data, admin=True) if user in domain.managers: flask.flash('User %s is already manager' % user, 'error') else: domain.managers.append(user) db.session.add(domain) db.session.commit() flask.flash('User %s can now manage %s' % (user, domain.name)) return flask.redirect( flask.url_for('.manager_list', domain_name=domain.name)) return flask.render_template('manager/create.html', domain=domain, form=form)
def fetch_create(user_address): user = utils.get_user(user_address) form = forms.FetchForm() if form.validate_on_submit(): fetch = models.Fetch(user=user) fetch.protocol = form.protocol.data fetch.host = form.host.data fetch.port = form.port.data fetch.tls = form.tls.data fetch.username = form.username.data fetch.password = form.password.data db.session.add(fetch) db.session.commit() flask.flash('Fetch configuration created') return flask.redirect( flask.url_for('.fetch_list', user_address=user.address)) return flask.render_template('fetch/create.html', form=form)
def manager_create(domain_name): domain = utils.get_domain_admin(domain_name) form = forms.ManagerForm() form.manager.choices = [ (user.email, user.email) for user in flask_login.current_user.get_managed_emails( include_aliases=False) ] if form.validate_on_submit(): user = utils.get_user(form.manager.data, admin=True) if user in domain.managers: flask.flash('User %s is already manager' % user, 'error') else: domain.managers.append(user) db.session.commit() flask.flash('User %s can now manage %s' % (user, domain.name)) return flask.redirect( flask.url_for('.manager_list', domain_name=domain.name)) return flask.render_template('manager/create.html', domain=domain, form=form)
def fetch_list(user_email): user = utils.get_user(user_email) return flask.render_template('fetch/list.html', user=user)
def fetch_list(user_address): user = utils.get_user(user_address, True) return flask.render_template('fetch/list.html', user=user)