Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Django3 #57

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 27 additions & 14 deletions shuup_megastore_theme/theme.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@

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.encoding import force_str
from django.utils.translation import gettext_lazy as _

from shuup.core import cache
from shuup.front.themes import BaseThemeFieldsMixin
Expand All @@ -26,35 +26,47 @@ 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)}
yield {"url": "/%s" % page.url, "text": force_str(page)}

def get_cms_navigation_links(self):
return self._format_cms_links(visible_in_menu=True)
Expand All @@ -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:
Expand Down