30 lines
753 B
Python
Raw Normal View History

2016-04-22 14:39:02 +05:30
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import frappe
no_cache = 1
no_sitemap = 1
2016-04-22 18:53:21 +05:30
def get_context(context):
homepage = frappe.get_doc('Homepage')
2016-05-12 15:22:59 +05:30
2016-05-02 11:43:44 +05:30
for item in homepage.products:
2016-06-27 12:04:13 +05:30
route = frappe.db.get_value('Item', item.item_code, 'route')
if route:
item.route = '/' + route
2016-05-12 15:22:59 +05:30
context.title = homepage.title or homepage.company
2016-05-12 15:22:59 +05:30
# show atleast 3 products
if len(homepage.products) < 3:
for i in xrange(3 - len(homepage.products)):
homepage.append('products', {
'item_code': 'product-{0}'.format(i),
'item_name': frappe._('Product {0}').format(i),
'route': '#'
})
context.homepage = homepage