Update project list in the header bar.

Use function for clean cache (from openstack_auth), after project
members were changed(for project cache is invalidated).
Now, in the header bar, show only active projects.

Change-Id: Ia2561b591b4f3de29a14aaa4b666b16fc1d4cec8
Closes-Bug: #1393659
This commit is contained in:
Vlad Okhrimenko 2014-11-26 16:40:48 +02:00
parent 60cfc4e234
commit a47c984623
3 changed files with 17 additions and 1 deletions

View File

@ -40,7 +40,9 @@ def openstack(request):
# Auth/Keystone context
context.setdefault('authorized_tenants', [])
if request.user.is_authenticated():
context['authorized_tenants'] = request.user.authorized_tenants
context['authorized_tenants'] = [
tenant for tenant in
request.user.authorized_tenants if tenant.enabled]
# Region context/support
available_regions = getattr(settings, 'AVAILABLE_REGIONS', [])

View File

@ -16,6 +16,8 @@ from django.utils.http import urlencode
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import ungettext_lazy
from openstack_auth import utils as auth_utils
from horizon import exceptions
from horizon import forms
from horizon import tables
@ -155,6 +157,12 @@ class DeleteTenantsAction(tables.DeleteAction):
def delete(self, request, obj_id):
api.keystone.tenant_delete(request, obj_id)
def handle(self, table, request, obj_ids):
response = \
super(DeleteTenantsAction, self).handle(table, request, obj_ids)
auth_utils.remove_project_cache(request.user.token.id)
return response
class TenantFilterAction(tables.FilterAction):
def filter(self, table, tenants, filter_string):

View File

@ -21,6 +21,8 @@ from django.conf import settings
from django.core.urlresolvers import reverse
from django.utils.translation import ugettext_lazy as _
from openstack_auth import utils as auth_utils
from horizon import exceptions
from horizon import forms
from horizon import messages
@ -444,6 +446,8 @@ class CreateProject(workflows.Workflow):
'members%(group_msg)s and set project quotas.')
% {'users_to_add': users_to_add,
'group_msg': group_msg})
finally:
auth_utils.remove_project_cache(request.user.token.id)
def _update_project_groups(self, request, data, project_id):
# update project groups
@ -697,6 +701,8 @@ class UpdateProject(workflows.Workflow):
% {'users_to_modify': users_to_modify,
'group_msg': group_msg})
return False
finally:
auth_utils.remove_project_cache(request.user.token.id)
def _update_project_groups(self, request, data, project_id, domain_id):
# update project groups