Skip to content

Commit

Permalink
Merge branch 'release/3.2.2.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
tarunbhardwaj committed Jan 7, 2015
2 parents dbe04df + feb5277 commit 2a3502e
Show file tree
Hide file tree
Showing 13 changed files with 1,603 additions and 13 deletions.
1,468 changes: 1,468 additions & 0 deletions locale/de_DE.po

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions static/css/style.css
Expand Up @@ -1618,3 +1618,7 @@ border-top: 1px solid rgba(248, 248, 248, 0.2);
.inline-form {
display: inline-block;
}
#search-bar .tt-suggestion {
padding: 5px;
padding-left: 15px;
}
53 changes: 53 additions & 0 deletions templates/webshop/_helpers.jinja
Expand Up @@ -65,6 +65,12 @@
</div>
{%- endmacro %}

{% macro render_search_filter_field(term, facet_checked, key) %}
<input type="checkbox" name="{{ key }}" value="{{ term['term'] }}"
{% if term['term'] in facet_checked %} checked="checked" {% endif %} />
{{ term['term'] }} {% if term['count'] > 0 %} ({{ term['count'] }}){% endif %}
{% endmacro %}

{% macro render_product_list(product, node=None, name=None, description=None, product_list_name=None) -%}
{% set description = description or product.description %}
{% if product.__name__ == 'product.template' %}
Expand Down Expand Up @@ -142,6 +148,53 @@
</ul>
{% endmacro %}

{% macro render_es_pagination(pagination) %}
<ul class="es_pagination pagination pull-right">
{% if pagination.has_prev -%}
<li>
<a href="#" data-page-no="{{pagination.prev_num}}">
&laquo; {% trans %}Previous{% endtrans %}
</a>
</li>
{% else %}
<li class="disabled">
<a>
&laquo; {% trans %}Previous{% endtrans %}
</a>
</li>
{% endif %}

{%- for page in pagination.iter_pages(left_edge=0, left_current=5, right_current=5, right_edge=0) %}
{% if loop.first and page !=1 %}
<li class="disabled"><a>...</a></li>
{% endif %}

{% if page %}
<li {% if page == pagination.page %}class="active"{% endif %}>
<a href="#" data-page-no="{{page}}">{{ page }}</a>
</li>
{% endif %}

{% if loop.last and page != pagination.pages %}
<li class="disabled"><a>...</a></li>
{% endif %}
{% endfor %}

{% if pagination.has_next -%}
<li>
<a href="#" data-page-no="{{pagination.next_num}}">
{% trans %}Next{% endtrans %} &raquo;
</a>
</li>
{% else %}
<li class="disabled">
<a>{% trans %}Next{% endtrans %} &raquo;</a>
</li>
{% endif %}

</ul>
{% endmacro %}

{% macro render_cms_root_menu(root_menu) -%}
{# render the children of the given node as menu #}
{% for menuitem in root_menu.get_menu_item(max_depth=10).children %}
Expand Down
1 change: 1 addition & 0 deletions templates/webshop/address-add.jinja
Expand Up @@ -68,6 +68,7 @@
// Register on change event
$("select#country").change(function(){
$("select#subdivision").html(''); // Clear options as soon as country change
$.getJSON("{{ url_for('nereid.website.subdivision_list') }}",
{country: $(this).val()}, function(data){
var options = '';
Expand Down
1 change: 1 addition & 0 deletions templates/webshop/address-edit.jinja
Expand Up @@ -71,6 +71,7 @@
$(document).ready(function(){
// Register on change event
$("select#country").change(function(){
$("select#subdivision").html(''); // Clear options as soon as country change
$.getJSON("{{ url_for('nereid.website.subdivision_list') }}",
{country: $(this).val()}, function(data){
var options = '';
Expand Down
11 changes: 7 additions & 4 deletions templates/webshop/base.jinja
Expand Up @@ -191,9 +191,9 @@
<div class="col-md-5 col-sm-12 col-xs-12 col-md-pull-4 top-search"
itemscope itemtype="http://schema.org/WebSite">
<meta itemprop="url" content="{{ url_for('nereid.website.home', _external=True) }}"/>
<form action="{{ url_for('product.product.quick_search') }}" id="search_form"
<form action="{{ url_for('nereid.website.quick_search') }}" id="search_form"
itemprop="potentialAction" itemscope itemtype="http://schema.org/SearchAction">
<meta itemprop="target" content="{{ url_for('product.product.quick_search', _external=True) }}?q={q}"/>
<meta itemprop="target" content="{{ url_for('nereid.website.quick_search', _external=True) }}?q={q}"/>
<div class="input-group" id="search-bar">
<input type="text" class="form-control typeahead" data-provide="typeahead" name="q" itemprop="query-input" required>
<span class="input-group-btn">
Expand Down Expand Up @@ -642,8 +642,11 @@
},
{
name: 'products',
displayKey: 'value',
source: products.ttAdapter()
displayKey: 'display_name',
source: products.ttAdapter(),
templates: {
suggestion: _.template("<a href=<%=url%>><%= display_name %></a>")
}
});
});
</script>
Expand Down
1 change: 1 addition & 0 deletions templates/webshop/checkout.jinja
Expand Up @@ -207,6 +207,7 @@
$(document).ready(function(){
// Register on change event
$("select#country").change(function(){
$("select#subdivision").html(''); // Clear options as soon as country change
$.getJSON("{{ url_for('nereid.website.subdivision_list') }}",
{country: $(this).val()}, function(data){
var options = '';
Expand Down
1 change: 1 addition & 0 deletions templates/webshop/checkout/billing_address.jinja
Expand Up @@ -107,6 +107,7 @@
// Register on change event
$("select#country").change(function(){
$("select#subdivision").html(''); // Clear options as soon as country change
$.getJSON("{{ url_for('nereid.website.subdivision_list') }}",
{country: $(this).val()}, function(data){
var options = '';
Expand Down
1 change: 1 addition & 0 deletions templates/webshop/checkout/shipping_address.jinja
Expand Up @@ -118,6 +118,7 @@
// Register on change event
$("select#country").change(function(){
$("select#subdivision").html(''); // Clear subdivisions on change
$.getJSON("{{ url_for('nereid.website.subdivision_list') }}",
{country: $(this).val()}, function(data){
var options = '';
Expand Down
53 changes: 50 additions & 3 deletions templates/webshop/search-results.jinja
@@ -1,15 +1,41 @@
{% extends 'base.jinja' %}

{% from 'webshop/_helpers.jinja' import render_pagination, render_product_list with context %}
{% from 'webshop/_helpers.jinja' import render_es_pagination, render_pagination, render_search_filter_field, render_product_list with context %}

{% block breadcrumb %}
{{ super() }}
{{ render_breadcrumb_item(_('Search Results'), url_for('product.product.quick_search', q=request.args.get('q', ''))) }}
{{ render_breadcrumb_item(_('Search Results'), url_for('nereid.website.quick_search', q=request.args.get('q', ''))) }}
{% endblock breadcrumb %}

{% block main %}

<section>
<div class="container">
{% if facets %}
{% block sidebar %}
<div class="col-md-3">
<div class="sidebar">
<h4>{% trans %}Refine your search{% endtrans %}</h4>
<form id="filter-form-sidebar">
<input type="hidden" name="q" value="{{ request.args.get('q') }}" />
<input type="hidden" name="page" value="1"/>
{% for key, value in facets.iteritems() %}
<ul>
<lh>{{ key }}</lh>
{% set facet_checked = request.args.getlist(key) %}
{% for term in value['terms'] %}
<li>
{{ render_search_filter_field(term, facet_checked, key) }}
</li>
{% endfor %}
</ul>
{% endfor %}
</form>
</div>
</div>
{% endblock %}
{% endif %}
<div class="col-md-9">
<!-- category page -->
<div class="row">
<!-- Content bar -->
Expand Down Expand Up @@ -49,7 +75,11 @@
</div>
<div class="row">
<div class="col-md-12">
{{ render_pagination(products, endpoint='product.product.quick_search', q=request.args.get('q', '')) }}
{% if facets %}
{{ render_es_pagination(products) }}
{% else %}
{{ render_pagination(products, endpoint='nereid.website.quick_search', q=request.args.get('q', '')) }}
{% endif %}
</div>
</div>

Expand All @@ -65,5 +95,22 @@
{% endif %}

</div>
</div>
</section>
{% endblock main %}

{% block scripts %}
{{ super() }}
<script type="text/javascript">
$(function (){
$(".es_pagination a[data-page-no]").click(function (e) {
e.preventDefault();
$('#filter-form-sidebar input[name="page"]').val($(this).data('page-no')).change();
})
$("#filter-form-sidebar input").on('change', function(){
$("#filter-form-sidebar").submit();
});
});
</script>
{% endblock %}
2 changes: 1 addition & 1 deletion tests/test_base.py
Expand Up @@ -473,7 +473,7 @@ def setup_defaults(self):
'uri': 'test-article',
'content': 'Test Content',
'sequence': 10,
'category': [('add', [article_categ.id])],
'categories': [('add', [article_categ.id])],
}])

# Product categories
Expand Down
2 changes: 1 addition & 1 deletion tryton.cfg
@@ -1,5 +1,5 @@
[tryton]
version=3.2.1.36
version=3.2.2.0
depends:
nereid
nereid_cms
Expand Down
18 changes: 14 additions & 4 deletions webshop.py
Expand Up @@ -2,7 +2,7 @@
'''
website
:copyright: (c) 2013-2014 by Openlabs Technologies & Consulting (P) Ltd.
:copyright: (c) 2013-2015 by Openlabs Technologies & Consulting (P) Ltd.
:license: GPLv3, see LICENSE for more details
'''
Expand Down Expand Up @@ -112,7 +112,7 @@ def render_sitemap(cls):
return render_template('sitemap.jinja', nodes=nodes)

@classmethod
def auto_complete(cls, phrase, limit=10):
def auto_complete(cls, phrase):
"""
Customizable method which returns a list of dictionaries
according to the search query. The search service used can
Expand All @@ -139,6 +139,16 @@ def search_auto_complete(cls):
Handler for auto-completing search.
"""
return jsonify(results=cls.auto_complete(
request.args.get('q', ''),
request.args.get('limit', 10, type=int)
request.args.get('q', '')
))

@classmethod
@route('/search')
def quick_search(cls):
"""
Downstream implementation of quick_search().
TODO:
* Add article search.
"""
return super(Website, cls).quick_search()

0 comments on commit 2a3502e

Please sign in to comment.