diff --git a/snf-admin-app/synnefo_admin/admin/resources/groups/views.py b/snf-admin-app/synnefo_admin/admin/resources/groups/views.py
index 279428697e647ab817a6b06526973a3168403010..c0584e3fc9b84c68f80843ff52fe8ab5b3f37476 100644
--- a/snf-admin-app/synnefo_admin/admin/resources/groups/views.py
+++ b/snf-admin-app/synnefo_admin/admin/resources/groups/views.py
@@ -1,4 +1,4 @@
-# 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")
diff --git a/snf-admin-app/synnefo_admin/admin/resources/ips/views.py b/snf-admin-app/synnefo_admin/admin/resources/ips/views.py
index d751590baca01a7200dbf7832ae57c7e8a12b77d..821d761573313724620ff02c248cea3c20c6f687 100644
--- a/snf-admin-app/synnefo_admin/admin/resources/ips/views.py
+++ b/snf-admin-app/synnefo_admin/admin/resources/ips/views.py
@@ -1,4 +1,4 @@
-# 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)
diff --git a/snf-admin-app/synnefo_admin/admin/resources/networks/views.py b/snf-admin-app/synnefo_admin/admin/resources/networks/views.py
index 4e2b690982dfb1e1039d2cda384a52b34e108ad7..bf5709e50eac01ac078e13f75ca6794e39205ed4 100644
--- a/snf-admin-app/synnefo_admin/admin/resources/networks/views.py
+++ b/snf-admin-app/synnefo_admin/admin/resources/networks/views.py
@@ -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)
diff --git a/snf-admin-app/synnefo_admin/admin/resources/projects/views.py b/snf-admin-app/synnefo_admin/admin/resources/projects/views.py
index 85fea42cf35bc2afd1ef5e4d0a42d9ee957e31d1..568bd76289043fc05f3cf023d1743b0c632cf461 100644
--- a/snf-admin-app/synnefo_admin/admin/resources/projects/views.py
+++ b/snf-admin-app/synnefo_admin/admin/resources/projects/views.py
@@ -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)
diff --git a/snf-admin-app/synnefo_admin/admin/resources/users/actions.py b/snf-admin-app/synnefo_admin/admin/resources/users/actions.py
index 7ffc276637e54ba3cd4f6e17e94b06d7485a9308..68253c35d2f5114f00a905cef5b74df588a4998d 100644
--- a/snf-admin-app/synnefo_admin/admin/resources/users/actions.py
+++ b/snf-admin-app/synnefo_admin/admin/resources/users/actions.py
@@ -1,4 +1,4 @@
-# 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
diff --git a/snf-admin-app/synnefo_admin/admin/resources/users/views.py b/snf-admin-app/synnefo_admin/admin/resources/users/views.py
index eb86d441c30c9265cc474b0038a32262541301c5..54ef8eda4470fae4d5472d7f3364185b798c3f6d 100644
--- a/snf-admin-app/synnefo_admin/admin/resources/users/views.py
+++ b/snf-admin-app/synnefo_admin/admin/resources/users/views.py
@@ -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)
diff --git a/snf-admin-app/synnefo_admin/admin/resources/vms/views.py b/snf-admin-app/synnefo_admin/admin/resources/vms/views.py
index ff9a7bd0b1682039cd69ac46c2e74c7017dc52bb..afc9bb3678ea5cad9fdb3a7e6ece93637ac3db86 100644
--- a/snf-admin-app/synnefo_admin/admin/resources/vms/views.py
+++ b/snf-admin-app/synnefo_admin/admin/resources/vms/views.py
@@ -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)
diff --git a/snf-admin-app/synnefo_admin/admin/resources/volumes/views.py b/snf-admin-app/synnefo_admin/admin/resources/volumes/views.py
index 3f1ad6af4858915c14f4dd7647c32cfabad85520..44f58d5c4ef503fed66714d5d12005f4814173cd 100644
--- a/snf-admin-app/synnefo_admin/admin/resources/volumes/views.py
+++ b/snf-admin-app/synnefo_admin/admin/resources/volumes/views.py
@@ -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)
diff --git a/snf-admin-app/synnefo_admin/admin/views.py b/snf-admin-app/synnefo_admin/admin/views.py
index d035606508421225763254c87daefc466cd2f27e..665d3c8c194979e71072ccd3f5013176cf750918 100644
--- a/snf-admin-app/synnefo_admin/admin/views.py
+++ b/snf-admin-app/synnefo_admin/admin/views.py
@@ -1,4 +1,4 @@
-# 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
diff --git a/snf-admin-app/synnefo_admin/admin_settings.py b/snf-admin-app/synnefo_admin/admin_settings.py
index 0b52c9dc92e347215f4723d80c106994852f868e..7fb9159869cc4b0c5f010cc4698a3531c2a60b7e 100644
--- a/snf-admin-app/synnefo_admin/admin_settings.py
+++ b/snf-admin-app/synnefo_admin/admin_settings.py
@@ -1,4 +1,4 @@
-# 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],