Modify update user info from pencil icon in keystone v2
When we update the user info from pencil icon in User List, data doesn't have 'project' attribute. Therefore, date.pop('project') failed and exception occur. The v2 API updates user model and default project separately. And in User List, operator don't need to consider if a user have a default tenant. So we should check if data has a 'project' attribute and if data has no 'project' attribute, it will update only user info. Change-Id: I979bedeb8ddb15d3f7f171660ec9df4875edb53a Closes-Bug: #1523343
This commit is contained in:
parent
4b5886d276
commit
6beefb3726
@ -354,8 +354,6 @@ def user_update(request, user, **data):
|
||||
|
||||
# The v2 API updates user model and default project separately
|
||||
if VERSIONS.active < 3:
|
||||
project = data.pop('project')
|
||||
|
||||
# Update user details
|
||||
try:
|
||||
user = manager.update(user, **data)
|
||||
@ -364,21 +362,24 @@ def user_update(request, user, **data):
|
||||
except Exception:
|
||||
error = exceptions.handle(request, ignore=True)
|
||||
|
||||
# Update default tenant
|
||||
try:
|
||||
user_update_tenant(request, user, project)
|
||||
user.tenantId = project
|
||||
except Exception:
|
||||
error = exceptions.handle(request, ignore=True)
|
||||
if "project" in data:
|
||||
project = data.pop('project')
|
||||
|
||||
# Check for existing roles
|
||||
# Show a warning if no role exists for the project
|
||||
user_roles = roles_for_user(request, user, project)
|
||||
if not user_roles:
|
||||
messages.warning(request,
|
||||
_('User %s has no role defined for '
|
||||
'that project.')
|
||||
% data.get('name', None))
|
||||
# Update default tenant
|
||||
try:
|
||||
user_update_tenant(request, user, project)
|
||||
user.tenantId = project
|
||||
except Exception:
|
||||
error = exceptions.handle(request, ignore=True)
|
||||
|
||||
# Check for existing roles
|
||||
# Show a warning if no role exists for the project
|
||||
user_roles = roles_for_user(request, user, project)
|
||||
if not user_roles:
|
||||
messages.warning(request,
|
||||
_('User %s has no role defined for '
|
||||
'that project.')
|
||||
% data.get('name', None))
|
||||
|
||||
if error is not None:
|
||||
raise error
|
||||
|
Loading…
x
Reference in New Issue
Block a user