From 76c18c0cae926cd616ac93e6ad3805b23f8d5a42 Mon Sep 17 00:00:00 2001 From: Santiago Lamora Date: Fri, 26 Jan 2024 13:51:08 +0100 Subject: [PATCH] Set order_by on AddressListView Avoid pagination inconsistency --- orchestra/contrib/musician/urls.py | 2 +- orchestra/contrib/musician/views.py | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/orchestra/contrib/musician/urls.py b/orchestra/contrib/musician/urls.py index 0114719e..50ea0161 100644 --- a/orchestra/contrib/musician/urls.py +++ b/orchestra/contrib/musician/urls.py @@ -27,7 +27,7 @@ urlpatterns = [ path('bills//download/', views.BillDownloadView.as_view(), name='bill-download'), path('profile/', views.ProfileView.as_view(), name='profile'), path('profile/setLang/', views.profile_set_language, name='profile-set-lang'), - path('address/', views.MailView.as_view(), name='address-list'), + path('address/', views.AddressListView.as_view(), name='address-list'), path('address/new/', views.MailCreateView.as_view(), name='address-create'), path('address//', views.MailUpdateView.as_view(), name='address-update'), path('address//delete/', views.AddressDeleteView.as_view(), name='address-delete'), diff --git a/orchestra/contrib/musician/views.py b/orchestra/contrib/musician/views.py index b15fa2a3..a89fd0fb 100644 --- a/orchestra/contrib/musician/views.py +++ b/orchestra/contrib/musician/views.py @@ -240,7 +240,7 @@ class BillDownloadView(CustomContextMixin, UserTokenRequiredMixin, View): return HttpResponse(bill.html or bill.render()) -class MailView(ServiceListView): +class AddressListView(ServiceListView): service_class = AddressService model = Address template_name = "musician/addresses.html" @@ -249,6 +249,11 @@ class MailView(ServiceListView): 'title': _('Mail addresses'), } + def get_queryset(self): + qs = super().get_queryset() + qs = qs.order_by("domain", "name") + return qs + def get_queryfilter(self): """Retrieve query params (if any) to filter queryset""" domain_id = self.request.GET.get('domain')