From b1a9cd6175ff3fa172349add44dbebe6e60d18ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Bedna=C5=99=C3=ADk?= <jan.bednarik@gmail.com> Date: Thu, 7 Apr 2022 15:47:59 +0200 Subject: [PATCH] majak: Explorer menu sort --- elections2021/models.py | 4 +--- majak/settings/base.py | 1 + tuning/wagtail_hooks.py | 9 ++++++++- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/elections2021/models.py b/elections2021/models.py index 990d730e..cb5c5b01 100644 --- a/elections2021/models.py +++ b/elections2021/models.py @@ -1593,9 +1593,7 @@ class BenefitBlock(blocks.StructBlock): template = "elections2021/_benefit_block.html" -class Elections2021ProgramPointPage( - SubpageMixin, MetadataPageMixin, Page, index.Indexed -): +class Elections2021ProgramPointPage(SubpageMixin, MetadataPageMixin, Page): ### FIELDS annotation = RichTextField( diff --git a/majak/settings/base.py b/majak/settings/base.py index f4085016..963e6153 100644 --- a/majak/settings/base.py +++ b/majak/settings/base.py @@ -77,6 +77,7 @@ INSTALLED_APPS = [ "django.contrib.messages", "django.contrib.staticfiles", "django.contrib.humanize", + "django.contrib.postgres", ] # AUTHENTICATION diff --git a/tuning/wagtail_hooks.py b/tuning/wagtail_hooks.py index c33d9bb0..8f148360 100644 --- a/tuning/wagtail_hooks.py +++ b/tuning/wagtail_hooks.py @@ -1,3 +1,5 @@ +from django.contrib.postgres.lookups import Unaccent +from django.db.models.functions import Lower from django.utils.safestring import mark_safe from wagtail.core import hooks @@ -5,7 +7,7 @@ from wagtail.core import hooks class HelpPanel: order = 1000 - def render(self): + def render_html(self, parent_context): return mark_safe( """ <section class="nice-padding"> @@ -20,3 +22,8 @@ class HelpPanel: @hooks.register("construct_homepage_panels") def add_another_welcome_panel(request, panels): panels.append(HelpPanel()) + + +@hooks.register("construct_explorer_page_queryset") +def show_my_profile_only(parent_page, pages, request): + return pages.order_by(Unaccent(Lower("title"))) -- GitLab