From 647e0d11649455524a2878871c600df691ba8631 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Tue, 18 Dec 2012 14:47:54 +0530 Subject: [PATCH] updates to product_page (search) and kb fix --- public/js/kb_common.js | 2 +- stock/doctype/item/item.txt | 5 +- utilities/page/questions/questions.py | 2 +- website/helpers/product.py | 89 ++----------------- website/templates/html/product_page.html | 12 ++- website/templates/html/product_search.html | 9 -- .../templates/html/product_search_box.html | 24 +++++ website/templates/pages/product_search.html | 88 ++++++++++++++++++ 8 files changed, 131 insertions(+), 100 deletions(-) delete mode 100644 website/templates/html/product_search.html create mode 100644 website/templates/html/product_search_box.html create mode 100644 website/templates/pages/product_search.html diff --git a/public/js/kb_common.js b/public/js/kb_common.js index 032d2db143..0686677692 100644 --- a/public/js/kb_common.js +++ b/public/js/kb_common.js @@ -33,7 +33,7 @@ KBItemToolbar = function(args, kb) { this.make_timestamp = function() { this.line1.innerHTML = repl('By %(name)s | %(when)s', { - name: wn.utils.full_name(this.det.first_name, this.det.last_name), + name: wn.user_info(this.det.owner).fullname, when: wn.datetime.comment_when(this.det.modified) }); diff --git a/stock/doctype/item/item.txt b/stock/doctype/item/item.txt index ce54443c35..10017a69a8 100644 --- a/stock/doctype/item/item.txt +++ b/stock/doctype/item/item.txt @@ -4,7 +4,7 @@ "docstatus": 0, "creation": "2012-12-17 14:56:32", "modified_by": "Administrator", - "modified": "2012-12-17 16:02:00" + "modified": "2012-12-18 14:23:19" }, { "allow_attach": 1, @@ -823,11 +823,12 @@ "permlevel": 0 }, { + "description": "Will appear in search", "depends_on": "show_in_website", "doctype": "DocField", "label": "Short Description", "fieldname": "web_short_description", - "fieldtype": "Text", + "fieldtype": "Text Editor", "permlevel": 0 }, { diff --git a/utilities/page/questions/questions.py b/utilities/page/questions/questions.py index b38bc1ed42..20d38034fb 100644 --- a/utilities/page/questions/questions.py +++ b/utilities/page/questions/questions.py @@ -35,7 +35,7 @@ def get_questions(): conds += ' and t1._user_tags like "%'+ t +'%"' return webnotes.conn.sql("""select t1.name, t1.owner, t1.question, t1.modified, t1._user_tags, - t2.first_name, t2.last_name, (select count(*) from tabAnswer where + (select count(*) from tabAnswer where tabAnswer.question = t1.name) as answers from tabQuestion t1, tabProfile t2 where t1.docstatus!=2 diff --git a/website/helpers/product.py b/website/helpers/product.py index fec462607b..ceec17daec 100644 --- a/website/helpers/product.py +++ b/website/helpers/product.py @@ -25,14 +25,6 @@ def get_product_info(item_code): @webnotes.whitelist(allow_guest=True) def get_product_list(args=None): - """ - args = { - 'limit_start': 0, - 'limit_page_length': 20, - 'search': '', - 'product_group': '', - } - """ import webnotes from webnotes.utils import cstr @@ -40,11 +32,11 @@ def get_product_list(args=None): # base query query = """\ - select name, item_name, page_name, website_image, - description, web_short_description + select name, item_name, page_name, website_image, item_group, + if(ifnull(web_short_description,'')='', web_long_description, + web_short_description) as web_short_description from `tabItem` - where is_sales_item = 'Yes' - and docstatus = 0 + where docstatus = 0 and show_in_website = 1""" # search term condition @@ -65,75 +57,6 @@ def get_product_list(args=None): and item_group = %(product_group)s""" # order by - query += """ - order by item_name asc, name asc""" + query += """order by item_name asc, name asc limit %s, 10""" % args.start - from webnotes.widgets.query_builder import add_limit_to_query - query, args = add_limit_to_query(query, args) - - return webnotes.conn.sql(query, args, as_dict=1) - -@webnotes.whitelist(allow_guest=True) -def get_product_category_list(args=None): - """ - args = { - 'limit_start': 0, - 'limit_page_length': 5, - } - """ - import webnotes - - if not args: args = webnotes.form_dict - - query = """\ - select count(name) as items, item_group - from `tabItem` - where is_sales_item = 'Yes' - and docstatus = 0 - and show_in_website = 1 - group by item_group - order by items desc""" - - from webnotes.widgets.query_builder import add_limit_to_query - query, args = add_limit_to_query(query, args) - - - result = webnotes.conn.sql(query, args, as_dict=1) - - # add All Products link - total_count = sum((r.get('items') or 0 for r in result)) - result = [{'items': total_count, 'item_group': 'All Products'}] + (result or []) - - return result - -@webnotes.whitelist(allow_guest=True) -def get_similar_product_list(args=None): - """ - args = { - 'limit_start': 0, - 'limit_page_length': 5, - 'product_name': '', - 'product_group': '', - } - """ - import webnotes - - if not args: args = webnotes.form_dict - - query = """\ - select name, item_name, page_name, website_image, - description, web_short_description - from `tabItem` - where is_sales_item = 'Yes' - and docstatus = 0 - and show_in_website = 1 - and name != %(product_name)s - and item_group = %(product_group)s - order by item_name""" - - from webnotes.widgets.query_builder import add_limit_to_query - query, args = add_limit_to_query(query, args) - - result = webnotes.conn.sql(query, args, as_dict=1) - - return result \ No newline at end of file + return webnotes.conn.sql(query, args, as_dict=1) \ No newline at end of file diff --git a/website/templates/html/product_page.html b/website/templates/html/product_page.html index 80108f1820..50b306029a 100644 --- a/website/templates/html/product_page.html +++ b/website/templates/html/product_page.html @@ -20,15 +20,19 @@
- {% include 'html/product_search.html' %} + {% include 'html/product_search_box.html' %}

{{ item_name }}

{% if website_image %} {% else %} -
- This is an auto-generated Image +
+
+
+
+ {% endif %}

@@ -51,7 +55,7 @@ {% for d in obj.doclist.get( {"doctype":"Item Website Specification"}) %} - {{ d.label }} + {{ d.label }} {{ d.description }} {% endfor %} diff --git a/website/templates/html/product_search.html b/website/templates/html/product_search.html deleted file mode 100644 index 034ec112f8..0000000000 --- a/website/templates/html/product_search.html +++ /dev/null @@ -1,9 +0,0 @@ -
- -
-
\ No newline at end of file diff --git a/website/templates/html/product_search_box.html b/website/templates/html/product_search_box.html new file mode 100644 index 0000000000..3cbb3e9c81 --- /dev/null +++ b/website/templates/html/product_search_box.html @@ -0,0 +1,24 @@ +
+ + +
\ No newline at end of file diff --git a/website/templates/pages/product_search.html b/website/templates/pages/product_search.html new file mode 100644 index 0000000000..53a0572d69 --- /dev/null +++ b/website/templates/pages/product_search.html @@ -0,0 +1,88 @@ +{% extends "html/page.html" %} + +{% block title %}Product Search{% endblock %} + +{% block content %} + + +
+ +
+ +{% endblock %} \ No newline at end of file