Commit fa5ff74d authored by Olga Brani's avatar Olga Brani Committed by Giorgos Korfiatis

admin: Add modify_email to user available actions

parent 78a3efde
# Copyright (C) 2010-2014 GRNET S.A.
# Copyright (C) 2010-2016 GRNET S.A.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
......@@ -54,7 +54,7 @@ class GroupJSONView(AdminJSONView):
JSON_CLASS = GroupJSONView
def do_action(request, op, id):
def do_action(request, op, id, data):
raise AdminHttp404("There are no actions for Groups")
......
# Copyright (C) 2010-2014 GRNET S.A.
# Copyright (C) 2010-2016 GRNET S.A.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
......@@ -155,7 +155,7 @@ JSON_CLASS = IPJSONView
@transaction.commit_on_success
@has_permission_or_403(cached_actions)
def do_action(request, op, id):
def do_action(request, op, id, data):
"""Apply the requested action on the specified ip."""
if op == "contact":
user = get_user_or_404(id)
......
......@@ -146,7 +146,7 @@ JSON_CLASS = NetworkJSONView
@transaction.commit_on_success
@has_permission_or_403(cached_actions)
def do_action(request, op, id):
def do_action(request, op, id, data):
"""Apply the requested action on the specified network."""
if op == "contact":
user = get_user_or_404(id)
......
......@@ -199,7 +199,7 @@ JSON_CLASS = ProjectJSONView
@has_permission_or_403(cached_actions)
@transaction.commit_on_success
def do_action(request, op, id):
def do_action(request, op, id, data):
"""Apply the requested action on the specified user."""
if op == "contact":
user = get_user_or_404(id)
......
# Copyright (C) 2010-2014 GRNET S.A.
# Copyright (C) 2010-2016 GRNET S.A.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
......@@ -21,6 +21,7 @@ from astakos.im import user_logic as users
from synnefo_admin.admin.actions import AdminAction
from synnefo_admin.admin.utils import update_actions_rbac, send_admin_email
from astakos.im.user_utils import change_user_email
class UserAction(AdminAction):
......@@ -82,6 +83,10 @@ def generate_actions():
actions['contact'] = UserAction(name='Send e-mail', f=send_admin_email,)
actions['modify_email'] = UserAction(name='Change e-mail',
f=change_user_email,karma='bad',
caution_level='dangerous',)
update_actions_rbac(actions)
return actions
......
......@@ -171,7 +171,7 @@ JSON_CLASS = UserJSONView
@has_permission_or_403(cached_actions)
@transaction.commit_on_success
def do_action(request, op, id):
def do_action(request, op, id, data):
"""Apply the requested action on the specified user."""
user = get_user_or_404(id, for_update=True)
actions = get_permitted_actions(cached_actions, request.user)
......@@ -180,6 +180,9 @@ def do_action(request, op, id):
actions[op].apply(user, 'Rejected by the admin')
elif op == 'contact':
actions[op].apply(user, request)
elif op == 'modify_email':
if isinstance(data, dict):
actions[op].apply(user, data.get('new_email'))
else:
actions[op].apply(user)
......
......@@ -147,7 +147,7 @@ JSON_CLASS = VMJSONView
@transaction.commit_on_success
@has_permission_or_403(cached_actions)
def do_action(request, op, id):
def do_action(request, op, id, data):
"""Apply the requested action on the specified user."""
if op == "contact":
user = get_user_or_404(id)
......
......@@ -169,7 +169,7 @@ JSON_CLASS = VolumeJSONView
@transaction.commit_on_success
@has_permission_or_403(cached_actions)
def do_action(request, op, id):
def do_action(request, op, id, data):
"""Apply the requested action on the specified volume."""
if op == "contact":
user = get_user_or_404(id)
......
# Copyright (C) 2010-2014 GRNET S.A.
# Copyright (C) 2010-2016 GRNET S.A.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
......@@ -320,8 +320,10 @@ def admin_actions(request):
for item in items:
id = item['id']
data = item.get('data')
try:
mod.do_action(request, op, id)
mod.do_action(request, op, id, data)
except faults.BadRequest as e:
status = 400
response['result'] = e.message
......
# Copyright (C) 2010-2014 GRNET S.A.
# Copyright (C) 2010-2016 GRNET S.A.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
......@@ -89,6 +89,7 @@ DEFAULT_ADMIN_RBAC = {
'verify': [ADMIN_GROUP],
'resend_verification': [ADMIN_GROUP],
'contact': [ADMIN_HELPDESK_GROUP, ADMIN_GROUP],
'modify_email': [ADMIN_HELPDESK_GROUP, ADMIN_GROUP],
}, 'vm': {
'start': [ADMIN_HELPDESK_GROUP, ADMIN_GROUP],
'shutdown': [ADMIN_HELPDESK_GROUP, ADMIN_GROUP],
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment