Merge "Implement admin_filter_first setting in Admin>Volumes"

This commit is contained in:
Jenkins
2016-09-07 09:57:29 +00:00
committed by Gerrit Code Review
2 changed files with 18 additions and 1 deletions

View File

@@ -11,6 +11,7 @@
# under the License.
from collections import OrderedDict
from django.conf import settings
from django.utils.translation import ugettext_lazy as _
from horizon import exceptions
@@ -44,9 +45,17 @@ class VolumeTab(volumes_tabs.PagedTableMixin, tabs.TableTab,
def get_volumes_data(self):
default_filters = {'all_tenants': True}
filters = self.get_filters(default_filters)
filters = self.get_filters(default_filters.copy())
filter_first = getattr(settings, 'ADMIN_FILTER_DATA_FIRST', False)
volumes = []
self.table.needs_filter_first = False
if filter_first and len(filters) == len(default_filters):
self.table.needs_filter_first = True
return volumes
if 'project' in filters:
# Keystone returns a tuple ([],false) where the first element is
# tenant list that's why the 0 is hardcoded below

View File

@@ -311,3 +311,11 @@ class VolumeTests(test.BaseAdminViewTests):
url=url, has_more=True, has_prev=False)
snapshots = res.context['volume_snapshots_table'].data
self.assertItemsEqual(snapshots, expected_snapshots)
@override_settings(ADMIN_FILTER_DATA_FIRST=True)
def test_volumes_tab_with_admin_filter_first(self):
res = self.client.get(INDEX_URL)
self.assertTemplateUsed(res, 'admin/volumes/index.html')
volumes = res.context['volumes_table'].data
self.assertItemsEqual(volumes, [])