Skip to content

Commit

Permalink
Merge pull request #375 from gautampanday/task-7815
Browse files Browse the repository at this point in the history
Added items of home page from CMS root menu #7815
  • Loading branch information
tarunbhardwaj committed May 25, 2015
2 parents 664c341 + 2979c4b commit 35309e5
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 45 deletions.
4 changes: 1 addition & 3 deletions static/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -1308,9 +1308,7 @@ span.text-success, span.text-warning, span.text-danger, span.text-info{
cursor: pointer;
color: #C34848;
}
#featured-node img{
height: 360px;
}

.reset_password{
padding-top: 50px;
}
Expand Down
66 changes: 24 additions & 42 deletions templates/webshop/home.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -59,54 +59,36 @@

<section class="products latest">
<div class="container">
{% set featured_products = request.nereid_website.featured_products_node and request.nereid_website.featured_products_node.get_products(per_page=3) %}
{% if featured_products %}
<div class="row" id="featured-node">
<h3>Featured Products</h3>
<br>
{% for product in featured_products %}
<a href="{{ url_for('product.product.render', uri=product.uri) }}" ga-product-link data-ga-product-list="Featured Products" data-ga-event-label="Product Name" data-ga-product-id="{{ product.id }}" data-ga-product-name="{{ product.name }}" data-ga-product-category="{{ product.category and product.category.name or None }}">
<div class="col-md-4 thumb">
<img class="img img-responsive margin-auto"
src="{{ CDN }}{{ product.default_image.transform_command().thumbnail(400, 400, 'a') }}"
alt="{{ product.name }}" title="{{ product.name }}"/>
<div class="fig-caption text-center">
<h4>{{ product.name }}</h4>
{% set homepage_menus = request.nereid_website.homepage_menu and request.nereid_website.homepage_menu.get_menu_item(max_depth=3).children %}
{% for child_menu in homepage_menus %}
<div class="row section-spaces">
<h3 class="text-center mrt-0">{{ child_menu.title }}</h3>
<br>
<div class="col-md-12 product-data">
<div class="client-slider">
{% for child in child_menu.children %}
<div class="slide">
<a href="{{ child.link }}">
<img class="img img-responsive margin-auto"
src="{{ CDN + url_for('nereid.webshop.send_static_file', filename='images/no-image.jpg') }}"
alt="{{ child.title }}" title="{{ child.title }}">
</a>
</div>
{% endfor %}
</div>
</a>
{% endfor %}
</div>
<div class="bx-controls-direction">
<a class="bx-prev" href="#"></a>
<a class="bx-next" href="#"></a>
</div>
</div>
</div>
{% endfor %}
<br>
{% endif %}
</div>
</section>
<div class="container">
<hr class="margin-0">
</div>
{% if latest_products %}
<section class="section-spaces">
<div class="container">
<h3 class="text-center mrt-0">Most Popular Item</h3>
<br>
<div class="col-md-12 product-data">
<div class="client-slider">
{% for product in latest_products %}
<div class="slide">
<a href="{{ url_for('product.product.render', uri=product.uri) }}" ga-product-link data-ga-product-list="Most Popular Item" data-ga-event-label="Product Name" data-ga-product-id="{{ product.id }}" data-ga-product-name="{{ product.name }}" data-ga-product-category="{{ product.category and product.category.name or None }}">
<img src="{{ CDN }}{{ product.default_image.transform_command().thumbnail(150, 150, 'a') }}" alt="{{ product.name }}" title="{{ product.name }}" class="img-responsive img-rounded">
</a>
</div>
{% endfor %}
</div>
<div class="bx-controls-direction">
<a class="bx-prev" href="#"></a>
<a class="bx-next" href="#"></a>
</div>
</div>
</div>
</section>
{% endif %}
<section>
<div class="container">
<div class="col-md-12 shop-assurance">
Expand Down Expand Up @@ -170,9 +152,9 @@ $(document).ready(function() {
});
$('.client-slider').bxSlider({
slideWidth: 180,
slideWidth: 230,
minSlides: 2,
maxSlides: 5,
maxSlides: 4,
slideMargin: 10,
infiniteLoop: true,
pager:false,
Expand Down
6 changes: 6 additions & 0 deletions tests/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ def setUp(self):
self.ProductNodeRelationship = POOL.get(
'product.product-product.tree_node'
)
self.MenuItem = POOL.get('nereid.cms.menuitem')
self.templates = {
'shopping-cart.jinja':
'Cart:{{ cart.id }},{{get_cart_size()|round|int}},'
Expand Down Expand Up @@ -495,6 +496,10 @@ def setup_defaults(self):
'name': 'root',
'slug': 'root',
}])
self.default_menuitem, = self.MenuItem.create([{
'type_': 'view',
'title': 'Test Title'
}])
self.NereidWebsite.create([{
'name': 'localhost',
'channel': self.channel,
Expand All @@ -504,6 +509,7 @@ def setup_defaults(self):
'guest_user': self.guest_user,
'countries': [('add', self.available_countries)],
'currencies': [('add', [self.usd.id])],
'homepage_menu': self.default_menuitem.id,
}])

# Create an article category
Expand Down
2 changes: 2 additions & 0 deletions view/website_form.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
<field name="cms_root_menu" />
<label name="cms_root_footer" />
<field name="cms_root_footer" />
<label name="homepage_menu" />
<field name="homepage_menu" />
</xpath>
<xpath
expr="/form/notebook/page[@id='general']/field[@name='cms_static_folder']"
Expand Down
5 changes: 5 additions & 0 deletions webshop.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,11 @@ class Website:
select=True,
)

homepage_menu = fields.Many2One(
'nereid.cms.menuitem', "Homepage Menu", ondelete='RESTRICT',
select=True,
)

@classmethod
@route('/sitemap', methods=["GET"])
def render_sitemap(cls):
Expand Down

0 comments on commit 35309e5

Please sign in to comment.