Enable pagination for Project->Images view
This feature is already implemented, but not enabled because it has strange behavior when the image list is filtered by removing aki and ari type of images. The pagination for images view should be enabled since the filtering image code was removed in: https://review.openstack.org/#/c/59935/ Because the ImagesTable is the only one being incorporated into the images view, there is no need to include table.name attribute into _prev and _more attributes of the view (no other tables to distinguish between). This is a refreshment of https://review.openstack.org/#/c/58928/ (which I cannot update because it's abandoned). Change-Id: Ib027a548ee8aa623f0faea86f0ad7570d6ec2360 Co-Authored-By: chenhaiq <chenhaiq@cn.ibm.com> Closes-Bug: #1252649
This commit is contained in:
parent
1d1b683f51
commit
0f7f17c62a
|
@ -41,8 +41,9 @@ class ImagesAndSnapshotsTests(test.TestCase):
|
|||
def test_index(self):
|
||||
images = self.images.list()
|
||||
api.glance.image_list_detailed(IsA(http.HttpRequest),
|
||||
marker=None).AndReturn([images,
|
||||
False, False])
|
||||
marker=None,
|
||||
paginate=True) \
|
||||
.AndReturn([images, False, False])
|
||||
self.mox.ReplayAll()
|
||||
|
||||
res = self.client.get(INDEX_URL)
|
||||
|
@ -66,8 +67,9 @@ class ImagesAndSnapshotsTests(test.TestCase):
|
|||
@test.create_stubs({api.glance: ('image_list_detailed',)})
|
||||
def test_index_no_images(self):
|
||||
api.glance.image_list_detailed(IsA(http.HttpRequest),
|
||||
marker=None).AndReturn([(),
|
||||
False, False])
|
||||
marker=None,
|
||||
paginate=True) \
|
||||
.AndReturn([(), False, False])
|
||||
self.mox.ReplayAll()
|
||||
|
||||
res = self.client.get(INDEX_URL)
|
||||
|
@ -76,7 +78,8 @@ class ImagesAndSnapshotsTests(test.TestCase):
|
|||
@test.create_stubs({api.glance: ('image_list_detailed',)})
|
||||
def test_index_error(self):
|
||||
api.glance.image_list_detailed(IsA(http.HttpRequest),
|
||||
marker=None) \
|
||||
marker=None,
|
||||
paginate=True) \
|
||||
.AndRaise(self.exceptions.glance)
|
||||
self.mox.ReplayAll()
|
||||
|
||||
|
@ -86,7 +89,9 @@ class ImagesAndSnapshotsTests(test.TestCase):
|
|||
@test.create_stubs({api.glance: ('image_list_detailed',)})
|
||||
def test_snapshot_actions(self):
|
||||
snapshots = self.snapshots.list()
|
||||
api.glance.image_list_detailed(IsA(http.HttpRequest), marker=None) \
|
||||
api.glance.image_list_detailed(IsA(http.HttpRequest),
|
||||
marker=None,
|
||||
paginate=True) \
|
||||
.AndReturn([snapshots, False, False])
|
||||
self.mox.ReplayAll()
|
||||
|
||||
|
|
|
@ -38,18 +38,19 @@ class IndexView(tables.DataTableView):
|
|||
page_title = _("Images")
|
||||
|
||||
def has_prev_data(self, table):
|
||||
return getattr(self, "_prev_%s" % table.name, False)
|
||||
return getattr(self, "_prev", False)
|
||||
|
||||
def has_more_data(self, table):
|
||||
return getattr(self, "_more_%s" % table.name, False)
|
||||
return getattr(self, "_more", False)
|
||||
|
||||
def get_data(self):
|
||||
marker = self.request.GET.get(
|
||||
images_tables.ImagesTable._meta.pagination_param, None)
|
||||
try:
|
||||
(images, self._more, self._prev) = api.glance.image_list_detailed(
|
||||
self.request, marker=marker)
|
||||
|
||||
self.request,
|
||||
marker=marker,
|
||||
paginate=True)
|
||||
except Exception:
|
||||
images = []
|
||||
exceptions.handle(self.request, _("Unable to retrieve images."))
|
||||
|
|
|
@ -1234,8 +1234,9 @@ class InstanceTests(helpers.TestCase):
|
|||
"snapshot1").AndReturn(self.snapshots.first())
|
||||
|
||||
api.glance.image_list_detailed(IsA(http.HttpRequest),
|
||||
marker=None).AndReturn([[], False,
|
||||
False])
|
||||
marker=None,
|
||||
paginate=True) \
|
||||
.AndReturn([[], False, False])
|
||||
|
||||
self.mox.ReplayAll()
|
||||
|
||||
|
|
Loading…
Reference in New Issue