|
|
@ -37,18 +37,17 @@ def manager_create(domain_name):
|
|
|
|
domain=domain, form=form)
|
|
|
|
domain=domain, form=form)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# TODO For now the deletion behaviour is broken and reserved to
|
|
|
|
@app.route('/manager/delete/<domain_name>/<user_email>', methods=['GET', 'POST'])
|
|
|
|
# global admins.
|
|
|
|
@access.confirmation_required("remove manager {user_email}")
|
|
|
|
@app.route('/manager/delete/<manager>', methods=['GET', 'POST'])
|
|
|
|
@access.domain_admin(models.Domain, 'domain_name')
|
|
|
|
@access.confirmation_required("remove manager {manager}")
|
|
|
|
def manager_delete(domain_name, user_email):
|
|
|
|
@access.global_admin
|
|
|
|
domain = models.Domain.query.get(domain_name) or flask.abort(404)
|
|
|
|
def manager_delete(manager):
|
|
|
|
user = models.User.query.get(user_email) or flask.abort(404)
|
|
|
|
user = models.User.query.get(manager)
|
|
|
|
if user in domain.managers:
|
|
|
|
if user in user.domain.managers:
|
|
|
|
domain.managers.remove(user)
|
|
|
|
user.domain.managers.remove(user)
|
|
|
|
|
|
|
|
db.session.commit()
|
|
|
|
db.session.commit()
|
|
|
|
flask.flash('User %s can no longer manager %s' % (user, user.domain))
|
|
|
|
flask.flash('User %s can no longer manager %s' % (user, domain))
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
flask.flash('User %s is not manager' % user, 'error')
|
|
|
|
flask.flash('User %s is not manager' % user, 'error')
|
|
|
|
return flask.redirect(
|
|
|
|
return flask.redirect(
|
|
|
|
flask.url_for('.manager_list', domain_name=user.domain.name))
|
|
|
|
flask.url_for('.manager_list', domain_name=domain_name))
|
|
|
|