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
This commit is contained in:
Timur Sufiev 2015-01-13 16:25:07 +03:00
parent a69f712d94
commit 3d7b163f87
2 changed files with 12 additions and 9 deletions

View File

@ -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())

View File

@ -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