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
This commit is contained in:
parent
8b6952e1bc
commit
ca5736a2dc
@ -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)
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user