Merge "Change from client filter to server filter in metadata page"

This commit is contained in:
Jenkins 2016-06-28 01:30:50 +00:00 committed by Gerrit Code Review
commit 152fce7fd4
3 changed files with 21 additions and 4 deletions

View File

@ -82,7 +82,8 @@ class ManageResourceTypeAssociations(tables.LinkAction):
class AdminMetadataFilterAction(tables.FilterAction):
pass
filter_type = "server"
filter_choices = (('resource_types', _("Resource Types ="), True),)
class UpdateRow(tables.Row):

View File

@ -49,7 +49,8 @@ class MetadataDefinitionsView(test.BaseAdminViewTests):
IsA(http.HttpRequest),
sort_dir='asc',
marker=None,
paginate=True).AndReturn((namespace_list, False, False))
paginate=True,
filters={}).AndReturn((namespace_list, False, False))
self.mox.ReplayAll()
res = self.client.get(reverse(constants.METADATA_INDEX_URL))
@ -89,7 +90,8 @@ class MetadataDefinitionsView(test.BaseAdminViewTests):
IsA(http.HttpRequest),
sort_dir='asc',
marker=None,
paginate=True).AndReturn((namespace_list, False, False))
paginate=True,
filters={}).AndReturn((namespace_list, False, False))
self.mox.ReplayAll()
res = self.client.get(reverse(constants.METADATA_INDEX_URL))

View File

@ -59,12 +59,15 @@ class AdminIndexView(tables.DataTableView):
marker = self.request.GET.get(
admin_tables.AdminNamespacesTable._meta.pagination_param, None)
filters = self.get_filters()
try:
namespaces, self._more, self._prev =\
glance.metadefs_namespace_list(self.request,
marker=marker,
paginate=True,
sort_dir=sort_dir)
sort_dir=sort_dir,
filters=filters)
if prev_marker is not None:
namespaces = sorted(namespaces,
@ -77,6 +80,17 @@ class AdminIndexView(tables.DataTableView):
exceptions.handle(self.request, msg)
return namespaces
def get_filters(self, filters=None):
if not filters:
filters = {}
filter_field = self.table.get_filter_field()
filter_action = self.table._meta._filter_action
if filter_action.is_api_filter(filter_field):
filter_string = self.table.get_filter_string().strip()
if filter_field and filter_string:
filters[filter_field] = filter_string
return filters
class CreateView(forms.ModalFormView):
form_class = admin_forms.CreateNamespaceForm