diff --git a/shop/cascade/navbar_shop.py b/shop/cascade/navbar_shop.py new file mode 100644 index 000000000..9b68f6ccf --- /dev/null +++ b/shop/cascade/navbar_shop.py @@ -0,0 +1,81 @@ +from django.utils.translation import ugettext_lazy as _, ugettext +from entangled.forms import EntangledModelFormMixin +from cms.plugin_pool import plugin_pool +from cmsplugin_cascade.mixins import WithSortableInlineElementsMixin +from shop.cascade.plugin_base import ShopPluginBase +from django.utils.html import format_html + +@plugin_pool.register_plugin +class ShopNavbarLoginLogout(ShopPluginBase): + name = _("Nav Login-Logout") + require_parent = True + parent_classes = ['BootstrapListsPlugin'] + cache = False + render_template = 'shop/navbar/login-logout.html' + + @classmethod + def get_identifier(cls, obj): + identifier = super().get_identifier(obj) + if hasattr(cls,'default_css_class'): + css_classes_without_default = obj.css_classes.replace( cls.default_css_class , '' , 1) + else: + css_classes_without_default = obj.css_classes + return format_html('
{0}{1}
', + identifier, css_classes_without_default ) + +@plugin_pool.register_plugin +class ShopNavbarWatchList(ShopPluginBase): + name = _("Nav WatchList") + require_parent = True + parent_classes = ['BootstrapListsPlugin'] + cache = False + render_template = 'shop/navbar/watch-icon.html' + + @classmethod + def get_identifier(cls, obj): + identifier = super().get_identifier(obj) + if hasattr(cls,'default_css_class'): + css_classes_without_default = obj.css_classes.replace( cls.default_css_class , '' , 1) + else: + css_classes_without_default = obj.css_classes + return format_html('
{0}{1}
', + identifier, css_classes_without_default ) + + +@plugin_pool.register_plugin +class ShopNavbarCart(ShopPluginBase): + name = _("Nav Cart Caddy") + require_parent = True + parent_classes = ['BootstrapListsPlugin'] + cache = False + render_template = 'shop/navbar/cart-caddy.html' + + @classmethod + def get_identifier(cls, obj): + identifier = super().get_identifier(obj) + if hasattr(cls,'default_css_class'): + css_classes_without_default = obj.css_classes.replace( cls.default_css_class , '' , 1) + else: + css_classes_without_default = obj.css_classes + return format_html('
{0}{1}
', + identifier, css_classes_without_default ) + + +@plugin_pool.register_plugin +class ShopNavbarSearchForm(ShopPluginBase): + name = _("Nav Search Form") + require_parent = True + parent_classes = ['BootstrapListsPlugin'] + cache = False + render_template = 'shop/navbar/search-form.html' + + + @classmethod + def get_identifier(cls, obj): + identifier = super().get_identifier(obj) + if hasattr(cls,'default_css_class'): + css_classes_without_default = obj.css_classes.replace( cls.default_css_class , '' , 1) + else: + css_classes_without_default = obj.css_classes + return format_html('
{0}{1}
', + identifier, css_classes_without_default ) diff --git a/shop/cascade/settings.py b/shop/cascade/settings.py index 54a8f2da0..381bf28cd 100644 --- a/shop/cascade/settings.py +++ b/shop/cascade/settings.py @@ -1,10 +1,12 @@ from django.conf import settings from django.utils.translation import gettext_lazy as _ +from cmsplugin_cascade.extra_fields.config import PluginExtraFieldsConfig + from cmsplugin_cascade.bootstrap4.mixins import BootstrapUtilities CASCADE_PLUGINS = getattr(settings, 'SHOP_CASCADE_PLUGINS', - ['auth', 'breadcrumb', 'catalog', 'cart', 'checkout', 'extensions', 'order', 'processbar', 'search'] + ['auth', 'breadcrumb', 'catalog', 'cart', 'checkout', 'extensions', 'order', 'processbar', 'search', 'navbar_shop'] ) @@ -32,6 +34,34 @@ def set_defaults(config): config['plugins_with_extra_mixins'].setdefault('BootstrapButtonPlugin', BootstrapUtilities( BootstrapUtilities.floats, )) + + config['plugins_with_extra_mixins'].setdefault('ShopNavbarSearchForm', BootstrapUtilities( + BootstrapUtilities.margins, + )) + config['plugins_with_extra_fields'].setdefault('ShopNavbarSearchForm', PluginExtraFieldsConfig( + css_classes={ + 'multiple': True, + 'class_names': ['shop-search-form'], + }, + )) + config['plugins_with_extra_fields'].setdefault('ShopNavbarCart', PluginExtraFieldsConfig( + css_classes={ + 'multiple': True, + 'class_names': ['shop-secondary-menu'], + }, + )) + config['plugins_with_extra_fields'].setdefault('BootstrapNavBrandPlugin', PluginExtraFieldsConfig( + css_classes={ + 'multiple': True, + 'class_names': ['shop-brand-icon'], + }, + )) + config['plugins_with_extra_fields'].setdefault('BootstrapNavItemsMainMenuPlugin', PluginExtraFieldsConfig( + css_classes={ + 'multiple': True, + 'class_names': ['shop-primary-menu'], + }, + )) config['plugins_with_extra_render_templates'].setdefault('BootstrapButtonPlugin', [ ('shop/button.html', _("Responsive Feedback")), ('cascade/bootstrap4/button.html', _("Default")), diff --git a/shop/templates/shop/navbar/cart-caddy.html b/shop/templates/shop/navbar/cart-caddy.html new file mode 100644 index 000000000..95d111a48 --- /dev/null +++ b/shop/templates/shop/navbar/cart-caddy.html @@ -0,0 +1,11 @@ +{% load static i18n cms_tags menu_tags sekizai_tags sass_tags shop_tags %} +{% spaceless %} +{% with item_class=instance.css_classes %} + {% if current_page.reverse_id == 'shop-cart' or current_page.reverse_id == 'shop-watch-list' %} + {% cart_icon without %} + {% else %} + {% cart_icon unsorted %} + {% endif %} +{% endwith %} +{% endspaceless %} + diff --git a/shop/templates/shop/navbar/search-form.html b/shop/templates/shop/navbar/search-form.html index c89403a09..4f7fae0ab 100644 --- a/shop/templates/shop/navbar/search-form.html +++ b/shop/templates/shop/navbar/search-form.html @@ -7,7 +7,8 @@ {% addtoblock "js" %}{% endaddtoblock %} {% add_data "ng-requires" "django.shop.search" %} - - + {% endif %} {% endspaceless %}