def _create_sample_carousel(cls, shop, business_segment): """ Create the sample carousel for the given business_segment and also injects it to the default theme currently being used in front """ if business_segment not in BUSINESS_SEGMENTS: return None carousel_data = BUSINESS_SEGMENTS[business_segment]["carousel"] carousel = create_sample_carousel(carousel_data, business_segment, shop) # injects the carousel plugin with in the front_content placeholder # this will only works if the theme have this placeholder, we expect so if 'shuup.xtheme' in settings.INSTALLED_APPS: from shuup.front.apps.carousel.plugins import CarouselPlugin from shuup.xtheme.plugins.products import ProductHighlightPlugin from shuup.xtheme.models import SavedViewConfig, SavedViewConfigStatus from shuup.xtheme.layout import Layout from shuup.xtheme._theme import get_current_theme theme = get_current_theme(shop) if theme: layout = Layout(theme, "front_content") # adds the carousel layout.begin_row() layout.begin_column({"md": 12}) layout.add_plugin(CarouselPlugin.identifier, {"carousel": carousel.pk}) # adds some products layout.begin_row() layout.begin_column({"md": 12}) layout.add_plugin(ProductHighlightPlugin.identifier, {}) svc = SavedViewConfig( theme_identifier=theme.identifier, shop=shop, view_name="IndexView", status=SavedViewConfigStatus.CURRENT_DRAFT) svc.set_layout_data(layout.placeholder_name, layout) svc.save() svc.publish() return carousel
def _create_sample_carousel(cls, shop, business_segment): """ Create the sample carousel for the given business_segment and also injects it to the default theme currently being used in front """ if business_segment not in BUSINESS_SEGMENTS: return None carousel_data = BUSINESS_SEGMENTS[business_segment]["carousel"] carousel = create_sample_carousel(carousel_data, business_segment, shop) # injects the carousel plugin with in the front_content placeholder # this will only works if the theme have this placeholder, we expect so if 'shuup.xtheme' in settings.INSTALLED_APPS: from shuup.front.apps.carousel.plugins import CarouselPlugin from shuup.xtheme.plugins.products import ProductHighlightPlugin from shuup.xtheme.models import SavedViewConfig, SavedViewConfigStatus from shuup.xtheme.layout import Layout from shuup.xtheme._theme import get_current_theme theme = get_current_theme(shop) if theme: layout = Layout(theme, "front_content") # adds the carousel layout.begin_row() layout.begin_column({"md": 12}) layout.add_plugin(CarouselPlugin.identifier, {"carousel": carousel.pk}) # adds some products layout.begin_row() layout.begin_column({"md": 12}) layout.add_plugin(ProductHighlightPlugin.identifier, {}) svc = SavedViewConfig( theme_identifier=theme.identifier, shop=shop, view_name="IndexView", status=SavedViewConfigStatus.CURRENT_DRAFT ) svc.set_layout_data(layout.placeholder_name, layout) svc.save() svc.publish() return carousel