From d18ccfac2326be4e9c17e9d670cb0b84a2cce91d Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Thu, 7 Oct 2021 13:13:11 +0200 Subject: [PATCH 1/3] Sort aliases by normalized name in profile alias view Signed-off-by: Yohann D'ANELLO --- apps/member/views.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/member/views.py b/apps/member/views.py index 39edcc0b..fac8bfc6 100644 --- a/apps/member/views.py +++ b/apps/member/views.py @@ -256,7 +256,8 @@ class ProfileAliasView(ProtectQuerysetMixin, LoginRequiredMixin, DetailView): context = super().get_context_data(**kwargs) note = context['object'].note context["aliases"] = AliasTable( - note.alias.filter(PermissionBackend.filter_queryset(self.request, Alias, "view")).distinct().all()) + note.alias.filter(PermissionBackend.filter_queryset(self.request, Alias, "view")).distinct() + .order_by('normalized_name').all()) context["can_create"] = PermissionBackend.check_perm(self.request, "note.add_alias", Alias( note=context["object"].note, name="", From 7848cd9cc2704d9257bc41fdb0b143918e009c19 Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Thu, 7 Oct 2021 13:15:52 +0200 Subject: [PATCH 2/3] Don't search buttons by prefix Signed-off-by: Yohann D'ANELLO --- apps/note/views.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/note/views.py b/apps/note/views.py index 074da01d..1224f2f8 100644 --- a/apps/note/views.py +++ b/apps/note/views.py @@ -90,9 +90,9 @@ class TransactionTemplateListView(ProtectQuerysetMixin, LoginRequiredMixin, Sing if "search" in self.request.GET: pattern = self.request.GET["search"] qs = qs.filter( - Q(name__iregex="^" + pattern) - | Q(destination__club__name__iregex="^" + pattern) - | Q(category__name__iregex="^" + pattern) + Q(name__iregex=pattern) + | Q(destination__club__name__iregex=pattern) + | Q(category__name__iregex=pattern) | Q(description__iregex=pattern) ) From 58cafad032df0831ed37c88d04f7fc4dc4a1d3b2 Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Thu, 7 Oct 2021 13:36:26 +0200 Subject: [PATCH 3/3] Sort buttons by category name instead of id in button list Signed-off-by: Yohann D'ANELLO --- apps/note/tables.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/apps/note/tables.py b/apps/note/tables.py index 188683dd..1efd5c38 100644 --- a/apps/note/tables.py +++ b/apps/note/tables.py @@ -215,6 +215,9 @@ class ButtonTable(tables.Table): def render_amount(self, value): return pretty_money(value) + def order_category(self, queryset, is_descending): + return queryset.order_by(f"{'-' if is_descending else ''}category__name"), True + def render_hideshow(self, record): val = '