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

Navbar shop #798

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
81 changes: 81 additions & 0 deletions shop/cascade/navbar_shop.py
Original file line number Diff line number Diff line change
@@ -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('<div style="font-size: smaller; white-space: pre-wrap;" >{0}{1}</div>',
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('<div style="font-size: smaller; white-space: pre-wrap;" >{0}{1}</div>',
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('<div style="font-size: smaller; white-space: pre-wrap;" >{0}{1}</div>',
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('<div style="font-size: smaller; white-space: pre-wrap;" >{0}{1}</div>',
identifier, css_classes_without_default )
32 changes: 31 additions & 1 deletion shop/cascade/settings.py
Original file line number Diff line number Diff line change
@@ -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']
)


Expand Down Expand Up @@ -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")),
Expand Down
11 changes: 11 additions & 0 deletions shop/templates/shop/navbar/cart-caddy.html
Original file line number Diff line number Diff line change
@@ -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 %}

5 changes: 3 additions & 2 deletions shop/templates/shop/navbar/search-form.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
{% addtoblock "js" %}<script src="{% static 'shop/js/search-form.js' %}" type="text/javascript"></script>{% endaddtoblock %}
{% add_data "ng-requires" "django.shop.search" %}

<form shop-product-search class="{{ search_form_classes }}" role="search" method="get"{% if search_product_url %} action="{{ search_product_url }}"{% endif %}>
<li class="nav-item shop-search-form">
<form {% if instance_css_classes %} class="{{ search_form_classes }} {{ instance.css_classes }}"{% endif %}{% if instance_inline_styles %} style="{{ instance.inline_styles }}"{% endif %} shop-product-search class="{{ search_form_classes }}" role="search" method="get"{% if search_product_url %} action="{{ search_product_url }}"{% endif %}>
{% if search_product_url %}
<div class="input-group w-100">
{% endif %}
Expand All @@ -19,6 +20,6 @@
</div>
{% endif %}
</form>

</li>
{% endif %}
{% endspaceless %}