Add default common template to python table views

Many of the Python table views are using identical (or nearly identical)
table templates. This patch adds a common template and makes it the
default for a DataTableView, which allows us to remove many similar
templates and redundant lines of code.

Change-Id: I1e4e15e695ee1f21f4d44f141a854e30f1e567a1
Closes-Bug: 1653986
This commit is contained in:
Rob Cresswell 2017-01-04 16:32:33 +00:00
parent dcd22840e0
commit 560f23a1c9
51 changed files with 70 additions and 190 deletions

View File

@ -240,6 +240,7 @@ class DataTableView(MultiTableView):
"""
table_class = None
context_object_name = 'table'
template_name = 'horizon/common/_data_table_view.html'
def _get_data_dict(self):
if not self._data:

View File

@ -0,0 +1,3 @@
{% extends 'base.html' %}
{% block title %}{{ page_title }}{% endblock %}
{% block main %}{{ table.render }}{% endblock %}

View File

@ -10,7 +10,7 @@
# License for the specific language governing permissions and limitations
# under the License.
FLAVORS_TEMPLATE_NAME = 'admin/flavors/index.html'
FLAVORS_TEMPLATE_NAME = 'horizon/common/_data_table_view.html'
FLAVORS_INDEX_URL = 'horizon:admin:flavors:index'
FLAVORS_CREATE_URL = 'horizon:admin:flavors:create'
FLAVORS_CREATE_VIEW_TEMPLATE = 'admin/flavors/create.html'

View File

@ -1,7 +0,0 @@
{% extends 'base.html' %}
{% load i18n %}
{% block title %}{% trans "Flavors" %}{% endblock %}
{% block main %}
{{ table.render }}
{% endblock %}

View File

@ -36,7 +36,6 @@ INDEX_URL = "horizon:admin:flavors:index"
class IndexView(tables.DataTableView):
table_class = project_tables.FlavorsTable
template_name = 'admin/flavors/index.html'
page_title = _("Flavors")
def has_prev_data(self, table):

View File

@ -1,7 +0,0 @@
{% extends 'base.html' %}
{% load i18n %}
{% block title %}{% trans "Floating IPs" %}{% endblock %}
{% block main %}
{{ table.render }}
{% endblock %}

View File

@ -21,6 +21,7 @@ from openstack_dashboard import api
from openstack_dashboard.test import helpers as test
INDEX_URL = reverse('horizon:admin:floating_ips:index')
INDEX_TEMPLATE = 'horizon/common/_data_table_view.html'
class AdminFloatingIpViewTest(test.BaseAdminViewTests):
@ -46,7 +47,7 @@ class AdminFloatingIpViewTest(test.BaseAdminViewTests):
self.mox.ReplayAll()
res = self.client.get(INDEX_URL)
self.assertTemplateUsed(res, 'admin/floating_ips/index.html')
self.assertTemplateUsed(res, INDEX_TEMPLATE)
self.assertIn('floating_ips_table', res.context)
floating_ips_table = res.context['floating_ips_table']
floating_ips = floating_ips_table.data
@ -96,7 +97,7 @@ class AdminFloatingIpViewTest(test.BaseAdminViewTests):
self.mox.ReplayAll()
res = self.client.get(INDEX_URL)
self.assertTemplateUsed(res, 'admin/floating_ips/index.html')
self.assertTemplateUsed(res, INDEX_TEMPLATE)
@test.create_stubs({api.network: ('tenant_floating_ip_list', )})
def test_index_error(self):
@ -106,7 +107,7 @@ class AdminFloatingIpViewTest(test.BaseAdminViewTests):
self.mox.ReplayAll()
res = self.client.get(INDEX_URL)
self.assertTemplateUsed(res, 'admin/floating_ips/index.html')
self.assertTemplateUsed(res, INDEX_TEMPLATE)
@test.create_stubs({api.neutron: ('network_list',),
api.keystone: ('tenant_list',)})
@ -261,7 +262,7 @@ class AdminFloatingIpViewTest(test.BaseAdminViewTests):
self.mox.ReplayAll()
res = self.client.get(INDEX_URL)
self.assertTemplateUsed(res, 'admin/floating_ips/index.html')
self.assertTemplateUsed(res, INDEX_TEMPLATE)
self.assertIn('floating_ips_table', res.context)
floating_ips_table = res.context['floating_ips_table']
floating_ips = floating_ips_table.data

View File

@ -59,7 +59,6 @@ def get_tenant_list(request):
class IndexView(tables.DataTableView):
table_class = fip_tables.FloatingIPsTable
template_name = 'admin/floating_ips/index.html'
page_title = _("Floating IPs")
@memoized.memoized_method

View File

@ -41,7 +41,7 @@ class HypervisorViewTest(test.BaseAdminViewTests):
self.mox.ReplayAll()
res = self.client.get(reverse('horizon:admin:hypervisors:index'))
self.assertTemplateUsed(res, 'admin/hypervisors/index.html')
self.assertTemplateUsed(res, 'horizon/common/_data_table_view.html')
hypervisors_tab = res.context['tab_group'].get_tab('hypervisor')
self.assertItemsEqual(hypervisors_tab._tables['hypervisors'].data,

View File

@ -27,7 +27,7 @@ from openstack_dashboard.dashboards.admin.hypervisors \
class AdminIndexView(tabs.TabbedTableView):
tab_group_class = project_tabs.HypervisorHostTabs
template_name = 'admin/hypervisors/index.html'
template_name = 'horizon/common/_data_table_view.html'
page_title = _("All Hypervisors")
def get_context_data(self, **kwargs):

View File

@ -1,7 +0,0 @@
{% extends 'base.html' %}
{% load i18n %}
{% block title %}{% trans "Images" %}{% endblock %}
{% block main %}
{{ table.render }}
{% endblock %}

View File

@ -24,6 +24,8 @@ from openstack_dashboard.test import helpers as test
from openstack_dashboard.dashboards.admin.images import tables
INDEX_TEMPLATE = 'horizon/common/_data_table_view.html'
class ImageCreateViewTest(test.BaseAdminViewTests):
@test.create_stubs({api.glance: ('image_list_detailed',)})
@ -64,14 +66,14 @@ class ImagesViewTest(test.BaseAdminViewTests):
res = self.client.get(
reverse('horizon:admin:images:index'))
self.assertContains(res, 'test_tenant', 9, 200)
self.assertTemplateUsed(res, 'admin/images/index.html')
self.assertTemplateUsed(res, INDEX_TEMPLATE)
self.assertEqual(len(res.context['images_table'].data),
len(self.images.list()))
@test.update_settings(FILTER_DATA_FIRST={'admin.images': True})
def test_images_list_with_admin_filter_first(self):
res = self.client.get(reverse('horizon:admin:images:index'))
self.assertTemplateUsed(res, 'admin/images/index.html')
self.assertTemplateUsed(res, INDEX_TEMPLATE)
images = res.context['table'].data
self.assertItemsEqual(images, [])
@ -110,7 +112,7 @@ class ImagesViewTest(test.BaseAdminViewTests):
# get all
self.assertEqual(len(res.context['images_table'].data),
len(images))
self.assertTemplateUsed(res, 'admin/images/index.html')
self.assertTemplateUsed(res, INDEX_TEMPLATE)
self.assertContains(res, 'test_tenant', 7, 200)
res = self.client.get(url)
@ -174,7 +176,7 @@ class ImagesViewTest(test.BaseAdminViewTests):
# get all
self.assertEqual(len(res.context['images_table'].data),
len(images))
self.assertTemplateUsed(res, 'admin/images/index.html')
self.assertTemplateUsed(res, INDEX_TEMPLATE)
self.assertContains(res, 'test_tenant', 5, 200)
res = self.client.get(url)

View File

@ -44,7 +44,6 @@ LOG = logging.getLogger(__name__)
class IndexView(tables.DataTableView):
DEFAULT_FILTERS = {'is_public': None}
table_class = project_tables.AdminImagesTable
template_name = 'admin/images/index.html'
page_title = _("Images")
def has_prev_data(self, table):

View File

@ -1,7 +0,0 @@
{% extends 'base.html' %}
{% load i18n %}
{% block title %}{% trans "Instances" %}{% endblock %}
{% block main %}
{{ table.render }}
{% endblock %}

View File

@ -26,6 +26,7 @@ from openstack_dashboard.test import helpers as test
INDEX_URL = reverse('horizon:admin:instances:index')
INDEX_TEMPLATE = 'horizon/common/_data_table_view.html'
class InstanceViewTest(test.BaseAdminViewTests):
@ -58,7 +59,7 @@ class InstanceViewTest(test.BaseAdminViewTests):
self.mox.ReplayAll()
res = self.client.get(INDEX_URL)
self.assertTemplateUsed(res, 'admin/instances/index.html')
self.assertTemplateUsed(res, INDEX_TEMPLATE)
instances = res.context['table'].data
self.assertItemsEqual(instances, servers)
@ -95,7 +96,7 @@ class InstanceViewTest(test.BaseAdminViewTests):
self.mox.ReplayAll()
res = self.client.get(INDEX_URL)
self.assertTemplateUsed(res, 'admin/instances/index.html')
self.assertTemplateUsed(res, INDEX_TEMPLATE)
instances = res.context['table'].data
self.assertItemsEqual(instances, servers)
@ -138,7 +139,7 @@ class InstanceViewTest(test.BaseAdminViewTests):
res = self.client.get(INDEX_URL)
instances = res.context['table'].data
self.assertTemplateUsed(res, 'admin/instances/index.html')
self.assertTemplateUsed(res, INDEX_TEMPLATE)
# Since error messages produced for each instance are identical,
# there will be only one error message for all instances
# (messages de-duplication).
@ -163,7 +164,7 @@ class InstanceViewTest(test.BaseAdminViewTests):
self.mox.ReplayAll()
res = self.client.get(INDEX_URL)
self.assertTemplateUsed(res, 'admin/instances/index.html')
self.assertTemplateUsed(res, INDEX_TEMPLATE)
self.assertEqual(len(res.context['instances_table'].data), 0)
@test.create_stubs({api.nova: ('server_get', 'flavor_get',
@ -430,6 +431,6 @@ class InstanceViewTest(test.BaseAdminViewTests):
@test.update_settings(FILTER_DATA_FIRST={'admin.instances': True})
def test_index_with_admin_filter_first(self):
res = self.client.get(INDEX_URL)
self.assertTemplateUsed(res, 'admin/instances/index.html')
self.assertTemplateUsed(res, INDEX_TEMPLATE)
instances = res.context['table'].data
self.assertItemsEqual(instances, [])

View File

@ -72,7 +72,6 @@ class AdminUpdateView(views.UpdateView):
class AdminIndexView(tables.DataTableView):
table_class = project_tables.AdminInstancesTable
template_name = 'admin/instances/index.html'
page_title = _("Instances")
def has_more_data(self, table):

View File

@ -20,7 +20,7 @@ METADATA_DETAIL_OVERVIEW_TEMPLATE = "admin/metadata_defs/_detail_overview.html"
METADATA_DETAIL_CONTENTS_TEMPLATE = "admin/metadata_defs/_detail_contents.html"
METADATA_DETAIL_TEMPLATE = 'horizon/common/_detail.html'
METADATA_DETAIL_URL = "horizon:admin:metadata_defs:detail"
METADATA_INDEX_TEMPLATE = 'admin/metadata_defs/index.html'
METADATA_INDEX_TEMPLATE = 'horizon/common/_data_table_view.html'
METADATA_INDEX_URL = 'horizon:admin:metadata_defs:index'
METADATA_MANAGE_RESOURCES_TEMPLATE = 'admin/metadata_defs/resource_types.html'
METADATA_MANAGE_RESOURCES_URL = 'horizon:admin:metadata_defs:resource_types'

View File

@ -1,7 +0,0 @@
{% extends 'base.html' %}
{% load i18n %}
{% block title %}{% trans "Metadata Definitions" %}{% endblock %}
{% block main %}
{{ table.render }}
{% endblock %}

View File

@ -1,17 +0,0 @@
{% extends 'base.html' %}
{% load i18n %}
{% block title %}{% trans "Networks" %}{% endblock %}
{% block main %}
<div id="networks">
{{ networks_table.render }}
</div>
<div id="subnets">
{{ subnets_table.render }}
</div>
<div id="ports">
{{ ports_table.render }}
</div>
{% endblock %}

View File

@ -23,7 +23,7 @@ from mox3.mox import IsA # noqa
from openstack_dashboard import api
from openstack_dashboard.test import helpers as test
INDEX_TEMPLATE = 'horizon/common/_data_table_view.html'
INDEX_URL = reverse('horizon:admin:networks:index')
@ -53,7 +53,7 @@ class NetworkTests(test.BaseAdminViewTests):
res = self.client.get(INDEX_URL)
self.assertTemplateUsed(res, 'admin/networks/index.html')
self.assertTemplateUsed(res, INDEX_TEMPLATE)
networks = res.context['networks_table'].data
self.assertItemsEqual(networks, self.networks.list())
@ -70,7 +70,7 @@ class NetworkTests(test.BaseAdminViewTests):
res = self.client.get(INDEX_URL)
self.assertTemplateUsed(res, 'admin/networks/index.html')
self.assertTemplateUsed(res, INDEX_TEMPLATE)
self.assertEqual(len(res.context['networks_table'].data), 0)
self.assertMessageCount(res, error=1)
@ -769,6 +769,6 @@ class NetworkTests(test.BaseAdminViewTests):
'dhcp_agent_scheduler').AndReturn(True)
self.mox.ReplayAll()
res = self.client.get(reverse('horizon:admin:networks:index'))
self.assertTemplateUsed(res, 'admin/networks/index.html')
self.assertTemplateUsed(res, INDEX_TEMPLATE)
networks = res.context['networks_table'].data
self.assertItemsEqual(networks, [])

View File

@ -43,7 +43,6 @@ from openstack_dashboard.dashboards.admin.networks \
class IndexView(tables.DataTableView):
table_class = networks_tables.NetworksTable
template_name = 'admin/networks/index.html'
page_title = _("Networks")
FILTERS_MAPPING = {'shared': {_("yes"): True, _("no"): False},
'router:external': {_("yes"): True, _("no"): False},

View File

@ -1,7 +0,0 @@
{% extends 'base.html' %}
{% load i18n %}
{% block title %}{% trans "Routers" %}{% endblock %}
{% block main %}
{{ table.render }}
{% endblock %}

View File

@ -22,6 +22,8 @@ from openstack_dashboard import api
from openstack_dashboard.dashboards.project.routers import tests as r_test
from openstack_dashboard.test import helpers as test
INDEX_TEMPLATE = 'horizon/common/_data_table_view.html'
class RouterTests(test.BaseAdminViewTests, r_test.RouterTests):
DASHBOARD = 'admin'
@ -47,7 +49,7 @@ class RouterTests(test.BaseAdminViewTests, r_test.RouterTests):
res = self.client.get(self.INDEX_URL)
self.assertTemplateUsed(res, '%s/routers/index.html' % self.DASHBOARD)
self.assertTemplateUsed(res, INDEX_TEMPLATE)
routers = res.context['table'].data
self.assertItemsEqual(routers, self.routers.list())
@ -60,7 +62,7 @@ class RouterTests(test.BaseAdminViewTests, r_test.RouterTests):
res = self.client.get(self.INDEX_URL)
self.assertTemplateUsed(res, '%s/routers/index.html' % self.DASHBOARD)
self.assertTemplateUsed(res, INDEX_TEMPLATE)
self.assertEqual(len(res.context['table'].data), 0)
self.assertMessageCount(res, error=1)
@ -87,7 +89,7 @@ class RouterTests(test.BaseAdminViewTests, r_test.RouterTests):
args=[agent.id])
res = self.client.get(l3_list_url)
self.assertTemplateUsed(res, '%s/routers/index.html' % self.DASHBOARD)
self.assertTemplateUsed(res, INDEX_TEMPLATE)
routers = res.context['table'].data
self.assertItemsEqual(routers, self.routers.list())
@ -108,7 +110,7 @@ class RouterTests(test.BaseAdminViewTests, r_test.RouterTests):
self.assertEqual(len(table_data), 1)
self.assertIn('(Not Found)',
table_data[0]['external_gateway_info']['network'])
self.assertTemplateUsed(res, '%s/routers/index.html' % self.DASHBOARD)
self.assertTemplateUsed(res, INDEX_TEMPLATE)
self.assertMessageCount(res, error=1)
@test.create_stubs({api.neutron: ('router_list', 'network_list',
@ -191,7 +193,7 @@ class RouterTests(test.BaseAdminViewTests, r_test.RouterTests):
@test.update_settings(FILTER_DATA_FIRST={'admin.routers': True})
def test_routers_list_with_admin_filter_first(self):
res = self.client.get(self.INDEX_URL)
self.assertTemplateUsed(res, '%s/routers/index.html' % self.DASHBOARD)
self.assertTemplateUsed(res, INDEX_TEMPLATE)
routers = res.context['table'].data
self.assertItemsEqual(routers, [])

View File

@ -31,7 +31,7 @@ from openstack_dashboard.dashboards.project.routers import views as r_views
class IndexView(r_views.IndexView, n_views.IndexView):
table_class = rtbl.RoutersTable
template_name = 'admin/routers/index.html'
template_name = 'horizon/common/_data_table_view.html'
FILTERS_MAPPING = {'admin_state_up': {_("up"): True, _("down"): False}}
def needs_filter_first(self, table):

View File

@ -1,7 +0,0 @@
{% extends 'base.html' %}
{% load i18n %}
{% block title %}{% trans "Identity Providers" %}{% endblock %}
{% block main %}
{{ table.render }}
{% endblock %}

View File

@ -40,7 +40,7 @@ class IdPsViewTests(test.BaseAdminViewTests):
res = self.client.get(IDPS_INDEX_URL)
self.assertTemplateUsed(res, 'identity/identity_providers/index.html')
self.assertTemplateUsed(res, 'horizon/common/_data_table_view.html')
self.assertItemsEqual(res.context['table'].data,
self.identity_providers.list())

View File

@ -36,7 +36,6 @@ from openstack_dashboard.dashboards.identity.identity_providers \
class IndexView(tables.DataTableView):
table_class = idp_tables.IdentityProvidersTable
template_name = 'identity/identity_providers/index.html'
page_title = _("Identity Providers")
def get_data(self):

View File

@ -1,7 +0,0 @@
{% extends 'base.html' %}
{% load i18n %}
{% block title %}{% trans "Mappings" %}{% endblock %}
{% block main %}
{{ table.render }}
{% endblock %}

View File

@ -40,7 +40,7 @@ class MappingsViewTests(test.BaseAdminViewTests):
res = self.client.get(MAPPINGS_INDEX_URL)
self.assertTemplateUsed(res, 'identity/mappings/index.html')
self.assertTemplateUsed(res, 'horizon/common/_data_table_view.html')
self.assertItemsEqual(res.context['table'].data,
self.idp_mappings.list())

View File

@ -35,7 +35,6 @@ from openstack_dashboard.dashboards.identity.mappings \
class IndexView(tables.DataTableView):
table_class = mapping_tables.MappingsTable
template_name = 'identity/mappings/index.html'
page_title = _("Mappings")
def get_data(self):

View File

@ -1,7 +0,0 @@
{% extends 'base.html' %}
{% load i18n %}
{% block title %}{% trans "Roles" %}{% endblock %}
{% block main %}
{{ table.render }}
{% endblock %}

View File

@ -25,6 +25,7 @@ from openstack_dashboard.test import helpers as test
ROLES_INDEX_URL = reverse('horizon:identity:roles:index')
ROLES_CREATE_URL = reverse('horizon:identity:roles:create')
ROLES_UPDATE_URL = reverse('horizon:identity:roles:update', args=[1])
INDEX_TEMPLATE = 'horizon/common/_data_table_view.html'
class RolesViewTests(test.BaseAdminViewTests):
@ -43,7 +44,7 @@ class RolesViewTests(test.BaseAdminViewTests):
self.assertContains(res, 'Edit')
self.assertContains(res, 'Delete Role')
self.assertTemplateUsed(res, 'identity/roles/index.html')
self.assertTemplateUsed(res, INDEX_TEMPLATE)
self.assertItemsEqual(res.context['table'].data, self.roles.list())
@test.create_stubs({api.keystone: ('role_list',
@ -64,7 +65,7 @@ class RolesViewTests(test.BaseAdminViewTests):
self.assertNotContains(res, 'Edit')
self.assertNotContains(res, 'Delete Role')
self.assertTemplateUsed(res, 'identity/roles/index.html')
self.assertTemplateUsed(res, INDEX_TEMPLATE)
self.assertItemsEqual(res.context['table'].data, self.roles.list())
@test.create_stubs({api.keystone: ('role_create', )})

View File

@ -33,7 +33,6 @@ from openstack_dashboard.dashboards.identity.roles \
class IndexView(tables.DataTableView):
table_class = project_tables.RolesTable
template_name = 'identity/roles/index.html'
page_title = _("Roles")
def get_data(self):

View File

@ -1,7 +0,0 @@
{% extends 'base.html' %}
{% load i18n %}
{% block title %}{% trans "Images" %}{% endblock %}
{% block main %}
{{ table.render }}
{% endblock %}

View File

@ -37,6 +37,7 @@ from openstack_dashboard.dashboards.project.images import utils
from openstack_dashboard.test import helpers as test
INDEX_TEMPLATE = 'horizon/common/_data_table_view.html'
INDEX_URL = reverse('horizon:project:images:index')
CREATE_URL = reverse('horizon:project:images:images:create')
@ -53,7 +54,7 @@ class ImagesAndSnapshotsTests(test.TestCase):
self.mox.ReplayAll()
res = self.client.get(INDEX_URL)
self.assertTemplateUsed(res, 'project/images/index.html')
self.assertTemplateUsed(res, INDEX_TEMPLATE)
self.assertContains(res, 'help_text="Deleted images'
' are not recoverable."')
self.assertIn('images_table', res.context)
@ -80,7 +81,7 @@ class ImagesAndSnapshotsTests(test.TestCase):
self.mox.ReplayAll()
res = self.client.get(INDEX_URL)
self.assertTemplateUsed(res, 'project/images/index.html')
self.assertTemplateUsed(res, INDEX_TEMPLATE)
self.assertContains(res, 'No items to display')
@test.create_stubs({api.glance: ('image_list_detailed',)})
@ -93,7 +94,7 @@ class ImagesAndSnapshotsTests(test.TestCase):
self.mox.ReplayAll()
res = self.client.get(INDEX_URL)
self.assertTemplateUsed(res, 'project/images/index.html')
self.assertTemplateUsed(res, INDEX_TEMPLATE)
@test.create_stubs({api.glance: ('image_list_detailed',)})
def test_snapshot_actions(self):
@ -106,7 +107,7 @@ class ImagesAndSnapshotsTests(test.TestCase):
self.mox.ReplayAll()
res = self.client.get(INDEX_URL)
self.assertTemplateUsed(res, 'project/images/index.html')
self.assertTemplateUsed(res, INDEX_TEMPLATE)
self.assertIn('images_table', res.context)
snaps = res.context['images_table']
self.assertEqual(len(snaps.get_rows()), 3)

View File

@ -36,7 +36,6 @@ from openstack_dashboard.dashboards.project.images.images \
class IndexView(tables.DataTableView):
table_class = images_tables.ImagesTable
template_name = 'project/images/index.html'
page_title = _("Images")
def has_prev_data(self, table):

View File

@ -1,7 +0,0 @@
{% extends 'base.html' %}
{% load i18n %}
{% block title %}{% trans "Instances" %}{% endblock %}
{% block main %}
{{ table.render }}
{% endblock %}

View File

@ -47,6 +47,7 @@ from openstack_dashboard.test import helpers
from openstack_dashboard.usage import quotas
INDEX_TEMPLATE = 'horizon/common/_data_table_view.html'
INDEX_URL = reverse('horizon:project:instances:index')
SEC_GROUP_ROLE_PREFIX = \
workflows.update_instance.INSTANCE_SEC_GROUP_SLUG + "_role_"
@ -157,8 +158,7 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
res = self._get_index()
self.assertTemplateUsed(res,
'project/instances/index.html')
self.assertTemplateUsed(res, INDEX_TEMPLATE)
instances = res.context['instances_table'].data
self.assertItemsEqual(instances, self.servers.list())
@ -185,7 +185,7 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
res = self.client.get(INDEX_URL)
self.assertTemplateUsed(res, 'project/instances/index.html')
self.assertTemplateUsed(res, INDEX_TEMPLATE)
self.assertEqual(len(res.context['instances_table'].data), 0)
self.assertMessageCount(res, error=1)
@ -228,7 +228,7 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
res = self.client.get(INDEX_URL)
self.assertTemplateUsed(res, 'project/instances/index.html')
self.assertTemplateUsed(res, INDEX_TEMPLATE)
instances = res.context['instances_table'].data
self.assertItemsEqual(instances, self.servers.list())
@ -272,7 +272,7 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
res = self.client.get(INDEX_URL)
self.assertTemplateUsed(res, 'project/instances/index.html')
self.assertTemplateUsed(res, INDEX_TEMPLATE)
instances = res.context['instances_table'].data
self.assertEqual(len(instances), len(servers))
self.assertContains(res, "(not found)")
@ -4314,7 +4314,7 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
self.mox.ReplayAll()
res = self.client.get(INDEX_URL)
self.assertTemplateUsed(res, 'project/instances/index.html')
self.assertTemplateUsed(res, INDEX_TEMPLATE)
# get first page with 2 items
self.assertEqual(len(res.context['instances_table'].data), page_size)

View File

@ -57,7 +57,6 @@ LOG = logging.getLogger(__name__)
class IndexView(tables.DataTableView):
table_class = project_tables.InstancesTable
template_name = 'project/instances/index.html'
page_title = _("Instances")
def has_more_data(self, table):

View File

@ -1,7 +0,0 @@
{% extends 'base.html' %}
{% load i18n %}
{% block title %}{% trans "Networks" %}{% endblock %}
{% block main %}
{{ table.render }}
{% endblock %}

View File

@ -30,6 +30,7 @@ from openstack_dashboard.test import helpers as test
from openstack_dashboard.usage import quotas
INDEX_TEMPLATE = 'horizon/common/_data_table_view.html'
INDEX_URL = reverse('horizon:project:networks:index')
@ -137,7 +138,7 @@ class NetworkTests(test.TestCase, NetworkStubMixin):
self.mox.ReplayAll()
res = self.client.get(INDEX_URL)
self.assertTemplateUsed(res, 'project/networks/index.html')
self.assertTemplateUsed(res, INDEX_TEMPLATE)
networks = res.context['networks_table'].data
self.assertItemsEqual(networks, self.networks.list())
@ -156,7 +157,7 @@ class NetworkTests(test.TestCase, NetworkStubMixin):
res = self.client.get(INDEX_URL)
self.assertTemplateUsed(res, 'project/networks/index.html')
self.assertTemplateUsed(res, INDEX_TEMPLATE)
self.assertEqual(len(res.context['networks_table'].data), 0)
self.assertMessageCount(res, error=1)
@ -1212,7 +1213,7 @@ class NetworkViewTests(test.TestCase, NetworkStubMixin):
self.mox.ReplayAll()
res = self.client.get(INDEX_URL)
self.assertTemplateUsed(res, 'project/networks/index.html')
self.assertTemplateUsed(res, INDEX_TEMPLATE)
networks = res.context['networks_table'].data
self.assertItemsEqual(networks, self.networks.list())
@ -1238,7 +1239,7 @@ class NetworkViewTests(test.TestCase, NetworkStubMixin):
self.mox.ReplayAll()
res = self.client.get(INDEX_URL)
self.assertTemplateUsed(res, 'project/networks/index.html')
self.assertTemplateUsed(res, INDEX_TEMPLATE)
networks = res.context['networks_table'].data
self.assertItemsEqual(networks, self.networks.list())

View File

@ -42,7 +42,6 @@ from openstack_dashboard.dashboards.project.networks \
class IndexView(tables.DataTableView):
table_class = project_tables.NetworksTable
template_name = 'project/networks/index.html'
page_title = _("Networks")
FILTERS_MAPPING = {'shared': {_("yes"): True, _("no"): False},
'router:external': {_("yes"): True, _("no"): False},

View File

@ -1,7 +0,0 @@
{% extends 'base.html' %}
{% load i18n %}
{% block title %}{% trans "Routers" %}{% endblock %}
{% block main %}
{{ table.render }}
{% endblock %}

View File

@ -25,6 +25,8 @@ from openstack_dashboard import api
from openstack_dashboard.test import helpers as test
from openstack_dashboard.usage import quotas
INDEX_TEMPLATE = 'horizon/common/_data_table_view.html'
class RouterMixin(object):
@test.create_stubs({
@ -98,7 +100,7 @@ class RouterTests(RouterMixin, test.TestCase):
res = self.client.get(self.INDEX_URL)
self.assertTemplateUsed(res, '%s/routers/index.html' % self.DASHBOARD)
self.assertTemplateUsed(res, INDEX_TEMPLATE)
routers = res.context['table'].data
self.assertItemsEqual(routers, self.routers.list())
@ -118,7 +120,7 @@ class RouterTests(RouterMixin, test.TestCase):
res = self.client.get(self.INDEX_URL)
self.assertTemplateUsed(res, '%s/routers/index.html' % self.DASHBOARD)
self.assertTemplateUsed(res, INDEX_TEMPLATE)
self.assertEqual(len(res.context['table'].data), 0)
self.assertMessageCount(res, error=1)
@ -142,7 +144,7 @@ class RouterTests(RouterMixin, test.TestCase):
self.assertEqual(len(table_data), 1)
self.assertIn('(Not Found)',
table_data[0]['external_gateway_info']['network'])
self.assertTemplateUsed(res, '%s/routers/index.html' % self.DASHBOARD)
self.assertTemplateUsed(res, INDEX_TEMPLATE)
self.assertMessageCount(res, error=1)
def test_router_detail(self):
@ -806,7 +808,7 @@ class RouterViewTests(RouterMixin, test.TestCase):
self.mox.ReplayAll()
res = self.client.get(self.INDEX_URL)
self.assertTemplateUsed(res, 'project/routers/index.html')
self.assertTemplateUsed(res, INDEX_TEMPLATE)
routers = res.context['routers_table'].data
self.assertItemsEqual(routers, self.routers.list())
@ -833,7 +835,7 @@ class RouterViewTests(RouterMixin, test.TestCase):
self.mox.ReplayAll()
res = self.client.get(self.INDEX_URL)
self.assertTemplateUsed(res, 'project/routers/index.html')
self.assertTemplateUsed(res, INDEX_TEMPLATE)
routers = res.context['routers_table'].data
self.assertItemsEqual(routers, self.routers.list())
@ -860,7 +862,7 @@ class RouterViewTests(RouterMixin, test.TestCase):
self.mox.ReplayAll()
res = self.client.get(self.INDEX_URL)
self.assertTemplateUsed(res, 'project/routers/index.html')
self.assertTemplateUsed(res, INDEX_TEMPLATE)
routers = res.context['routers_table'].data
self.assertItemsEqual(routers, self.routers.list())

View File

@ -42,7 +42,6 @@ from openstack_dashboard.dashboards.project.routers import tabs as rdtabs
class IndexView(tables.DataTableView):
table_class = rtables.RoutersTable
template_name = 'project/routers/index.html'
page_title = _("Routers")
FILTERS_MAPPING = {'admin_state_up': {_("up"): True, _("down"): False}}

View File

@ -1,7 +0,0 @@
{% extends 'base.html' %}
{% load i18n %}
{% block title %}{% trans "Resource Types" %}{% endblock %}
{% block main %}
{{ table.render }}
{% endblock %}

View File

@ -33,7 +33,7 @@ class ResourceTypesTests(test.TestCase):
res = self.client.get(
reverse('horizon:project:stacks.resource_types:index'))
self.assertTemplateUsed(
res, 'project/stacks.resource_types/index.html')
res, 'horizon/common/_data_table_view.html')
self.assertContains(res, 'AWS::CloudFormation::Stack')
@test.create_stubs({api.heat: ('resource_type_get',)})

View File

@ -29,7 +29,6 @@ import openstack_dashboard.dashboards.project.stacks.resource_types.tabs \
class ResourceTypesView(tables.DataTableView):
table_class = project_tables.ResourceTypesTable
template_name = 'project/stacks.resource_types/index.html'
page_title = _("Resource Types")
def get_data(self):

View File

@ -1,7 +0,0 @@
{% extends 'base.html' %}
{% load i18n %}
{% block title %}{% trans "Stacks" %}{% endblock %}
{% block main %}
{{ table.render }}
{% endblock %}

View File

@ -34,6 +34,7 @@ from openstack_dashboard.dashboards.project.stacks import mappings
from openstack_dashboard.dashboards.project.stacks import tables
INDEX_TEMPLATE = 'horizon/common/_data_table_view.html'
INDEX_URL = reverse('horizon:project:stacks:index')
DETAIL_URL = 'horizon:project:stacks:detail'
@ -153,7 +154,7 @@ class StackTests(test.TestCase):
# get all
self.assertEqual(len(res.context['stacks_table'].data),
len(stacks))
self.assertTemplateUsed(res, 'project/stacks/index.html')
self.assertTemplateUsed(res, INDEX_TEMPLATE)
res = self.client.get(url)
# get first page with 2 items
@ -212,7 +213,7 @@ class StackTests(test.TestCase):
# get all
self.assertEqual(len(res.context['stacks_table'].data),
len(stacks))
self.assertTemplateUsed(res, 'project/stacks/index.html')
self.assertTemplateUsed(res, INDEX_TEMPLATE)
res = self.client.get(url)
# get first page with 2 items

View File

@ -40,7 +40,6 @@ from openstack_dashboard.dashboards.project.stacks \
class IndexView(tables.DataTableView):
table_class = project_tables.StacksTable
template_name = 'project/stacks/index.html'
page_title = _("Stacks")
def __init__(self, *args, **kwargs):