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) messages.error(request, msg)
if "HTTP_X_HORIZON_ADD_TO_FIELD" in self.request.META: if "HTTP_X_HORIZON_ADD_TO_FIELD" in self.request.META:
field_id = self.request.META["HTTP_X_HORIZON_ADD_TO_FIELD"] field_id = self.request.META["HTTP_X_HORIZON_ADD_TO_FIELD"]
data = [self.get_object_id(workflow.object), response = http.HttpResponse()
self.get_object_display(workflow.object)] if workflow.object:
response = http.HttpResponse(json.dumps(data)) data = [self.get_object_id(workflow.object),
response["X-Horizon-Add-To-Field"] = field_id self.get_object_display(workflow.object)]
response.content = json.dumps(data)
response["X-Horizon-Add-To-Field"] = field_id
return response return response
next_url = self.request.REQUEST.get(workflow.redirect_param_name, None) next_url = self.request.REQUEST.get(workflow.redirect_param_name, None)
return shortcuts.redirect(next_url or workflow.get_success_url()) 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'] domain_id = data['domain_id']
try: try:
desc = data['description'] desc = data['description']
return api.keystone.tenant_create(request, self.object = api.keystone.tenant_create(request,
name=data['name'], name=data['name'],
description=desc, description=desc,
enabled=data['enabled'], enabled=data['enabled'],
domain=domain_id) domain=domain_id)
return self.object
except Exception: except Exception:
exceptions.handle(request, ignore=True) exceptions.handle(request, ignore=True)
return return