From e0818f8f462d186dd7ffc4206e8062e23d281470 Mon Sep 17 00:00:00 2001 From: Kanchan Chauhan Date: Fri, 22 Apr 2016 14:39:02 +0530 Subject: [PATCH] Website Changes --- .../controllers/website_list_for_contact.py | 2 +- erpnext/public/css/website.css | 3 ++ erpnext/public/less/website.less | 4 ++ erpnext/templates/pages/home.html | 31 ++++++++++++++++ erpnext/templates/pages/home.py | 37 +++++++++++++++++++ 5 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 erpnext/templates/pages/home.html create mode 100644 erpnext/templates/pages/home.py diff --git a/erpnext/controllers/website_list_for_contact.py b/erpnext/controllers/website_list_for_contact.py index 6b514b23d0..a1982ef515 100644 --- a/erpnext/controllers/website_list_for_contact.py +++ b/erpnext/controllers/website_list_for_contact.py @@ -49,7 +49,7 @@ def get_transaction_list(doctype, txt=None, filters=None, limit_start=0, limit_p order_by = "modified desc")) else: return [] - + return post_process(doctype, get_list(doctype, txt, filters, limit_start, limit_page_length, fields="name", order_by = "modified desc")) diff --git a/erpnext/public/css/website.css b/erpnext/public/css/website.css index 8b455f3a08..a57bf33f37 100644 --- a/erpnext/public/css/website.css +++ b/erpnext/public/css/website.css @@ -63,3 +63,6 @@ border-top: 2px solid #EBEFF2; padding-top: 10px; } +.featured-products { + border-top: 1px solid #EBEFF2; +} diff --git a/erpnext/public/less/website.less b/erpnext/public/less/website.less index 08ae03a767..7b0f1d651f 100644 --- a/erpnext/public/less/website.less +++ b/erpnext/public/less/website.less @@ -74,3 +74,7 @@ border-top: 2px solid @light-border-color; padding-top:10px; } + +.featured-products { + border-top: 1px solid @light-border-color; +} diff --git a/erpnext/templates/pages/home.html b/erpnext/templates/pages/home.html new file mode 100644 index 0000000000..5c0f330892 --- /dev/null +++ b/erpnext/templates/pages/home.html @@ -0,0 +1,31 @@ +{% extends "templates/web.html" %} + +{% block title %}{{brand_html}}{% endblock %} + +{% block page_content %} + + + + +
+
+

{{ tag_line }}

+

{{ description }}

+

Login

+
+
{{_("FEATURED PRODUCTS")}}
+ +

More Products

+
+
+
+{% endblock %} diff --git a/erpnext/templates/pages/home.py b/erpnext/templates/pages/home.py new file mode 100644 index 0000000000..af7509706c --- /dev/null +++ b/erpnext/templates/pages/home.py @@ -0,0 +1,37 @@ +# 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 +from frappe.utils import cstr, nowdate +from erpnext.setup.doctype.item_group.item_group import get_item_for_list_in_html + +no_cache = 1 +no_sitemap = 1 + +@frappe.whitelist(allow_guest=True) +def get_product_list(search=None, start=0, limit=6): + # limit = 12 because we show 12 items in the grid view + + # base query + query = """select name, item_name, page_name, website_image, thumbnail, item_group, + web_long_description as website_description, parent_website_route + from `tabItem` + where show_in_website = 1 + and disabled=0 + and (end_of_life is null or end_of_life='0000-00-00' or end_of_life > %(today)s) + and (variant_of is null or variant_of = '')""" + + # order by + query += """ order by weightage desc, idx desc, modified desc limit %s, %s""" % (start, limit) + + data = frappe.db.sql(query, { + "today": nowdate() + }, as_dict=1) + + for d in data: + d.route = ((d.parent_website_route + "/") if d.parent_website_route else "") \ + + (d.page_name or "") + + return [get_item_for_list_in_html(r) for r in data] +