From 3d7b163f87a6f71308bd6016c3a4e620de4753c5 Mon Sep 17 00:00:00 2001 From: Timur Sufiev Date: Tue, 13 Jan 2015 16:25:07 +0300 Subject: [PATCH] Fix setting Primary Project for new user once the project was created When the project is being created via pressing '+' button at Create User form, it is important to store the reference to it inside the `workflow.object` attribute, otherwise [None, None] value will be returned to the client-side code which will cause appending "null" value to the list of available projects - instead of adding the newly created project name and selecting it as the current value. Change-Id: I10fcb1f2fb51e341b15901d4f014f0e4faca3adf Closes-Bug: #1410129 --- horizon/workflows/views.py | 10 ++++++---- .../dashboards/identity/projects/workflows.py | 11 ++++++----- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/horizon/workflows/views.py b/horizon/workflows/views.py index c8c7ff6d13..f708f5aace 100644 --- a/horizon/workflows/views.py +++ b/horizon/workflows/views.py @@ -203,10 +203,12 @@ class WorkflowView(hz_views.ModalBackdropMixin, generic.TemplateView): messages.error(request, msg) if "HTTP_X_HORIZON_ADD_TO_FIELD" in self.request.META: field_id = self.request.META["HTTP_X_HORIZON_ADD_TO_FIELD"] - data = [self.get_object_id(workflow.object), - self.get_object_display(workflow.object)] - response = http.HttpResponse(json.dumps(data)) - response["X-Horizon-Add-To-Field"] = field_id + response = http.HttpResponse() + if workflow.object: + data = [self.get_object_id(workflow.object), + self.get_object_display(workflow.object)] + response.content = json.dumps(data) + response["X-Horizon-Add-To-Field"] = field_id return response next_url = self.request.REQUEST.get(workflow.redirect_param_name, None) return shortcuts.redirect(next_url or workflow.get_success_url()) diff --git a/openstack_dashboard/dashboards/identity/projects/workflows.py b/openstack_dashboard/dashboards/identity/projects/workflows.py index f96cbcc215..b07090ea85 100644 --- a/openstack_dashboard/dashboards/identity/projects/workflows.py +++ b/openstack_dashboard/dashboards/identity/projects/workflows.py @@ -404,11 +404,12 @@ class CreateProject(workflows.Workflow): domain_id = data['domain_id'] try: desc = data['description'] - return api.keystone.tenant_create(request, - name=data['name'], - description=desc, - enabled=data['enabled'], - domain=domain_id) + self.object = api.keystone.tenant_create(request, + name=data['name'], + description=desc, + enabled=data['enabled'], + domain=domain_id) + return self.object except Exception: exceptions.handle(request, ignore=True) return