brotherton-erpnext/erpnext/templates/pages/home.py

30 lines
707 B
Python
Raw Normal View History

2016-04-22 09:09:02 +00:00
# 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 13:23:21 +00:00
def get_context(context):
homepage = frappe.get_doc('Homepage')
2016-05-12 09:52:59 +00:00
2016-05-02 06:13:44 +00:00
for item in homepage.products:
2016-06-27 06:34:13 +00:00
route = frappe.db.get_value('Item', item.item_code, 'route')
if route:
item.route = '/' + route
2016-05-12 09:52:59 +00:00
# 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': '#'
})
2016-04-22 13:23:21 +00:00
return {
'homepage': homepage
2016-06-27 06:34:13 +00:00
}