Merge "Fetch user's projects from request.user"

This commit is contained in:
Jenkins
2015-04-02 01:39:59 +00:00
committed by Gerrit Code Review
2 changed files with 8 additions and 4 deletions

View File

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

View File

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