From 9faf1cd109c2af47e587237e0f01a9e052039e23 Mon Sep 17 00:00:00 2001 From: Wangliangyu Date: Wed, 21 Nov 2018 18:19:21 +0800 Subject: [PATCH] Fix bug about snapshot pagination Now, one page content will be changed after Clicking "Next page" or "Prev page" to go back. As we know, the order of the list could not be changed at will, for one at the beginning or the end is a marker. The marker is very importent for pagination. So, this commit remove the sort of snapshots and reverse the sort of the previous page ones. Change-Id: I8d3d0cf4a1e6526bed3055b18741b1cf5d6166ff Closes-Bug: #1804391 --- openstack_dashboard/api/cinder.py | 3 +++ openstack_dashboard/dashboards/admin/snapshots/views.py | 3 +-- openstack_dashboard/dashboards/project/volumes/views.py | 4 ---- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/openstack_dashboard/api/cinder.py b/openstack_dashboard/api/cinder.py index 6270035efa..215fcd13e7 100644 --- a/openstack_dashboard/api/cinder.py +++ b/openstack_dashboard/api/cinder.py @@ -296,6 +296,9 @@ def update_pagination(entities, page_size, marker, sort_dir): elif marker is not None: has_prev_data = True + if sort_dir == 'asc': + entities.reverse() + return entities, has_more_data, has_prev_data diff --git a/openstack_dashboard/dashboards/admin/snapshots/views.py b/openstack_dashboard/dashboards/admin/snapshots/views.py index 3b9ac4d9ed..75afb30ce8 100644 --- a/openstack_dashboard/dashboards/admin/snapshots/views.py +++ b/openstack_dashboard/dashboards/admin/snapshots/views.py @@ -75,8 +75,7 @@ class SnapshotsView(tables.PagedTableMixin, tables.DataTableView): else: snapshots = [] - return sorted(snapshots, - key=lambda snapshot: snapshot.tenant_name or '') + return snapshots class UpdateStatusView(forms.ModalFormView): diff --git a/openstack_dashboard/dashboards/project/volumes/views.py b/openstack_dashboard/dashboards/project/volumes/views.py index 6e68dde1b8..17afcb113a 100644 --- a/openstack_dashboard/dashboards/project/volumes/views.py +++ b/openstack_dashboard/dashboards/project/volumes/views.py @@ -62,10 +62,6 @@ class VolumeTableMixIn(object): cinder.volume_list_paged(self.request, marker=marker, search_opts=search_opts, sort_dir=sort_dir, paginate=True) - - if sort_dir == "asc": - volumes.reverse() - return volumes except Exception: exceptions.handle(self.request,