blob: 9a4c89c8120a8ec12fac66cc678616631b56524b [file] [log] [blame]
Kanchan Chauhane0818f82016-04-22 14:39:02 +05301# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
2# License: GNU General Public License v3. See license.txt
3
4from __future__ import unicode_literals
5import frappe
Kanchan Chauhane0818f82016-04-22 14:39:02 +05306
7no_cache = 1
8no_sitemap = 1
9
Anand Doshie3bd78e2016-04-22 18:53:21 +053010def get_context(context):
11 homepage = frappe.get_doc('Homepage')
Rushabh Mehta4b9238a2016-05-12 15:22:59 +053012
Kanchan Chauhan239b3512016-05-02 11:43:44 +053013 for item in homepage.products:
Anand Doshi771ab0c2016-06-27 12:04:13 +053014 route = frappe.db.get_value('Item', item.item_code, 'route')
15 if route:
16 item.route = '/' + route
Rushabh Mehta4b9238a2016-05-12 15:22:59 +053017
Rushabh Mehtaec2d09c2016-08-09 16:43:15 +053018 context.title = homepage.title or homepage.company
19
Rushabh Mehta4b9238a2016-05-12 15:22:59 +053020 # show atleast 3 products
21 if len(homepage.products) < 3:
22 for i in xrange(3 - len(homepage.products)):
23 homepage.append('products', {
24 'item_code': 'product-{0}'.format(i),
25 'item_name': frappe._('Product {0}').format(i),
26 'route': '#'
27 })
28
Rushabh Mehtaec2d09c2016-08-09 16:43:15 +053029 context.homepage = homepage