From f9620eaf441c0ee2882d1aff6be495e2c3452f3e Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Tue, 7 Feb 2012 14:31:49 +0530 Subject: [PATCH] fix to product, blog --- erpnext/home/__init__.py | 4 +-- .../{latest => website}/__init__.py | 0 .../{latest => website}/cleanups.py | 0 .../jan_mar_2012/{latest => website}/feed.py | 0 .../jan_mar_2012/{latest => website}/login.py | 0 .../{latest => website}/website.py | 1 + erpnext/website/Role/Blogger/Blogger.txt | 26 ++++++++++++++ erpnext/website/doctype/blog/blog.py | 1 + erpnext/website/doctype/blog/blog.txt | 20 +++++++++-- erpnext/website/doctype/product/product.py | 6 ++-- .../website/doctype/product/product_page.js | 36 ++++++++++++++++++- erpnext/website/doctype/product/template.html | 4 +++ erpnext/website/js/product_category.js | 2 +- erpnext/website/page/products/products.html | 1 + erpnext/website/page/products/products.js | 1 - version.num | 2 +- wnf.py | 6 ++++ 17 files changed, 99 insertions(+), 11 deletions(-) rename erpnext/patches/jan_mar_2012/{latest => website}/__init__.py (100%) rename erpnext/patches/jan_mar_2012/{latest => website}/cleanups.py (100%) rename erpnext/patches/jan_mar_2012/{latest => website}/feed.py (100%) rename erpnext/patches/jan_mar_2012/{latest => website}/login.py (100%) rename erpnext/patches/jan_mar_2012/{latest => website}/website.py (98%) create mode 100644 erpnext/website/Role/Blogger/Blogger.txt diff --git a/erpnext/home/__init__.py b/erpnext/home/__init__.py index d41b26289b..bec99d48ff 100644 --- a/erpnext/home/__init__.py +++ b/erpnext/home/__init__.py @@ -34,8 +34,8 @@ feed_dict = { 'Support Ticket': ['[%(status)s] %(subject)s', '#000080'], # Website - 'Web Page': ['%(title)s', '#00080'], - 'Blog': ['%(title)s', '#00080'] + 'Web Page': ['%(title)s', '#000080'], + 'Blog': ['%(title)s', '#000080'] } def make_feed(feedtype, doctype, name, owner, subject, color): diff --git a/erpnext/patches/jan_mar_2012/latest/__init__.py b/erpnext/patches/jan_mar_2012/website/__init__.py similarity index 100% rename from erpnext/patches/jan_mar_2012/latest/__init__.py rename to erpnext/patches/jan_mar_2012/website/__init__.py diff --git a/erpnext/patches/jan_mar_2012/latest/cleanups.py b/erpnext/patches/jan_mar_2012/website/cleanups.py similarity index 100% rename from erpnext/patches/jan_mar_2012/latest/cleanups.py rename to erpnext/patches/jan_mar_2012/website/cleanups.py diff --git a/erpnext/patches/jan_mar_2012/latest/feed.py b/erpnext/patches/jan_mar_2012/website/feed.py similarity index 100% rename from erpnext/patches/jan_mar_2012/latest/feed.py rename to erpnext/patches/jan_mar_2012/website/feed.py diff --git a/erpnext/patches/jan_mar_2012/latest/login.py b/erpnext/patches/jan_mar_2012/website/login.py similarity index 100% rename from erpnext/patches/jan_mar_2012/latest/login.py rename to erpnext/patches/jan_mar_2012/website/login.py diff --git a/erpnext/patches/jan_mar_2012/latest/website.py b/erpnext/patches/jan_mar_2012/website/website.py similarity index 98% rename from erpnext/patches/jan_mar_2012/latest/website.py rename to erpnext/patches/jan_mar_2012/website/website.py index 9c930e2659..4ffb441738 100644 --- a/erpnext/patches/jan_mar_2012/latest/website.py +++ b/erpnext/patches/jan_mar_2012/website/website.py @@ -12,6 +12,7 @@ def execute(): delete_doc('Website', 'Module Def', 'Website') reload_doc('website', 'Module Def', 'Website') reload_doc('website', 'Role', 'Website Manager') + reload_doc('website', 'Role', 'Blogger') webnotes.conn.sql("""delete from `tabModule Def Role` where parent='Website'""") d = Document('Module Def Role') diff --git a/erpnext/website/Role/Blogger/Blogger.txt b/erpnext/website/Role/Blogger/Blogger.txt new file mode 100644 index 0000000000..a380d4c7b7 --- /dev/null +++ b/erpnext/website/Role/Blogger/Blogger.txt @@ -0,0 +1,26 @@ +# Role, Blogger +[ + + # These values are common in all dictionaries + { + 'creation': '2012-01-27 12:22:24', + 'docstatus': 0, + 'modified': '2012-01-27 12:22:24', + 'modified_by': u'Administrator', + 'owner': u'Administrator' + }, + + # These values are common for all Role + { + 'doctype': 'Role', + 'module': u'Website', + 'name': '__common__', + 'role_name': u'Blogger' + }, + + # Role, Blogger + { + 'doctype': 'Role', + 'name': u'Blogger' + } +] \ No newline at end of file diff --git a/erpnext/website/doctype/blog/blog.py b/erpnext/website/doctype/blog/blog.py index c0e70a6100..c83b922d50 100644 --- a/erpnext/website/doctype/blog/blog.py +++ b/erpnext/website/doctype/blog/blog.py @@ -18,6 +18,7 @@ class DocType(): def validate(self): """write/update 'Page' with the blog""" p = website.utils.add_page(self.doc.title) + self.doc.name = p.name from jinja2 import Template import markdown2 diff --git a/erpnext/website/doctype/blog/blog.txt b/erpnext/website/doctype/blog/blog.txt index 2471c2dfa4..59444f8113 100644 --- a/erpnext/website/doctype/blog/blog.txt +++ b/erpnext/website/doctype/blog/blog.txt @@ -5,21 +5,23 @@ { 'creation': '2012-01-27 12:24:03', 'docstatus': 0, - 'modified': '2012-02-07 12:59:01', + 'modified': '2012-02-07 13:55:17', 'modified_by': u'Administrator', 'owner': u'Administrator' }, # These values are common for all DocType { - '_last_update': u'1327647244', + '_last_update': u'1328599743', + 'allow_attach': 1, 'colour': u'White:FFF', 'doctype': 'DocType', + 'max_attachments': 5, 'module': u'Website', 'name': '__common__', 'section_style': u'Simple', 'show_in_menu': 0, - 'version': 2 + 'version': 3 }, # These values are common for all DocField @@ -106,5 +108,17 @@ 'fieldtype': u'Text', 'label': u'Preview', 'permlevel': 1 + }, + + # DocField + { + 'doctype': u'DocField', + 'fieldname': u'file_list', + 'fieldtype': u'Text', + 'hidden': 1, + 'label': u'File List', + 'no_copy': 1, + 'permlevel': 0, + 'print_hide': 1 } ] \ No newline at end of file diff --git a/erpnext/website/doctype/product/product.py b/erpnext/website/doctype/product/product.py index 5880d34c7b..223a790df9 100644 --- a/erpnext/website/doctype/product/product.py +++ b/erpnext/website/doctype/product/product.py @@ -14,6 +14,7 @@ class DocType: import markdown2 import os + self.doc.item_group = webnotes.conn.get_value('Item', self.doc.item, 'item_group') self.doc.long_description_html = markdown2.markdown(self.doc.long_description or '') with open(os.path.join(os.path.dirname(__file__), 'template.html'), 'r') as f: @@ -26,14 +27,15 @@ class DocType: website.utils.add_guest_access_to_page(p.name) self.doc.page_name = p.name - del self.doc.fields['long_description_html'] self.make_item_group_active() + del self.doc.fields['long_description_html'] + del self.doc.fields['item_group'] def make_item_group_active(self): """show item group in website""" if self.doc.published: from webnotes.model.doc import Document - ig = Document('Item Group', webnotes.conn.get_value('Item', self.doc.item, 'item_group')) + ig = Document('Item Group', self.doc.item_group) ig.show_in_website = 1 ig.save() diff --git a/erpnext/website/doctype/product/product_page.js b/erpnext/website/doctype/product/product_page.js index 7d031ef94b..35359cca41 100644 --- a/erpnext/website/doctype/product/product_page.js +++ b/erpnext/website/doctype/product/product_page.js @@ -1,6 +1,8 @@ wn.require('erpnext/website/js/product_category.js'); pscript["onload_{{ doc.page_name }}"] = function(wrapper) { + wrapper.product_group = "{{ doc.item_group }}"; + wrapper.product_name = "{{ doc.name }}"; erpnext.make_product_categories(wrapper); $(wrapper).find('.product-inquiry').click(function() { loadpage('contact', function() { @@ -9,5 +11,37 @@ pscript["onload_{{ doc.page_name }}"] = function(wrapper) { My contact details are:\n\nThank you!\ "); }) - }) + }); + + // similar products + wrapper.similar = new wn.widgets.Listing({ + parent: $(wrapper).find('.similar-products').get(0), + hide_refresh: true, + page_length: 5, + get_query: function() { + args = { + cat: wrapper.product_group, + name: wrapper.product_name + }; + return repl('select t1.name, t1.title, t1.thumbnail_image, \ + t1.page_name, t1.short_description \ + from tabProduct t1, tabItem t2 \ + where t1.item = t2.name \ + and ifnull(t1.published,0)=1 \ + and t1.name != "%(name)s" \ + and t2.item_group="%(cat)s" order by t1.modified desc', args) + }, + render_row: function(parent, data) { + if(data.short_description.length > 100) { + data.short_description = data.short_description.substr(0,100) + '...'; + } + parent.innerHTML = repl('
\ +
\ +
\ + %(title)s\ +

%(short_description)s

\ +
', data); + } + }); + wrapper.similar.run(); } \ No newline at end of file diff --git a/erpnext/website/doctype/product/template.html b/erpnext/website/doctype/product/template.html index 8c7f918ef1..926b650847 100644 --- a/erpnext/website/doctype/product/template.html +++ b/erpnext/website/doctype/product/template.html @@ -22,6 +22,10 @@

More Categories

+
+
+

Similar Products

+
diff --git a/erpnext/website/js/product_category.js b/erpnext/website/js/product_category.js index 5296029a5b..076578ae25 100644 --- a/erpnext/website/js/product_category.js +++ b/erpnext/website/js/product_category.js @@ -3,7 +3,7 @@ erpnext.product_item_group = {} erpnext.make_product_categories = function(wrapper) { wrapper.category_list = new wn.widgets.Listing({ - parent: $(wrapper).find('.web-side-section').get(0), + parent: $(wrapper).find('.more-categories').get(0), query: 'select label, count(t2.name) as items, t1.item_group \ from `tabProduct Group` t1, `tabProduct` t2, tabItem t3\ where t1.parent="Products Settings" \ diff --git a/erpnext/website/page/products/products.html b/erpnext/website/page/products/products.html index d12004ee2f..7ca7495893 100644 --- a/erpnext/website/page/products/products.html +++ b/erpnext/website/page/products/products.html @@ -7,6 +7,7 @@

Categories

+
\ No newline at end of file diff --git a/erpnext/website/page/products/products.js b/erpnext/website/page/products/products.js index 6284d186a9..b9fa167514 100644 --- a/erpnext/website/page/products/products.js +++ b/erpnext/website/page/products/products.js @@ -70,7 +70,6 @@ erpnext.products.make_product_list = function(wrapper) {
', data); } }); - } erpnext.products.set_group = function() { diff --git a/version.num b/version.num index 4f36264f98..e24b797f8d 100644 --- a/version.num +++ b/version.num @@ -1 +1 @@ -360 \ No newline at end of file +361 \ No newline at end of file diff --git a/wnf.py b/wnf.py index 355474f58c..52308d0902 100755 --- a/wnf.py +++ b/wnf.py @@ -52,6 +52,8 @@ def setup_options(): help="Apply the patches on given db") parser.add_option('--reload_doc', nargs=3, metavar = "module doctype docname", help="reload doc") + parser.add_option('--export_doc', nargs=2, metavar = "doctype docname", + help="export doc") return parser.parse_args() @@ -121,6 +123,10 @@ def run(): {"module":options.reload_doc[0], "dt":options.reload_doc[1], "dn":options.reload_doc[2]}) print '\n'.join(webnotes.modules.patch_handler.log_list) + elif options.export_doc: + from webnotes.modules import export_doc + export_doc(options.export_doc[0], options.export_doc[1]) + # run all pending elif options.run_latest: webnotes.modules.patch_handler.run_all()