From 5466981f962d1748ce5529aee222ba5875516975 Mon Sep 17 00:00:00 2001 From: Matt Westcott Date: Tue, 19 Jul 2022 15:23:47 +0100 Subject: [PATCH] rename show_locale_labels attribute to i18n_enabled It brings the whole locale filtering logic into play, so it's used for more than just showing labels or not --- wagtail/admin/views/chooser.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/wagtail/admin/views/chooser.py b/wagtail/admin/views/chooser.py index 1a17da21df..17ca916640 100644 --- a/wagtail/admin/views/chooser.py +++ b/wagtail/admin/views/chooser.py @@ -161,7 +161,7 @@ class BrowseView(View): def columns(self): return [ PageTitleColumn( - "title", label=_("Title"), show_locale_labels=self.show_locale_labels + "title", label=_("Title"), show_locale_labels=self.i18n_enabled ), DateColumn( "updated", @@ -182,7 +182,7 @@ class BrowseView(View): def get_object_list(self): # Get children of parent page (without streamfields) pages = self.parent_page.get_children().defer_streamfields().specific() - if self.show_locale_labels: + if self.i18n_enabled: pages = pages.select_related("locale") return pages @@ -203,7 +203,7 @@ class BrowseView(View): return pages def get(self, request, parent_page_id=None): - self.show_locale_labels = getattr(settings, "WAGTAIL_I18N_ENABLED", False) + self.i18n_enabled = getattr(settings, "WAGTAIL_I18N_ENABLED", False) # A missing or empty page_type parameter indicates 'all page types' # (i.e. descendants of wagtailcore.page) @@ -258,7 +258,7 @@ class BrowseView(View): selected_locale = None locale_options = [] - if self.show_locale_labels: + if self.i18n_enabled: if self.parent_page.is_root(): # 'locale' is the current value of the "Locale" selector in the UI if request.GET.get("locale"): @@ -359,7 +359,7 @@ class BrowseView(View): for desired_class in self.desired_classes ], "page_types_restricted": (page_type_string != "wagtailcore.page"), - "show_locale_labels": self.show_locale_labels, + "show_locale_labels": self.i18n_enabled, "locale_options": locale_options, "selected_locale": selected_locale, }, @@ -379,10 +379,10 @@ class SearchView(View): def columns(self): return [ PageTitleColumn( - "title", label=_("Title"), show_locale_labels=self.show_locale_labels + "title", label=_("Title"), show_locale_labels=self.i18n_enabled ), ParentPageColumn( - "parent", label=_("Parent"), show_locale_labels=self.show_locale_labels + "parent", label=_("Parent"), show_locale_labels=self.i18n_enabled ), DateColumn( "updated", @@ -400,7 +400,7 @@ class SearchView(View): ] def get(self, request): - self.show_locale_labels = getattr(settings, "WAGTAIL_I18N_ENABLED", False) + self.i18n_enabled = getattr(settings, "WAGTAIL_I18N_ENABLED", False) # A missing or empty page_type parameter indicates 'all page types' (i.e. descendants of wagtailcore.page) page_type_string = request.GET.get("page_type") or "wagtailcore.page" @@ -410,7 +410,7 @@ class SearchView(View): raise Http404 pages = Page.objects.all() - if self.show_locale_labels: + if self.i18n_enabled: pages = pages.select_related("locale") # allow hooks to modify the queryset @@ -448,7 +448,7 @@ class SearchView(View): "table": table, "pages": pages, "page_type_string": page_type_string, - "show_locale_labels": self.show_locale_labels, + "show_locale_labels": self.i18n_enabled, }, ), )