diff --git a/openstack_dashboard/dashboards/admin/metadata_defs/tables.py b/openstack_dashboard/dashboards/admin/metadata_defs/tables.py index 7ce4db8573..50e46c135d 100644 --- a/openstack_dashboard/dashboards/admin/metadata_defs/tables.py +++ b/openstack_dashboard/dashboards/admin/metadata_defs/tables.py @@ -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): diff --git a/openstack_dashboard/dashboards/admin/metadata_defs/tests.py b/openstack_dashboard/dashboards/admin/metadata_defs/tests.py index 5437e08ec2..4718aa0bfd 100644 --- a/openstack_dashboard/dashboards/admin/metadata_defs/tests.py +++ b/openstack_dashboard/dashboards/admin/metadata_defs/tests.py @@ -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)) diff --git a/openstack_dashboard/dashboards/admin/metadata_defs/views.py b/openstack_dashboard/dashboards/admin/metadata_defs/views.py index fafb94e74f..129c357b8b 100644 --- a/openstack_dashboard/dashboards/admin/metadata_defs/views.py +++ b/openstack_dashboard/dashboards/admin/metadata_defs/views.py @@ -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