From e6b16d332a3960f2a2be98a895571710907f23be Mon Sep 17 00:00:00 2001 From: Emiliano Beronich Date: Tue, 28 Jun 2022 12:47:14 -0300 Subject: [PATCH 1/2] Replace ugettext_lazy by gettext_lazy, ugettext by gettext, ungettext by ngettext. --- shuup_megastore_theme/theme.py | 37 +++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/shuup_megastore_theme/theme.py b/shuup_megastore_theme/theme.py index a3ce121..c4e7160 100644 --- a/shuup_megastore_theme/theme.py +++ b/shuup_megastore_theme/theme.py @@ -11,7 +11,7 @@ from django import forms from django.conf import settings from django.utils.encoding import force_text -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from shuup.core import cache from shuup.front.themes import BaseThemeFieldsMixin @@ -26,33 +26,45 @@ class ShuupMegastoreTheme(BaseThemeFieldsMixin, Theme): template_dir = "shuup_megastore_theme/" _theme_fields = [ - ("group_items_by_supplier", forms.BooleanField( - required=False, initial=False, - label=_("Group items by supplier"), - help_text=_("Group items by the supplier in basket and order") - )) + ( + "group_items_by_supplier", + forms.BooleanField( + required=False, + initial=False, + label=_("Group items by supplier"), + help_text=_("Group items by the supplier in basket and order"), + ), + ) ] @property def fields(self): fields = self._theme_fields + super(ShuupMegastoreTheme, self).get_base_fields() if has_installed("shuup_product_reviews"): - fields.extend([ - ("show_product_review", forms.BooleanField( - required=False, initial=True, - label=_("Show product reviews rating in product card.") - )) - ]) + fields.extend( + [ + ( + "show_product_review", + forms.BooleanField( + required=False, + initial=True, + label=_("Show product reviews rating in product card."), + ), + ) + ] + ) return fields def get_view(self, view_name): import shuup_megastore_theme.views as views + return getattr(views, view_name, None) def _format_cms_links(self, **query_kwargs): if "shuup.simple_cms" not in settings.INSTALLED_APPS: return from shuup.simple_cms.models import Page + for page in Page.objects.visible().filter(**query_kwargs): yield {"url": "/%s" % page.url, "text": force_text(page)} @@ -70,6 +82,7 @@ def render_product_review_rating(self, product): return cached_rating from shuup_product_reviews.utils import render_product_review_ratings + rendered = render_product_review_ratings(product) if rendered: From 31cee137367877ffe8215c05ea0d9eebcfdf9238 Mon Sep 17 00:00:00 2001 From: Emiliano Beronich Date: Tue, 28 Jun 2022 13:25:59 -0300 Subject: [PATCH 2/2] Replace smart_text by smart_str, force_text by force_str. --- shuup_megastore_theme/theme.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/shuup_megastore_theme/theme.py b/shuup_megastore_theme/theme.py index c4e7160..d3ccb17 100644 --- a/shuup_megastore_theme/theme.py +++ b/shuup_megastore_theme/theme.py @@ -10,7 +10,7 @@ from django import forms from django.conf import settings -from django.utils.encoding import force_text +from django.utils.encoding import force_str from django.utils.translation import gettext_lazy as _ from shuup.core import cache @@ -66,7 +66,7 @@ def _format_cms_links(self, **query_kwargs): from shuup.simple_cms.models import Page for page in Page.objects.visible().filter(**query_kwargs): - yield {"url": "/%s" % page.url, "text": force_text(page)} + yield {"url": "/%s" % page.url, "text": force_str(page)} def get_cms_navigation_links(self): return self._format_cms_links(visible_in_menu=True)