From ca5736a2dc61913b2ae70613d94c85b07b18735b Mon Sep 17 00:00:00 2001 From: lin-hua-cheng Date: Tue, 31 Mar 2015 15:59:20 -0700 Subject: [PATCH] Fetch user's projects from request.user Instead of hitting the backend api, the user's projects can be fetched from request.user. Change-Id: I9cbdeded40d4cc4f54ff0c52f5fd8ea7280ef7cf Closes-Bug: #1439338 --- openstack_dashboard/api/keystone.py | 8 +++++++- openstack_dashboard/dashboards/identity/projects/views.py | 4 +--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/openstack_dashboard/api/keystone.py b/openstack_dashboard/api/keystone.py index da726d1c35..2b5eb5ba42 100644 --- a/openstack_dashboard/api/keystone.py +++ b/openstack_dashboard/api/keystone.py @@ -264,7 +264,13 @@ def tenant_list(request, paginate=False, marker=None, domain=None, user=None, limit = page_size + 1 has_more_data = False - if VERSIONS.active < 3: + + # if requesting the projects for the current user, + # return the list from the cache + if user == request.user.id: + tenants = request.user.authorized_tenants + + elif VERSIONS.active < 3: tenants = manager.list(limit, marker) if paginate and len(tenants) > page_size: tenants.pop(-1) diff --git a/openstack_dashboard/dashboards/identity/projects/views.py b/openstack_dashboard/dashboards/identity/projects/views.py index 3754f309d3..a6dbb9dc50 100644 --- a/openstack_dashboard/dashboards/identity/projects/views.py +++ b/openstack_dashboard/dashboards/identity/projects/views.py @@ -78,6 +78,7 @@ class IndexView(tables.DataTableView): marker = self.request.GET.get( project_tables.TenantsTable._meta.pagination_param, None) domain_context = self.request.session.get('domain_context', None) + self._more = False if policy.check((("identity", "identity:list_projects"),), self.request): try: @@ -87,7 +88,6 @@ class IndexView(tables.DataTableView): paginate=True, marker=marker) except Exception: - self._more = False exceptions.handle(self.request, _("Unable to retrieve project list.")) elif policy.check((("identity", "identity:list_user_projects"),), @@ -100,11 +100,9 @@ class IndexView(tables.DataTableView): marker=marker, admin=False) except Exception: - self._more = False exceptions.handle(self.request, _("Unable to retrieve project information.")) else: - self._more = False msg = \ _("Insufficient privilege level to view project information.") messages.info(self.request, msg)