-
Notifications
You must be signed in to change notification settings - Fork 13
/
website.py
37 lines (29 loc) · 1.07 KB
/
website.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# -*- coding: utf-8 -*-
'''
website
Nereid Website
:copyright: (c) 2014 by Openlabs Technologies & Consulting (P) Ltd.
:license: GPLv3, see LICENSE for more details
'''
from trytond.pool import Pool, PoolMeta
from nereid import request, route, render_template
from nereid.contrib.pagination import Pagination
__all__ = ['WebSite']
__metaclass__ = PoolMeta
class WebSite:
__name__ = 'nereid.website'
@classmethod
@route('/search')
def quick_search(cls):
"""A quick and dirty search which searches through the product.product
for an insensitive like and returns a pagination object the same.
"""
Product = Pool().get('product.product')
page = request.args.get('page', 1, type=int)
query = request.args.get('q', '')
products = Pagination(Product, [
('displayed_on_eshop', '=', True),
('template.active', '=', True),
('name', 'ilike', '%' + query + '%'),
], page, Product.per_page)
return render_template('search-results.jinja', products=products)