Kanchan Chauhan | e0818f8 | 2016-04-22 14:39:02 +0530 | [diff] [blame] | 1 | # Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors |
| 2 | # License: GNU General Public License v3. See license.txt |
| 3 | |
| 4 | from __future__ import unicode_literals |
| 5 | import frappe |
Kanchan Chauhan | e0818f8 | 2016-04-22 14:39:02 +0530 | [diff] [blame] | 6 | |
| 7 | no_cache = 1 |
| 8 | no_sitemap = 1 |
| 9 | |
Anand Doshi | e3bd78e | 2016-04-22 18:53:21 +0530 | [diff] [blame] | 10 | def get_context(context): |
| 11 | homepage = frappe.get_doc('Homepage') |
Rushabh Mehta | 4b9238a | 2016-05-12 15:22:59 +0530 | [diff] [blame] | 12 | |
Kanchan Chauhan | 239b351 | 2016-05-02 11:43:44 +0530 | [diff] [blame] | 13 | for item in homepage.products: |
Anand Doshi | 771ab0c | 2016-06-27 12:04:13 +0530 | [diff] [blame] | 14 | route = frappe.db.get_value('Item', item.item_code, 'route') |
| 15 | if route: |
| 16 | item.route = '/' + route |
Rushabh Mehta | 4b9238a | 2016-05-12 15:22:59 +0530 | [diff] [blame] | 17 | |
Rushabh Mehta | ec2d09c | 2016-08-09 16:43:15 +0530 | [diff] [blame] | 18 | context.title = homepage.title or homepage.company |
| 19 | |
Rushabh Mehta | 4b9238a | 2016-05-12 15:22:59 +0530 | [diff] [blame] | 20 | # show atleast 3 products |
| 21 | if len(homepage.products) < 3: |
Achilles Rasquinha | 96698c9 | 2018-02-28 16:12:51 +0530 | [diff] [blame] | 22 | for i in range(3 - len(homepage.products)): |
Rushabh Mehta | 4b9238a | 2016-05-12 15:22:59 +0530 | [diff] [blame] | 23 | homepage.append('products', { |
| 24 | 'item_code': 'product-{0}'.format(i), |
| 25 | 'item_name': frappe._('Product {0}').format(i), |
| 26 | 'route': '#' |
| 27 | }) |
| 28 | |
Rushabh Mehta | ec2d09c | 2016-08-09 16:43:15 +0530 | [diff] [blame] | 29 | context.homepage = homepage |