From fb2a31cff6273a767ad371c1c6893233aa1ca047 Mon Sep 17 00:00:00 2001 From: Kuo-tung Kao Date: Tue, 14 Jul 2015 14:54:43 +0800 Subject: [PATCH] Don't get descript if attribute doesn't exist. Don't get description attribute from user_obj in update_cell function in user table if the attribute doesn't exist. Closes-Bug: #1474228 Change-Id: I38978402991121e2e2259856aa52b633a60cba36 --- .../dashboards/identity/users/tables.py | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/openstack_dashboard/dashboards/identity/users/tables.py b/openstack_dashboard/dashboards/identity/users/tables.py index 0ed9244028..5bdc143028 100644 --- a/openstack_dashboard/dashboards/identity/users/tables.py +++ b/openstack_dashboard/dashboards/identity/users/tables.py @@ -193,14 +193,20 @@ class UpdateCell(tables.UpdateAction): try: user_obj = datum setattr(user_obj, cell_name, new_cell_value) - api.keystone.user_update( - request, - user_obj, - name=user_obj.name, - description=user_obj.description, - email=user_obj.email, - enabled=user_obj.enabled, - project=user_obj.project_id) + kwargs = {} + attr_to_keyword_map = { + 'name': 'name', + 'description': 'description', + 'email': 'email', + 'enabled': 'enabled', + 'project_id': 'project' + } + for key in attr_to_keyword_map: + value = getattr(user_obj, key, None) + keyword_name = attr_to_keyword_map[key] + if value is not None: + kwargs[keyword_name] = value + api.keystone.user_update(request, user_obj, **kwargs) except horizon_exceptions.Conflict: message = _("This name is already taken.")