From 46089dbc97f52fdc20813a47ff2d61fdb4de25f6 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Mon, 9 Sep 2013 11:32:24 +0530 Subject: [PATCH 01/37] [website] [minor] moving website helper methods to doctypes --- config.json | 4 +- setup/doctype/item_group/item_group.py | 2 +- setup/doctype/sales_partner/sales_partner.py | 6 + startup/event_handlers.py | 2 +- stock/doctype/item/item.py | 2 +- .../blog_post}/blog_feed.py | 0 website/doctype/blog_post/blog_post.py | 107 ++++++++++++++++ website/doctype/blogger/blogger.py | 2 +- .../doctype/style_settings/style_settings.py | 2 +- website/doctype/web_page/web_page.py | 2 +- .../doctype/website_script/website_script.py | 2 +- .../make_web_include_files.py | 0 .../website_settings/website_settings.py | 2 +- .../website_slideshow/website_slideshow.py | 7 +- website/helpers/blog.py | 121 ------------------ website/helpers/partner.py | 11 -- website/helpers/slideshow.py | 10 -- website/templates/js/blog.js | 2 +- website/templates/js/blog_page.js | 2 +- 19 files changed, 131 insertions(+), 155 deletions(-) rename website/{helpers => doctype/blog_post}/blog_feed.py (100%) rename website/{helpers => doctype/website_settings}/make_web_include_files.py (100%) delete mode 100644 website/helpers/blog.py delete mode 100644 website/helpers/partner.py delete mode 100644 website/helpers/slideshow.py diff --git a/config.json b/config.json index e0f98d8daa..19f787e374 100644 --- a/config.json +++ b/config.json @@ -90,7 +90,7 @@ }, "blog": { "template": "app/website/templates/pages/blog", - "args_method": "website.helpers.blog.get_blog_template_args" + "args_method": "website.doctype.blog_post.blog_post.get_blog_template_args" }, "contact": { "template": "app/website/templates/pages/contact", @@ -185,7 +185,7 @@ }, "partners": { "template": "app/website/templates/pages/partners", - "args_method": "website.helpers.partner.get_partner_args" + "args_method": "setup.doctype.sales_partner.sales_partner.get_partner_args" } }, "generators": { diff --git a/setup/doctype/item_group/item_group.py b/setup/doctype/item_group/item_group.py index 81f6903516..e2eb5e91c4 100644 --- a/setup/doctype/item_group/item_group.py +++ b/setup/doctype/item_group/item_group.py @@ -60,6 +60,6 @@ class DocType(DocTypeNestedSet): self.doc.title = self.doc.name if self.doc.slideshow: - from website.helpers.slideshow import get_slideshow + from website.doctype.website_slideshow.website_slideshow import get_slideshow get_slideshow(self) \ No newline at end of file diff --git a/setup/doctype/sales_partner/sales_partner.py b/setup/doctype/sales_partner/sales_partner.py index 2c39e67bea..d63376d537 100644 --- a/setup/doctype/sales_partner/sales_partner.py +++ b/setup/doctype/sales_partner/sales_partner.py @@ -43,3 +43,9 @@ class DocType: "partner_address": filter_strip_join(address_rows, "\n
"), "phone": filter_strip_join(cstr(address.phone).split(","), "\n
") }) + +def get_partner_args(): + return { + "partners": webnotes.conn.sql("""select * from `tabSales Partner` + where show_in_website=1 order by name asc""", as_dict=True), + } \ No newline at end of file diff --git a/startup/event_handlers.py b/startup/event_handlers.py index fa08962fc2..84a91a4491 100644 --- a/startup/event_handlers.py +++ b/startup/event_handlers.py @@ -65,7 +65,7 @@ def check_if_expired(): raise webnotes.AuthenticationError def on_build(): - from website.helpers.make_web_include_files import make + from website.doctype.website_settings.make_web_include_files import make make() from home.page.latest_updates import latest_updates diff --git a/stock/doctype/item/item.py b/stock/doctype/item/item.py index 75e2b034a3..dab7dea044 100644 --- a/stock/doctype/item/item.py +++ b/stock/doctype/item/item.py @@ -264,7 +264,7 @@ class DocType(DocListController): self.doc.title = self.doc.item_name if self.doc.slideshow: - from website.helpers.slideshow import get_slideshow + from website.doctype.website_slideshow.website_slideshow import get_slideshow get_slideshow(self) def get_file_details(self, arg = ''): diff --git a/website/helpers/blog_feed.py b/website/doctype/blog_post/blog_feed.py similarity index 100% rename from website/helpers/blog_feed.py rename to website/doctype/blog_post/blog_feed.py diff --git a/website/doctype/blog_post/blog_post.py b/website/doctype/blog_post/blog_post.py index 48b32069d8..143b64d586 100644 --- a/website/doctype/blog_post/blog_post.py +++ b/website/doctype/blog_post/blog_post.py @@ -67,3 +67,110 @@ class DocType: for comment in self.doc.comment_list: comment['comment_date'] = webnotes.utils.global_date_format(comment['creation']) comment['comment'] = markdown2.markdown(comment['comment']) + +def clear_blog_cache(): + for blog in webnotes.conn.sql_list("""select page_name from + `tabBlog Post` where ifnull(published,0)=1"""): + webnotes.webutils.delete_page_cache(blog) + + webnotes.webutils.delete_page_cache("writers") + +@webnotes.whitelist(allow_guest=True) +def get_blog_list(start=0, by=None, category=None): + import webnotes + condition = "" + if by: + condition = " and t1.blogger='%s'" % by.replace("'", "\'") + if category: + condition += " and t1.blog_category='%s'" % category.replace("'", "\'") + query = """\ + select + t1.title, t1.name, t1.page_name, t1.published_on as creation, + ifnull(t1.blog_intro, t1.content) as content, + t2.full_name, t2.avatar, t1.blogger, + (select count(name) from `tabComment` where + comment_doctype='Blog Post' and comment_docname=t1.name) as comments + from `tabBlog Post` t1, `tabBlogger` t2 + where ifnull(t1.published,0)=1 + and t1.blogger = t2.name + %(condition)s + order by published_on desc, name asc + limit %(start)s, 20""" % {"start": start, "condition": condition} + + result = webnotes.conn.sql(query, as_dict=1) + + # strip html tags from content + import webnotes.utils + + for res in result: + from webnotes.utils import global_date_format + res['published'] = global_date_format(res['creation']) + if not res['content']: + res['content'] = webnotes.webutils.get_html(res['page_name']) + res['content'] = res['content'][:140] + + return result + +@webnotes.whitelist(allow_guest=True) +def add_comment(args=None): + """ + args = { + 'comment': '', + 'comment_by': '', + 'comment_by_fullname': '', + 'comment_doctype': '', + 'comment_docname': '', + 'page_name': '', + } + """ + import webnotes + import webnotes.utils, markdown2 + + if not args: args = webnotes.form_dict + args['comment'] = unicode(markdown2.markdown(args.get('comment') or '')) + args['doctype'] = "Comment" + + page_name = args.get("page_name") + if "page_name" in args: + del args["page_name"] + if "cmd" in args: + del args["cmd"] + + comment = webnotes.bean(args) + comment.ignore_permissions = True + comment.insert() + + # since comments are embedded in the page, clear the web cache + webnotes.webutils.clear_cache(page_name) + + args['comment_date'] = webnotes.utils.global_date_format(comment.doc.creation) + template_args = { 'comment_list': [args], 'template': 'app/website/templates/html/comment.html' } + + # get html of comment row + comment_html = webnotes.webutils.build_html(template_args) + + # notify commentors + commentors = [d[0] for d in webnotes.conn.sql("""select comment_by from tabComment where + comment_doctype='Blog Post' and comment_docname=%s and + ifnull(unsubscribed, 0)=0""", args.get('comment_docname'))] + + blog = webnotes.doc("Blog Post", args.get("comment_docname")) + blogger_profile = webnotes.conn.get_value("Blogger", blog.blogger, "profile") + blogger_email = webnotes.conn.get_value("Profile", blogger_profile, "email") + + from webnotes.utils.email_lib.bulk import send + send(recipients=list(set(commentors + [blogger_email])), + doctype='Comment', + email_field='comment_by', + subject='New Comment on Blog: ' + blog.title, + message='%(comment)s

By %(comment_by_fullname)s

' % args, + ref_doctype='Blog Post', ref_docname=blog.name) + + return comment_html.replace("\n", "") + +def get_blog_template_args(): + args = { + "categories": webnotes.conn.sql_list("select name from `tabBlog Category` order by name") + } + args.update(webnotes.doc("Blog Settings", "Blog Settings").fields) + return args diff --git a/website/doctype/blogger/blogger.py b/website/doctype/blogger/blogger.py index 9cb4a44448..fd646fded4 100644 --- a/website/doctype/blogger/blogger.py +++ b/website/doctype/blogger/blogger.py @@ -14,7 +14,7 @@ class DocType: def on_update(self): "if profile is set, then update all older blogs" - from website.helpers.blog import clear_blog_cache + from website.doctype.blog_post.blog_post import clear_blog_cache clear_blog_cache() if self.doc.profile: diff --git a/website/doctype/style_settings/style_settings.py b/website/doctype/style_settings/style_settings.py index 7efe86117b..073d3f9e23 100644 --- a/website/doctype/style_settings/style_settings.py +++ b/website/doctype/style_settings/style_settings.py @@ -94,5 +94,5 @@ class DocType: def on_update(self): """rebuild pages""" - from website.helpers.make_web_include_files import make + from website.doctype.website_settings.make_web_include_files import make make() \ No newline at end of file diff --git a/website/doctype/web_page/web_page.py b/website/doctype/web_page/web_page.py index dbcd68e24e..f0045fdda5 100644 --- a/website/doctype/web_page/web_page.py +++ b/website/doctype/web_page/web_page.py @@ -29,7 +29,7 @@ class DocType(): def prepare_template_args(self): if self.doc.slideshow: - from website.helpers.slideshow import get_slideshow + from website.doctype.website_slideshow.website_slideshow import get_slideshow get_slideshow(self) self.doc.meta_description = self.doc.description diff --git a/website/doctype/website_script/website_script.py b/website/doctype/website_script/website_script.py index 2a5b9e2f3a..c449df6271 100644 --- a/website/doctype/website_script/website_script.py +++ b/website/doctype/website_script/website_script.py @@ -12,5 +12,5 @@ class DocType: def on_update(self): # make js and css - from website.helpers.make_web_include_files import make + from website.doctype.website_settings.make_web_include_files import make make() \ No newline at end of file diff --git a/website/helpers/make_web_include_files.py b/website/doctype/website_settings/make_web_include_files.py similarity index 100% rename from website/helpers/make_web_include_files.py rename to website/doctype/website_settings/make_web_include_files.py diff --git a/website/doctype/website_settings/website_settings.py b/website/doctype/website_settings/website_settings.py index 5d6c874d70..135c7531b3 100644 --- a/website/doctype/website_settings/website_settings.py +++ b/website/doctype/website_settings/website_settings.py @@ -58,7 +58,7 @@ class DocType: def on_update(self): # make js and css - from website.helpers.make_web_include_files import make + from website.doctype.website_settings.make_web_include_files import make make() # clear web cache (for menus!) diff --git a/website/doctype/website_slideshow/website_slideshow.py b/website/doctype/website_slideshow/website_slideshow.py index 8bc0447ef0..eb7de7a33a 100644 --- a/website/doctype/website_slideshow/website_slideshow.py +++ b/website/doctype/website_slideshow/website_slideshow.py @@ -13,4 +13,9 @@ class DocType: def on_update(self): # a slide show can be in use and any change in it should get reflected from webnotes.webutils import clear_cache - clear_cache() \ No newline at end of file + clear_cache() + +def get_slideshow(obj): + slideshow = webnotes.bean("Website Slideshow", obj.doc.slideshow) + obj.slides = slideshow.doclist.get({"doctype":"Website Slideshow Item"}) + obj.doc.slideshow_header = slideshow.doc.header or "" \ No newline at end of file diff --git a/website/helpers/blog.py b/website/helpers/blog.py deleted file mode 100644 index 3f6d94fa6c..0000000000 --- a/website/helpers/blog.py +++ /dev/null @@ -1,121 +0,0 @@ -# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. -# License: GNU General Public License v3. See license.txt - -from __future__ import unicode_literals -import webnotes -import webnotes.webutils -from webnotes import _ - -def clear_blog_cache(): - for blog in webnotes.conn.sql_list("""select page_name from - `tabBlog Post` where ifnull(published,0)=1"""): - webnotes.webutils.delete_page_cache(blog) - - webnotes.webutils.delete_page_cache("writers") - -@webnotes.whitelist(allow_guest=True) -def get_blog_list(start=0, by=None, category=None): - import webnotes - condition = "" - if by: - condition = " and t1.blogger='%s'" % by.replace("'", "\'") - if category: - condition += " and t1.blog_category='%s'" % category.replace("'", "\'") - query = """\ - select - t1.title, t1.name, t1.page_name, t1.published_on as creation, - ifnull(t1.blog_intro, t1.content) as content, - t2.full_name, t2.avatar, t1.blogger, - (select count(name) from `tabComment` where - comment_doctype='Blog Post' and comment_docname=t1.name) as comments - from `tabBlog Post` t1, `tabBlogger` t2 - where ifnull(t1.published,0)=1 - and t1.blogger = t2.name - %(condition)s - order by published_on desc, name asc - limit %(start)s, 20""" % {"start": start, "condition": condition} - - result = webnotes.conn.sql(query, as_dict=1) - - # strip html tags from content - import webnotes.utils - - for res in result: - from webnotes.utils import global_date_format - res['published'] = global_date_format(res['creation']) - if not res['content']: - res['content'] = webnotes.webutils.get_html(res['page_name']) - res['content'] = res['content'][:140] - - return result - -@webnotes.whitelist(allow_guest=True) -def add_comment(args=None): - """ - args = { - 'comment': '', - 'comment_by': '', - 'comment_by_fullname': '', - 'comment_doctype': '', - 'comment_docname': '', - 'page_name': '', - } - """ - import webnotes - import webnotes.utils, markdown2 - - if not args: args = webnotes.form_dict - args['comment'] = unicode(markdown2.markdown(args.get('comment') or '')) - args['doctype'] = "Comment" - - page_name = args.get("page_name") - if "page_name" in args: - del args["page_name"] - if "cmd" in args: - del args["cmd"] - - comment = webnotes.bean(args) - comment.ignore_permissions = True - comment.insert() - - # since comments are embedded in the page, clear the web cache - webnotes.webutils.clear_cache(page_name) - - args['comment_date'] = webnotes.utils.global_date_format(comment.doc.creation) - template_args = { 'comment_list': [args], 'template': 'app/website/templates/html/comment.html' } - - # get html of comment row - comment_html = webnotes.webutils.build_html(template_args) - - # notify commentors - commentors = [d[0] for d in webnotes.conn.sql("""select comment_by from tabComment where - comment_doctype='Blog Post' and comment_docname=%s and - ifnull(unsubscribed, 0)=0""", args.get('comment_docname'))] - - blog = webnotes.doc("Blog Post", args.get("comment_docname")) - blogger_profile = webnotes.conn.get_value("Blogger", blog.blogger, "profile") - blogger_email = webnotes.conn.get_value("Profile", blogger_profile, "email") - - from webnotes.utils.email_lib.bulk import send - send(recipients=list(set(commentors + [blogger_email])), - doctype='Comment', - email_field='comment_by', - subject='New Comment on Blog: ' + blog.title, - message='%(comment)s

By %(comment_by_fullname)s

' % args, - ref_doctype='Blog Post', ref_docname=blog.name) - - return comment_html.replace("\n", "") - -def get_blog_content(blog_page_name): - import webnotes.webutils - content = webnotes.webutils.get_html(blog_page_name) - import webnotes.utils - content = webnotes.utils.escape_html(content) - return content - -def get_blog_template_args(): - args = { - "categories": webnotes.conn.sql_list("select name from `tabBlog Category` order by name") - } - args.update(webnotes.doc("Blog Settings", "Blog Settings").fields) - return args diff --git a/website/helpers/partner.py b/website/helpers/partner.py deleted file mode 100644 index 404894e53c..0000000000 --- a/website/helpers/partner.py +++ /dev/null @@ -1,11 +0,0 @@ -# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. -# License: GNU General Public License v3. See license.txt - -from __future__ import unicode_literals -import webnotes - -def get_partner_args(): - return { - "partners": webnotes.conn.sql("""select * from `tabSales Partner` - where show_in_website=1 order by name asc""", as_dict=True), - } \ No newline at end of file diff --git a/website/helpers/slideshow.py b/website/helpers/slideshow.py deleted file mode 100644 index 7e3c398bf4..0000000000 --- a/website/helpers/slideshow.py +++ /dev/null @@ -1,10 +0,0 @@ -# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. -# License: GNU General Public License v3. See license.txt - -import webnotes - -def get_slideshow(obj): - slideshow = webnotes.bean("Website Slideshow", obj.doc.slideshow) - obj.slides = slideshow.doclist.get({"doctype":"Website Slideshow Item"}) - obj.doc.slideshow_header = slideshow.doc.header or "" - \ No newline at end of file diff --git a/website/templates/js/blog.js b/website/templates/js/blog.js index 8134b635d1..d5e9d5081b 100644 --- a/website/templates/js/blog.js +++ b/website/templates/js/blog.js @@ -28,7 +28,7 @@ var blog = { method: "GET", url: "server.py", data: { - cmd: "website.helpers.blog.get_blog_list", + cmd: "website.doctype.blog_post.blog_post.get_blog_list", start: blog.start, by: get_url_arg("by"), category: get_url_arg("category") diff --git a/website/templates/js/blog_page.js b/website/templates/js/blog_page.js index ee56d9087b..665dbf4e03 100644 --- a/website/templates/js/blog_page.js +++ b/website/templates/js/blog_page.js @@ -22,7 +22,7 @@ $(document).ready(function() { comment_by_fullname: $("[name='comment_by_fullname']").val(), comment_by: $("[name='comment_by']").val(), comment: $("[name='comment']").val(), - cmd: "website.helpers.blog.add_comment", + cmd: "website.doctype.blog_post.blog_post.add_comment", comment_doctype: "Blog Post", comment_docname: "{{ name }}", page_name: "{{ page_name }}", From c59c4e069932849edb1cd6e1fa1aefe847d1525c Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Mon, 9 Sep 2013 12:17:45 +0530 Subject: [PATCH 02/37] [website] [minor] moving to framework --- config.json | 14 ++++----- patches/patch_list.py | 1 + .../p03_move_website_to_framework.py | 17 ++++++++++ public/js/website_utils.js | 4 +-- selling/{utils.py => utils/__init__.py} | 0 {website/helpers => selling/utils}/cart.py | 0 {website/helpers => selling/utils}/contact.py | 0 {website/helpers => selling/utils}/product.py | 2 +- setup/doctype/item_group/item_group.py | 4 +-- .../templates}/partner_page.html | 0 .../sales_partner/templates}/partners.html | 0 startup/event_handlers.py | 2 +- startup/webutils.py | 4 +-- stock/doctype/item/item.py | 4 +-- .../includes}/product_breadcrumbs.html | 0 .../templates/includes}/product_in_grid.html | 0 .../templates/includes}/product_in_list.html | 0 .../includes}/product_missing_image.html | 0 .../includes}/product_search_box.html | 0 .../item/templates}/product_group.html | 0 .../doctype/item/templates}/product_page.html | 0 .../item/templates}/product_search.html | 0 .../support_ticket/templates}/ticket.html | 0 .../support_ticket/templates}/tickets.html | 0 utilities/demo/demo_control_panel.py | 2 +- .../website_transactions.py | 8 ++--- .../blog_post/templates}/blog.html | 0 .../blog_post/templates/blog_post.html} | 0 .../templates/includes}/blog_footer.html | 0 .../templates/includes}/blog_subscribe.html | 0 .../templates/includes}/blogger.html | 0 .../templates/includes}/comment.html | 0 .../blogger/templates}/writers.html | 0 website/templates/js/blog_page.js | 1 + website/templates/js/cart.js | 8 ++--- website/templates/js/product_list.js | 2 +- website/templates/js/product_page.js | 2 +- website/templates/pages/address.html | 2 +- website/templates/pages/addresses.html | 2 +- website/templates/pages/messages.html | 31 ------------------- 40 files changed, 49 insertions(+), 61 deletions(-) create mode 100644 patches/september_2013/p03_move_website_to_framework.py rename selling/{utils.py => utils/__init__.py} (100%) rename {website/helpers => selling/utils}/cart.py (100%) rename {website/helpers => selling/utils}/contact.py (100%) rename {website/helpers => selling/utils}/product.py (98%) rename {website/templates/html => setup/doctype/sales_partner/templates}/partner_page.html (100%) rename {website/templates/pages => setup/doctype/sales_partner/templates}/partners.html (100%) rename {website/templates/html => stock/doctype/item/templates/includes}/product_breadcrumbs.html (100%) rename {website/templates/html => stock/doctype/item/templates/includes}/product_in_grid.html (100%) rename {website/templates/html => stock/doctype/item/templates/includes}/product_in_list.html (100%) rename {website/templates/html => stock/doctype/item/templates/includes}/product_missing_image.html (100%) rename {website/templates/html => stock/doctype/item/templates/includes}/product_search_box.html (100%) rename {website/templates/html => stock/doctype/item/templates}/product_group.html (100%) rename {website/templates/html => stock/doctype/item/templates}/product_page.html (100%) rename {website/templates/pages => stock/doctype/item/templates}/product_search.html (100%) rename {website/templates/pages => support/doctype/support_ticket/templates}/ticket.html (100%) rename {website/templates/pages => support/doctype/support_ticket/templates}/tickets.html (100%) rename website/helpers/transaction.py => utilities/website_transactions.py (93%) rename website/{templates/pages => doctype/blog_post/templates}/blog.html (100%) rename website/{templates/html/blog_page.html => doctype/blog_post/templates/blog_post.html} (100%) rename website/{templates/html => doctype/blog_post/templates/includes}/blog_footer.html (100%) rename website/{templates/html => doctype/blog_post/templates/includes}/blog_subscribe.html (100%) rename website/{templates/html => doctype/blog_post/templates/includes}/blogger.html (100%) rename website/{templates/html => doctype/blog_post/templates/includes}/comment.html (100%) rename website/{templates/pages => doctype/blogger/templates}/writers.html (100%) delete mode 100644 website/templates/pages/messages.html diff --git a/config.json b/config.json index 19f787e374..76ab832280 100644 --- a/config.json +++ b/config.json @@ -102,7 +102,7 @@ "order": { "no_cache": true, "template": "app/website/templates/pages/sale", - "args_method": "website.helpers.transaction.get_order_args", + "args_method": "utilities.website_transactions.get_order_args", "portal": { "doctype": "Sales Order", "conditions": { @@ -113,12 +113,12 @@ "orders": { "no_cache": true, "template": "app/website/templates/pages/sales_transactions", - "args_method": "website.helpers.transaction.order_list_args" + "args_method": "utilities.website_transactions.order_list_args" }, "invoice": { "no_cache": true, "template": "app/website/templates/pages/sale", - "args_method": "website.helpers.transaction.get_invoice_args", + "args_method": "utilities.website_transactions.get_invoice_args", "portal": { "doctype": "Sales Invoice", "conditions": { @@ -129,12 +129,12 @@ "invoices": { "no_cache": true, "template": "app/website/templates/pages/sales_transactions", - "args_method": "website.helpers.transaction.invoice_list_args" + "args_method": "utilities.website_transactions.invoice_list_args" }, "shipment": { "no_cache": true, "template": "app/website/templates/pages/sale", - "args_method": "website.helpers.transaction.get_shipment_args", + "args_method": "utilities.website_transactions.get_shipment_args", "portal": { "doctype": "Delivery Note", "conditions": { @@ -145,7 +145,7 @@ "shipments": { "no_cache": true, "template": "app/website/templates/pages/sales_transactions", - "args_method": "website.helpers.transaction.shipment_list_args" + "args_method": "utilities.website_transactions.shipment_list_args" }, "product_search": { "template": "app/website/templates/pages/product_search" @@ -160,7 +160,7 @@ }, "tickets": { "template": "app/website/templates/pages/tickets", - "args_method": "website.helpers.transaction.ticket_list_args" + "args_method": "utilities.website_transactions.ticket_list_args" }, "address": { "no_cache": true, diff --git a/patches/patch_list.py b/patches/patch_list.py index 3c13e0eb47..68bb005760 100644 --- a/patches/patch_list.py +++ b/patches/patch_list.py @@ -263,4 +263,5 @@ patch_list = [ "patches.september_2013.p01_update_communication", "execute:webnotes.reload_doc('setup', 'doctype', 'features_setup') # 2013-09-05", "patches.september_2013.p02_fix_serial_no_status", + "patches.september_2013.p03_move_website_to_framework" ] \ No newline at end of file diff --git a/patches/september_2013/p03_move_website_to_framework.py b/patches/september_2013/p03_move_website_to_framework.py new file mode 100644 index 0000000000..69bd505456 --- /dev/null +++ b/patches/september_2013/p03_move_website_to_framework.py @@ -0,0 +1,17 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. +# License: GNU General Public License v3. See license.txt + +from __future__ import unicode_literals +import webnotes +from webnotes.utils import get_base_path +import os + +def execute(): + # remove pyc files + utils_pyc = os.path.join(get_base_path(), "app", "selling", "utils.pyc") + if os.path.exists(utils_pyc): + print exists + os.remove(utils_pyc) + + # TODO remove website folder + \ No newline at end of file diff --git a/public/js/website_utils.js b/public/js/website_utils.js index 9b7832678a..b5fea13bbe 100644 --- a/public/js/website_utils.js +++ b/public/js/website_utils.js @@ -9,7 +9,7 @@ if(!window.wn) wn = {}; erpnext.send_message = function(opts) { return wn.call({ type: "POST", - method: "website.helpers.contact.send_message", + method: "selling.utils.contact.send_message", args: opts, callback: opts.callback }); @@ -206,7 +206,7 @@ $.extend(wn.cart, { } else { return wn.call({ type: "POST", - method: "website.helpers.cart.update_cart", + method: "selling.utils.cart.update_cart", args: { item_code: opts.item_code, qty: opts.qty, diff --git a/selling/utils.py b/selling/utils/__init__.py similarity index 100% rename from selling/utils.py rename to selling/utils/__init__.py diff --git a/website/helpers/cart.py b/selling/utils/cart.py similarity index 100% rename from website/helpers/cart.py rename to selling/utils/cart.py diff --git a/website/helpers/contact.py b/selling/utils/contact.py similarity index 100% rename from website/helpers/contact.py rename to selling/utils/contact.py diff --git a/website/helpers/product.py b/selling/utils/product.py similarity index 98% rename from website/helpers/product.py rename to selling/utils/product.py index 031339ab31..fb0605e51d 100644 --- a/website/helpers/product.py +++ b/selling/utils/product.py @@ -6,7 +6,7 @@ from __future__ import unicode_literals import webnotes from webnotes.utils import cstr, cint, fmt_money from webnotes.webutils import build_html, delete_page_cache -from website.helpers.cart import _get_cart_quotation +from selling.utils.cart import _get_cart_quotation @webnotes.whitelist(allow_guest=True) def get_product_info(item_code): diff --git a/setup/doctype/item_group/item_group.py b/setup/doctype/item_group/item_group.py index e2eb5e91c4..ccc6c29061 100644 --- a/setup/doctype/item_group/item_group.py +++ b/setup/doctype/item_group/item_group.py @@ -18,7 +18,7 @@ class DocType(DocTypeNestedSet): self.validate_name_with_item() - from website.helpers.product import invalidate_cache_for + from selling.utils.product import invalidate_cache_for if self.doc.show_in_website: from webnotes.webutils import update_page_name @@ -45,7 +45,7 @@ class DocType(DocTypeNestedSet): item group name or rename the item" % self.doc.name, raise_exception=1) def prepare_template_args(self): - from website.helpers.product import get_product_list_for_group, \ + from selling.utils.product import get_product_list_for_group, \ get_parent_item_groups, get_group_item_count self.doc.sub_groups = webnotes.conn.sql("""select name, page_name diff --git a/website/templates/html/partner_page.html b/setup/doctype/sales_partner/templates/partner_page.html similarity index 100% rename from website/templates/html/partner_page.html rename to setup/doctype/sales_partner/templates/partner_page.html diff --git a/website/templates/pages/partners.html b/setup/doctype/sales_partner/templates/partners.html similarity index 100% rename from website/templates/pages/partners.html rename to setup/doctype/sales_partner/templates/partners.html diff --git a/startup/event_handlers.py b/startup/event_handlers.py index 84a91a4491..57345f3ca0 100644 --- a/startup/event_handlers.py +++ b/startup/event_handlers.py @@ -31,7 +31,7 @@ def on_login_post_session(login_manager): webnotes.conn.commit() if webnotes.conn.get_value("Profile", webnotes.session.user, "user_type") == "Website User": - from website.helpers.cart import set_cart_count + from selling.utils.cart import set_cart_count set_cart_count() def on_logout(login_manager): diff --git a/startup/webutils.py b/startup/webutils.py index eab4948dd3..b9b6182408 100644 --- a/startup/webutils.py +++ b/startup/webutils.py @@ -71,14 +71,14 @@ def update_template_args(page_name, args): @webnotes.whitelist() def update_profile(fullname, password=None, company_name=None, mobile_no=None, phone=None): - from website.helpers.cart import update_party + from selling.utils.cart import update_party update_party(fullname, company_name, mobile_no, phone) from core.doctype.profile import profile return profile.update_profile(fullname, password) def get_profile_args(): - from website.helpers.cart import get_lead_or_customer + from selling.utils.cart import get_lead_or_customer party = get_lead_or_customer() if party.doctype == "Lead": mobile_no = party.mobile_no diff --git a/stock/doctype/item/item.py b/stock/doctype/item/item.py index dab7dea044..f6f8d516af 100644 --- a/stock/doctype/item/item.py +++ b/stock/doctype/item/item.py @@ -228,7 +228,7 @@ class DocType(DocListController): def update_website(self): def _invalidate_cache(): - from website.helpers.product import invalidate_cache_for + from selling.utils.product import invalidate_cache_for invalidate_cache_for(self.doc.item_group) @@ -259,7 +259,7 @@ class DocType(DocListController): return { "tax_rate": webnotes.conn.get_value("Account", tax_type, "tax_rate") } def prepare_template_args(self): - from website.helpers.product import get_parent_item_groups + from selling.utils.product import get_parent_item_groups self.parent_groups = get_parent_item_groups(self.doc.item_group) + [{"name":self.doc.name}] self.doc.title = self.doc.item_name diff --git a/website/templates/html/product_breadcrumbs.html b/stock/doctype/item/templates/includes/product_breadcrumbs.html similarity index 100% rename from website/templates/html/product_breadcrumbs.html rename to stock/doctype/item/templates/includes/product_breadcrumbs.html diff --git a/website/templates/html/product_in_grid.html b/stock/doctype/item/templates/includes/product_in_grid.html similarity index 100% rename from website/templates/html/product_in_grid.html rename to stock/doctype/item/templates/includes/product_in_grid.html diff --git a/website/templates/html/product_in_list.html b/stock/doctype/item/templates/includes/product_in_list.html similarity index 100% rename from website/templates/html/product_in_list.html rename to stock/doctype/item/templates/includes/product_in_list.html diff --git a/website/templates/html/product_missing_image.html b/stock/doctype/item/templates/includes/product_missing_image.html similarity index 100% rename from website/templates/html/product_missing_image.html rename to stock/doctype/item/templates/includes/product_missing_image.html diff --git a/website/templates/html/product_search_box.html b/stock/doctype/item/templates/includes/product_search_box.html similarity index 100% rename from website/templates/html/product_search_box.html rename to stock/doctype/item/templates/includes/product_search_box.html diff --git a/website/templates/html/product_group.html b/stock/doctype/item/templates/product_group.html similarity index 100% rename from website/templates/html/product_group.html rename to stock/doctype/item/templates/product_group.html diff --git a/website/templates/html/product_page.html b/stock/doctype/item/templates/product_page.html similarity index 100% rename from website/templates/html/product_page.html rename to stock/doctype/item/templates/product_page.html diff --git a/website/templates/pages/product_search.html b/stock/doctype/item/templates/product_search.html similarity index 100% rename from website/templates/pages/product_search.html rename to stock/doctype/item/templates/product_search.html diff --git a/website/templates/pages/ticket.html b/support/doctype/support_ticket/templates/ticket.html similarity index 100% rename from website/templates/pages/ticket.html rename to support/doctype/support_ticket/templates/ticket.html diff --git a/website/templates/pages/tickets.html b/support/doctype/support_ticket/templates/tickets.html similarity index 100% rename from website/templates/pages/tickets.html rename to support/doctype/support_ticket/templates/tickets.html diff --git a/utilities/demo/demo_control_panel.py b/utilities/demo/demo_control_panel.py index c70913ee68..a1113ae609 100644 --- a/utilities/demo/demo_control_panel.py +++ b/utilities/demo/demo_control_panel.py @@ -6,7 +6,7 @@ if webnotes.form_dict.lead_email and validate_email_add(webnotes.form_dict.lead_email): import requests response = requests.post(conf.demo_notify_url, data={ - "cmd":"website.helpers.contact.send_message", + "cmd":"selling.utils.contact.send_message", "subject":"Logged into Demo", "sender": webnotes.form_dict.lead_email, "message": "via demo.erpnext.com" diff --git a/website/helpers/transaction.py b/utilities/website_transactions.py similarity index 93% rename from website/helpers/transaction.py rename to utilities/website_transactions.py index 8943575c6c..f8710968fb 100644 --- a/website/helpers/transaction.py +++ b/utilities/website_transactions.py @@ -40,7 +40,7 @@ def order_list_args(): args = get_common_args() args.update({ "title": "My Orders", - "method": "website.helpers.transaction.get_orders", + "method": "utilities.website_transactions.get_orders", "icon": "icon-list", "empty_list_message": "No Orders Yet", "page": "order", @@ -55,7 +55,7 @@ def invoice_list_args(): args = get_common_args() args.update({ "title": "Invoices", - "method": "website.helpers.transaction.get_invoices", + "method": "utilities.website_transactions.get_invoices", "icon": "icon-file-text", "empty_list_message": "No Invoices Found", "page": "invoice" @@ -70,7 +70,7 @@ def shipment_list_args(): args = get_common_args() args.update({ "title": "Shipments", - "method": "website.helpers.transaction.get_shipments", + "method": "utilities.website_transactions.get_shipments", "icon": "icon-truck", "empty_list_message": "No Shipments Found", "page": "shipment" @@ -91,7 +91,7 @@ def get_tickets(start=0): def ticket_list_args(): return { "title": "My Tickets", - "method": "website.helpers.transaction.get_tickets", + "method": "utilities.website_transactions.get_tickets", "icon": "icon-ticket", "empty_list_message": "No Tickets Raised", "page": "ticket" diff --git a/website/templates/pages/blog.html b/website/doctype/blog_post/templates/blog.html similarity index 100% rename from website/templates/pages/blog.html rename to website/doctype/blog_post/templates/blog.html diff --git a/website/templates/html/blog_page.html b/website/doctype/blog_post/templates/blog_post.html similarity index 100% rename from website/templates/html/blog_page.html rename to website/doctype/blog_post/templates/blog_post.html diff --git a/website/templates/html/blog_footer.html b/website/doctype/blog_post/templates/includes/blog_footer.html similarity index 100% rename from website/templates/html/blog_footer.html rename to website/doctype/blog_post/templates/includes/blog_footer.html diff --git a/website/templates/html/blog_subscribe.html b/website/doctype/blog_post/templates/includes/blog_subscribe.html similarity index 100% rename from website/templates/html/blog_subscribe.html rename to website/doctype/blog_post/templates/includes/blog_subscribe.html diff --git a/website/templates/html/blogger.html b/website/doctype/blog_post/templates/includes/blogger.html similarity index 100% rename from website/templates/html/blogger.html rename to website/doctype/blog_post/templates/includes/blogger.html diff --git a/website/templates/html/comment.html b/website/doctype/blog_post/templates/includes/comment.html similarity index 100% rename from website/templates/html/comment.html rename to website/doctype/blog_post/templates/includes/comment.html diff --git a/website/templates/pages/writers.html b/website/doctype/blogger/templates/writers.html similarity index 100% rename from website/templates/pages/writers.html rename to website/doctype/blogger/templates/writers.html diff --git a/website/templates/js/blog_page.js b/website/templates/js/blog_page.js index 665dbf4e03..3d45925da0 100644 --- a/website/templates/js/blog_page.js +++ b/website/templates/js/blog_page.js @@ -14,6 +14,7 @@ $(document).ready(function() { .parent().append("
Comments are closed.
") } $(".add-comment").click(function() { + $(this).toggle(false); $("#comment-form").toggle(); $("#comment-form input, #comment-form, textarea").val(""); }) diff --git a/website/templates/js/cart.js b/website/templates/js/cart.js index 20090caec6..63c6463ac4 100644 --- a/website/templates/js/cart.js +++ b/website/templates/js/cart.js @@ -7,7 +7,7 @@ $(document).ready(function() { wn.cart.bind_events(); return wn.call({ type: "POST", - method: "website.helpers.cart.get_cart_quotation", + method: "selling.utils.cart.get_cart_quotation", callback: function(r) { console.log(r); $("#cart-container").removeClass("hide"); @@ -194,7 +194,7 @@ $.extend(wn.cart, { return wn.call({ btn: btn, type: "POST", - method: "website.helpers.cart.apply_shipping_rule", + method: "selling.utils.cart.apply_shipping_rule", args: { shipping_rule: rule }, callback: function(r) { if(!r.exc) { @@ -242,7 +242,7 @@ $.extend(wn.cart, { return wn.call({ type: "POST", - method: "website.helpers.cart.update_cart_address", + method: "selling.utils.cart.update_cart_address", args: { address_fieldname: $address_wrapper.attr("data-fieldname"), address_name: $(this).attr("data-address-name") @@ -273,7 +273,7 @@ $.extend(wn.cart, { place_order: function() { return wn.call({ type: "POST", - method: "website.helpers.cart.place_order", + method: "selling.utils.cart.place_order", callback: function(r) { if(r.exc) { var msg = ""; diff --git a/website/templates/js/product_list.js b/website/templates/js/product_list.js index 729499c0c7..2856bde3d7 100644 --- a/website/templates/js/product_list.js +++ b/website/templates/js/product_list.js @@ -15,7 +15,7 @@ window.get_product_list = function() { url: "server.py", dataType: "json", data: { - cmd: "website.helpers.product.get_product_list", + cmd: "selling.utils.product.get_product_list", start: window.start, search: window.search, product_group: window.product_group diff --git a/website/templates/js/product_page.js b/website/templates/js/product_page.js index b8c65ec87f..b2a122ec82 100644 --- a/website/templates/js/product_page.js +++ b/website/templates/js/product_page.js @@ -7,7 +7,7 @@ $(document).ready(function() { wn.call({ type: "POST", - method: "website.helpers.product.get_product_info", + method: "selling.utils.product.get_product_info", args: { item_code: "{{ name }}" }, diff --git a/website/templates/pages/address.html b/website/templates/pages/address.html index 6544b1225d..6d4273c3a5 100644 --- a/website/templates/pages/address.html +++ b/website/templates/pages/address.html @@ -89,7 +89,7 @@ wn.call({ btn: $(this), type: "POST", - method: "website.helpers.cart.save_address", + method: "selling.utils.cart.save_address", args: { fields: fields, address_fieldname: get_url_arg("address_fieldname") }, callback: function(r) { if(r.exc) { diff --git a/website/templates/pages/addresses.html b/website/templates/pages/addresses.html index 04fc47ba73..b19780ae38 100644 --- a/website/templates/pages/addresses.html +++ b/website/templates/pages/addresses.html @@ -26,7 +26,7 @@ var fetch_addresses = function() { wn.call({ - method: "website.helpers.cart.get_addresses", + method: "selling.utils.cart.get_addresses", callback: function(r) { $("#address-list .progress").remove(); var $list = $("#address-list"); diff --git a/website/templates/pages/messages.html b/website/templates/pages/messages.html deleted file mode 100644 index e1ea8d0fe3..0000000000 --- a/website/templates/pages/messages.html +++ /dev/null @@ -1,31 +0,0 @@ -{% extends "app/website/templates/html/transactions.html" %} - -{% block javascript -%} -{{ super() }} - -var render = function(doc) { - doc.sender = doc.sender ? doc.sender : "To "; - doc.recipients = doc.recipients ? (" to " + doc.recipients) : ""; - doc.content = remove_script_and_style(doc.content); - - if(!is_html(doc.content)) { - doc.content = doc.content.replace("\n", "
"); - } - - $(repl('\ -
%(subject)s
\ -
\ -
%(sender)s%(recipients)s
\ -
%(creation)s
\ -
\ - \ -
', doc)) - .appendTo($list) - .on("click", function() { - $(this).find(".msg-content").toggle(); - }); - - -} - -{%- endblock %} \ No newline at end of file From e865de01eeba3cb96f9cd788bdf338983404a0be Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Mon, 9 Sep 2013 12:32:35 +0530 Subject: [PATCH 03/37] [website] [minor] moving to framework --- {website/templates/pages => portal/templates}/account.html | 0 {website/templates/pages => portal/templates}/cart.html | 0 {website/templates/js => portal/templates/includes}/cart.js | 0 .../html => portal/templates/includes}/transactions.html | 0 {website/templates/pages => portal/templates}/invoice.html | 0 {website/templates/pages => portal/templates}/profile.html | 0 {website/templates/pages => portal/templates}/sale.html | 0 .../templates/pages => portal/templates}/sales_transactions.html | 0 .../templates/pages => portal/templates}/transaction_list.html | 0 .../js => stock/doctype/item/templates/includes}/product_list.js | 0 .../doctype/item/templates/includes}/product_page.css | 0 .../js => stock/doctype/item/templates/includes}/product_page.js | 0 .../pages => utilities/doctype/address/templates}/address.html | 0 .../pages => utilities/doctype/address/templates}/addresses.html | 0 .../pages => doctype/about_us_settings/templates}/about.html | 0 .../css => doctype/blog_post/templates/includes}/blog.css | 0 .../js => doctype/blog_post/templates/includes}/blog.js | 0 .../css => doctype/blog_post/templates/includes}/blog_page.css | 0 .../js => doctype/blog_post/templates/includes}/blog_page.js | 0 .../pages => doctype/contact_us_settings/templates}/contact.html | 0 .../contact_us_settings/templates/includes}/contact.js | 0 .../{templates/pages => doctype/web_page/templates}/index.html | 0 .../{templates/html => doctype/web_page/templates}/web_page.html | 0 .../website_slideshow/templates/includes}/slideshow.html | 0 website/templates/{html => includes}/footer.html | 0 website/templates/{html => includes}/navbar.html | 0 website/templates/{html => includes}/outer.html | 0 website/templates/{html => includes}/page.html | 0 28 files changed, 0 insertions(+), 0 deletions(-) rename {website/templates/pages => portal/templates}/account.html (100%) rename {website/templates/pages => portal/templates}/cart.html (100%) rename {website/templates/js => portal/templates/includes}/cart.js (100%) rename {website/templates/html => portal/templates/includes}/transactions.html (100%) rename {website/templates/pages => portal/templates}/invoice.html (100%) rename {website/templates/pages => portal/templates}/profile.html (100%) rename {website/templates/pages => portal/templates}/sale.html (100%) rename {website/templates/pages => portal/templates}/sales_transactions.html (100%) rename {website/templates/pages => portal/templates}/transaction_list.html (100%) rename {website/templates/js => stock/doctype/item/templates/includes}/product_list.js (100%) rename {website/templates/css => stock/doctype/item/templates/includes}/product_page.css (100%) rename {website/templates/js => stock/doctype/item/templates/includes}/product_page.js (100%) rename {website/templates/pages => utilities/doctype/address/templates}/address.html (100%) rename {website/templates/pages => utilities/doctype/address/templates}/addresses.html (100%) rename website/{templates/pages => doctype/about_us_settings/templates}/about.html (100%) rename website/{templates/css => doctype/blog_post/templates/includes}/blog.css (100%) rename website/{templates/js => doctype/blog_post/templates/includes}/blog.js (100%) rename website/{templates/css => doctype/blog_post/templates/includes}/blog_page.css (100%) rename website/{templates/js => doctype/blog_post/templates/includes}/blog_page.js (100%) rename website/{templates/pages => doctype/contact_us_settings/templates}/contact.html (100%) rename website/{templates/js => doctype/contact_us_settings/templates/includes}/contact.js (100%) rename website/{templates/pages => doctype/web_page/templates}/index.html (100%) rename website/{templates/html => doctype/web_page/templates}/web_page.html (100%) rename website/{templates/html => doctype/website_slideshow/templates/includes}/slideshow.html (100%) rename website/templates/{html => includes}/footer.html (100%) rename website/templates/{html => includes}/navbar.html (100%) rename website/templates/{html => includes}/outer.html (100%) rename website/templates/{html => includes}/page.html (100%) diff --git a/website/templates/pages/account.html b/portal/templates/account.html similarity index 100% rename from website/templates/pages/account.html rename to portal/templates/account.html diff --git a/website/templates/pages/cart.html b/portal/templates/cart.html similarity index 100% rename from website/templates/pages/cart.html rename to portal/templates/cart.html diff --git a/website/templates/js/cart.js b/portal/templates/includes/cart.js similarity index 100% rename from website/templates/js/cart.js rename to portal/templates/includes/cart.js diff --git a/website/templates/html/transactions.html b/portal/templates/includes/transactions.html similarity index 100% rename from website/templates/html/transactions.html rename to portal/templates/includes/transactions.html diff --git a/website/templates/pages/invoice.html b/portal/templates/invoice.html similarity index 100% rename from website/templates/pages/invoice.html rename to portal/templates/invoice.html diff --git a/website/templates/pages/profile.html b/portal/templates/profile.html similarity index 100% rename from website/templates/pages/profile.html rename to portal/templates/profile.html diff --git a/website/templates/pages/sale.html b/portal/templates/sale.html similarity index 100% rename from website/templates/pages/sale.html rename to portal/templates/sale.html diff --git a/website/templates/pages/sales_transactions.html b/portal/templates/sales_transactions.html similarity index 100% rename from website/templates/pages/sales_transactions.html rename to portal/templates/sales_transactions.html diff --git a/website/templates/pages/transaction_list.html b/portal/templates/transaction_list.html similarity index 100% rename from website/templates/pages/transaction_list.html rename to portal/templates/transaction_list.html diff --git a/website/templates/js/product_list.js b/stock/doctype/item/templates/includes/product_list.js similarity index 100% rename from website/templates/js/product_list.js rename to stock/doctype/item/templates/includes/product_list.js diff --git a/website/templates/css/product_page.css b/stock/doctype/item/templates/includes/product_page.css similarity index 100% rename from website/templates/css/product_page.css rename to stock/doctype/item/templates/includes/product_page.css diff --git a/website/templates/js/product_page.js b/stock/doctype/item/templates/includes/product_page.js similarity index 100% rename from website/templates/js/product_page.js rename to stock/doctype/item/templates/includes/product_page.js diff --git a/website/templates/pages/address.html b/utilities/doctype/address/templates/address.html similarity index 100% rename from website/templates/pages/address.html rename to utilities/doctype/address/templates/address.html diff --git a/website/templates/pages/addresses.html b/utilities/doctype/address/templates/addresses.html similarity index 100% rename from website/templates/pages/addresses.html rename to utilities/doctype/address/templates/addresses.html diff --git a/website/templates/pages/about.html b/website/doctype/about_us_settings/templates/about.html similarity index 100% rename from website/templates/pages/about.html rename to website/doctype/about_us_settings/templates/about.html diff --git a/website/templates/css/blog.css b/website/doctype/blog_post/templates/includes/blog.css similarity index 100% rename from website/templates/css/blog.css rename to website/doctype/blog_post/templates/includes/blog.css diff --git a/website/templates/js/blog.js b/website/doctype/blog_post/templates/includes/blog.js similarity index 100% rename from website/templates/js/blog.js rename to website/doctype/blog_post/templates/includes/blog.js diff --git a/website/templates/css/blog_page.css b/website/doctype/blog_post/templates/includes/blog_page.css similarity index 100% rename from website/templates/css/blog_page.css rename to website/doctype/blog_post/templates/includes/blog_page.css diff --git a/website/templates/js/blog_page.js b/website/doctype/blog_post/templates/includes/blog_page.js similarity index 100% rename from website/templates/js/blog_page.js rename to website/doctype/blog_post/templates/includes/blog_page.js diff --git a/website/templates/pages/contact.html b/website/doctype/contact_us_settings/templates/contact.html similarity index 100% rename from website/templates/pages/contact.html rename to website/doctype/contact_us_settings/templates/contact.html diff --git a/website/templates/js/contact.js b/website/doctype/contact_us_settings/templates/includes/contact.js similarity index 100% rename from website/templates/js/contact.js rename to website/doctype/contact_us_settings/templates/includes/contact.js diff --git a/website/templates/pages/index.html b/website/doctype/web_page/templates/index.html similarity index 100% rename from website/templates/pages/index.html rename to website/doctype/web_page/templates/index.html diff --git a/website/templates/html/web_page.html b/website/doctype/web_page/templates/web_page.html similarity index 100% rename from website/templates/html/web_page.html rename to website/doctype/web_page/templates/web_page.html diff --git a/website/templates/html/slideshow.html b/website/doctype/website_slideshow/templates/includes/slideshow.html similarity index 100% rename from website/templates/html/slideshow.html rename to website/doctype/website_slideshow/templates/includes/slideshow.html diff --git a/website/templates/html/footer.html b/website/templates/includes/footer.html similarity index 100% rename from website/templates/html/footer.html rename to website/templates/includes/footer.html diff --git a/website/templates/html/navbar.html b/website/templates/includes/navbar.html similarity index 100% rename from website/templates/html/navbar.html rename to website/templates/includes/navbar.html diff --git a/website/templates/html/outer.html b/website/templates/includes/outer.html similarity index 100% rename from website/templates/html/outer.html rename to website/templates/includes/outer.html diff --git a/website/templates/html/page.html b/website/templates/includes/page.html similarity index 100% rename from website/templates/html/page.html rename to website/templates/includes/page.html From 6035165b691c7d5abcfe00b672c0b12713f4b86b Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Mon, 9 Sep 2013 12:42:37 +0530 Subject: [PATCH 04/37] [website] [minor] moving to framework --- website/helpers/__init__.py | 0 website/{helpers => }/sitemap.py | 0 2 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 website/helpers/__init__.py rename website/{helpers => }/sitemap.py (100%) diff --git a/website/helpers/__init__.py b/website/helpers/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/website/helpers/sitemap.py b/website/sitemap.py similarity index 100% rename from website/helpers/sitemap.py rename to website/sitemap.py From bb4c6eb630268fa949017884946e6fa8f5ade0ae Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Mon, 9 Sep 2013 12:46:34 +0530 Subject: [PATCH 05/37] [website] [minor] moving to framework --- website/README.md | 8 - website/__init__.py | 20 -- website/css/website.css | 204 -------------- website/doctype/__init__.py | 1 - website/doctype/about_us_settings/README.md | 1 - website/doctype/about_us_settings/__init__.py | 0 .../about_us_settings/about_us_settings.py | 21 -- .../about_us_settings/about_us_settings.txt | 110 -------- .../about_us_settings/templates/about.html | 34 --- .../doctype/about_us_team_member/README.md | 1 - .../doctype/about_us_team_member/__init__.py | 0 .../about_us_team_member.py | 11 - .../about_us_team_member.txt | 52 ---- website/doctype/blog_category/README.md | 1 - website/doctype/blog_category/__init__.py | 0 .../doctype/blog_category/blog_category.py | 17 -- .../doctype/blog_category/blog_category.txt | 56 ---- website/doctype/blog_post/README.md | 1 - website/doctype/blog_post/__init__.py | 0 website/doctype/blog_post/blog_feed.py | 61 ----- website/doctype/blog_post/blog_post.js | 12 - website/doctype/blog_post/blog_post.py | 176 ------------- website/doctype/blog_post/blog_post.txt | 135 ---------- website/doctype/blog_post/templates/blog.html | 33 --- .../blog_post/templates/blog_post.html | 58 ---- .../blog_post/templates/includes/blog.css | 7 - .../blog_post/templates/includes/blog.js | 86 ------ .../templates/includes/blog_footer.html | 13 - .../templates/includes/blog_page.css | 13 - .../blog_post/templates/includes/blog_page.js | 65 ----- .../templates/includes/blog_subscribe.html | 9 - .../blog_post/templates/includes/blogger.html | 13 - .../blog_post/templates/includes/comment.html | 17 -- website/doctype/blog_settings/README.md | 1 - website/doctype/blog_settings/__init__.py | 0 .../doctype/blog_settings/blog_settings.py | 11 - .../doctype/blog_settings/blog_settings.txt | 62 ----- website/doctype/blogger/README.md | 1 - website/doctype/blogger/__init__.py | 0 website/doctype/blogger/blogger.py | 41 --- website/doctype/blogger/blogger.txt | 102 ------- .../doctype/blogger/templates/writers.html | 17 -- website/doctype/company_history/README.md | 1 - website/doctype/company_history/__init__.py | 0 .../company_history/company_history.py | 11 - .../company_history/company_history.txt | 42 --- website/doctype/contact_us_settings/README.md | 1 - .../doctype/contact_us_settings/__init__.py | 0 .../contact_us_settings.py | 24 -- .../contact_us_settings.txt | 82 ------ .../templates/contact.html | 60 ----- .../templates/includes/contact.js | 45 ---- .../shopping_cart_price_list/__init__.py | 0 .../shopping_cart_price_list.py | 11 - .../shopping_cart_price_list.txt | 36 --- .../shopping_cart_settings/__init__.py | 0 .../shopping_cart_settings.js | 10 - .../shopping_cart_settings.py | 149 ----------- .../shopping_cart_settings.txt | 125 --------- .../test_shopping_cart_settings.py | 81 ------ .../shopping_cart_shipping_rule/__init__.py | 0 .../shopping_cart_shipping_rule.py | 11 - .../shopping_cart_shipping_rule.txt | 36 --- .../__init__.py | 0 .../shopping_cart_taxes_and_charges_master.py | 11 - ...shopping_cart_taxes_and_charges_master.txt | 36 --- website/doctype/style_settings/README.md | 6 - website/doctype/style_settings/__init__.py | 1 - .../style_settings/custom_template.css | 235 ----------------- .../doctype/style_settings/style_settings.js | 12 - .../doctype/style_settings/style_settings.py | 98 ------- .../doctype/style_settings/style_settings.txt | 201 -------------- website/doctype/top_bar_item/README.md | 1 - website/doctype/top_bar_item/__init__.py | 1 - website/doctype/top_bar_item/top_bar_item.py | 9 - website/doctype/top_bar_item/top_bar_item.txt | 57 ---- website/doctype/web_page/README.md | 1 - website/doctype/web_page/__init__.py | 1 - website/doctype/web_page/templates/index.html | 1 - .../doctype/web_page/templates/web_page.html | 14 - website/doctype/web_page/web_page.js | 29 -- website/doctype/web_page/web_page.py | 35 --- website/doctype/web_page/web_page.txt | 154 ----------- website/doctype/website_item_group/README.md | 1 - .../doctype/website_item_group/__init__.py | 0 .../website_item_group/website_item_group.py | 11 - .../website_item_group/website_item_group.txt | 37 --- website/doctype/website_script/README.md | 1 - website/doctype/website_script/__init__.py | 0 .../doctype/website_script/website_script.py | 16 -- .../doctype/website_script/website_script.txt | 52 ---- website/doctype/website_settings/README.md | 1 - website/doctype/website_settings/__init__.py | 1 - .../make_web_include_files.py | 60 ----- .../website_settings/website_settings.js | 64 ----- .../website_settings/website_settings.py | 78 ------ .../website_settings/website_settings.txt | 249 ------------------ website/doctype/website_slideshow/README.md | 1 - website/doctype/website_slideshow/__init__.py | 0 .../templates/includes/slideshow.html | 39 --- .../website_slideshow/website_slideshow.js | 12 - .../website_slideshow/website_slideshow.py | 21 -- .../website_slideshow/website_slideshow.txt | 82 ------ .../doctype/website_slideshow_item/README.md | 1 - .../website_slideshow_item/__init__.py | 0 .../website_slideshow_item.py | 11 - .../website_slideshow_item.txt | 53 ---- website/page/__init__.py | 1 - website/page/website_home/__init__.py | 1 - website/page/website_home/website_home.js | 111 -------- website/page/website_home/website_home.txt | 22 -- website/sitemap.py | 55 ---- website/templates/__init__.py | 1 - website/templates/includes/footer.html | 79 ------ website/templates/includes/navbar.html | 39 --- website/templates/includes/outer.html | 34 --- website/templates/includes/page.html | 20 -- 117 files changed, 4253 deletions(-) delete mode 100644 website/README.md delete mode 100644 website/__init__.py delete mode 100644 website/css/website.css delete mode 100644 website/doctype/__init__.py delete mode 100644 website/doctype/about_us_settings/README.md delete mode 100644 website/doctype/about_us_settings/__init__.py delete mode 100644 website/doctype/about_us_settings/about_us_settings.py delete mode 100644 website/doctype/about_us_settings/about_us_settings.txt delete mode 100644 website/doctype/about_us_settings/templates/about.html delete mode 100644 website/doctype/about_us_team_member/README.md delete mode 100644 website/doctype/about_us_team_member/__init__.py delete mode 100644 website/doctype/about_us_team_member/about_us_team_member.py delete mode 100644 website/doctype/about_us_team_member/about_us_team_member.txt delete mode 100644 website/doctype/blog_category/README.md delete mode 100644 website/doctype/blog_category/__init__.py delete mode 100644 website/doctype/blog_category/blog_category.py delete mode 100644 website/doctype/blog_category/blog_category.txt delete mode 100644 website/doctype/blog_post/README.md delete mode 100644 website/doctype/blog_post/__init__.py delete mode 100644 website/doctype/blog_post/blog_feed.py delete mode 100644 website/doctype/blog_post/blog_post.js delete mode 100644 website/doctype/blog_post/blog_post.py delete mode 100644 website/doctype/blog_post/blog_post.txt delete mode 100644 website/doctype/blog_post/templates/blog.html delete mode 100644 website/doctype/blog_post/templates/blog_post.html delete mode 100644 website/doctype/blog_post/templates/includes/blog.css delete mode 100644 website/doctype/blog_post/templates/includes/blog.js delete mode 100644 website/doctype/blog_post/templates/includes/blog_footer.html delete mode 100644 website/doctype/blog_post/templates/includes/blog_page.css delete mode 100644 website/doctype/blog_post/templates/includes/blog_page.js delete mode 100644 website/doctype/blog_post/templates/includes/blog_subscribe.html delete mode 100644 website/doctype/blog_post/templates/includes/blogger.html delete mode 100644 website/doctype/blog_post/templates/includes/comment.html delete mode 100644 website/doctype/blog_settings/README.md delete mode 100644 website/doctype/blog_settings/__init__.py delete mode 100644 website/doctype/blog_settings/blog_settings.py delete mode 100644 website/doctype/blog_settings/blog_settings.txt delete mode 100644 website/doctype/blogger/README.md delete mode 100644 website/doctype/blogger/__init__.py delete mode 100644 website/doctype/blogger/blogger.py delete mode 100644 website/doctype/blogger/blogger.txt delete mode 100644 website/doctype/blogger/templates/writers.html delete mode 100644 website/doctype/company_history/README.md delete mode 100644 website/doctype/company_history/__init__.py delete mode 100644 website/doctype/company_history/company_history.py delete mode 100644 website/doctype/company_history/company_history.txt delete mode 100644 website/doctype/contact_us_settings/README.md delete mode 100644 website/doctype/contact_us_settings/__init__.py delete mode 100644 website/doctype/contact_us_settings/contact_us_settings.py delete mode 100644 website/doctype/contact_us_settings/contact_us_settings.txt delete mode 100644 website/doctype/contact_us_settings/templates/contact.html delete mode 100644 website/doctype/contact_us_settings/templates/includes/contact.js delete mode 100644 website/doctype/shopping_cart_price_list/__init__.py delete mode 100644 website/doctype/shopping_cart_price_list/shopping_cart_price_list.py delete mode 100644 website/doctype/shopping_cart_price_list/shopping_cart_price_list.txt delete mode 100644 website/doctype/shopping_cart_settings/__init__.py delete mode 100644 website/doctype/shopping_cart_settings/shopping_cart_settings.js delete mode 100644 website/doctype/shopping_cart_settings/shopping_cart_settings.py delete mode 100644 website/doctype/shopping_cart_settings/shopping_cart_settings.txt delete mode 100644 website/doctype/shopping_cart_settings/test_shopping_cart_settings.py delete mode 100644 website/doctype/shopping_cart_shipping_rule/__init__.py delete mode 100644 website/doctype/shopping_cart_shipping_rule/shopping_cart_shipping_rule.py delete mode 100644 website/doctype/shopping_cart_shipping_rule/shopping_cart_shipping_rule.txt delete mode 100644 website/doctype/shopping_cart_taxes_and_charges_master/__init__.py delete mode 100644 website/doctype/shopping_cart_taxes_and_charges_master/shopping_cart_taxes_and_charges_master.py delete mode 100644 website/doctype/shopping_cart_taxes_and_charges_master/shopping_cart_taxes_and_charges_master.txt delete mode 100644 website/doctype/style_settings/README.md delete mode 100644 website/doctype/style_settings/__init__.py delete mode 100644 website/doctype/style_settings/custom_template.css delete mode 100644 website/doctype/style_settings/style_settings.js delete mode 100644 website/doctype/style_settings/style_settings.py delete mode 100644 website/doctype/style_settings/style_settings.txt delete mode 100644 website/doctype/top_bar_item/README.md delete mode 100644 website/doctype/top_bar_item/__init__.py delete mode 100644 website/doctype/top_bar_item/top_bar_item.py delete mode 100644 website/doctype/top_bar_item/top_bar_item.txt delete mode 100644 website/doctype/web_page/README.md delete mode 100644 website/doctype/web_page/__init__.py delete mode 100644 website/doctype/web_page/templates/index.html delete mode 100644 website/doctype/web_page/templates/web_page.html delete mode 100644 website/doctype/web_page/web_page.js delete mode 100644 website/doctype/web_page/web_page.py delete mode 100644 website/doctype/web_page/web_page.txt delete mode 100644 website/doctype/website_item_group/README.md delete mode 100644 website/doctype/website_item_group/__init__.py delete mode 100644 website/doctype/website_item_group/website_item_group.py delete mode 100644 website/doctype/website_item_group/website_item_group.txt delete mode 100644 website/doctype/website_script/README.md delete mode 100644 website/doctype/website_script/__init__.py delete mode 100644 website/doctype/website_script/website_script.py delete mode 100644 website/doctype/website_script/website_script.txt delete mode 100644 website/doctype/website_settings/README.md delete mode 100644 website/doctype/website_settings/__init__.py delete mode 100644 website/doctype/website_settings/make_web_include_files.py delete mode 100644 website/doctype/website_settings/website_settings.js delete mode 100644 website/doctype/website_settings/website_settings.py delete mode 100644 website/doctype/website_settings/website_settings.txt delete mode 100644 website/doctype/website_slideshow/README.md delete mode 100644 website/doctype/website_slideshow/__init__.py delete mode 100644 website/doctype/website_slideshow/templates/includes/slideshow.html delete mode 100644 website/doctype/website_slideshow/website_slideshow.js delete mode 100644 website/doctype/website_slideshow/website_slideshow.py delete mode 100644 website/doctype/website_slideshow/website_slideshow.txt delete mode 100644 website/doctype/website_slideshow_item/README.md delete mode 100644 website/doctype/website_slideshow_item/__init__.py delete mode 100644 website/doctype/website_slideshow_item/website_slideshow_item.py delete mode 100644 website/doctype/website_slideshow_item/website_slideshow_item.txt delete mode 100644 website/page/__init__.py delete mode 100644 website/page/website_home/__init__.py delete mode 100644 website/page/website_home/website_home.js delete mode 100644 website/page/website_home/website_home.txt delete mode 100644 website/sitemap.py delete mode 100644 website/templates/__init__.py delete mode 100644 website/templates/includes/footer.html delete mode 100644 website/templates/includes/navbar.html delete mode 100644 website/templates/includes/outer.html delete mode 100644 website/templates/includes/page.html diff --git a/website/README.md b/website/README.md deleted file mode 100644 index 8ad39038f4..0000000000 --- a/website/README.md +++ /dev/null @@ -1,8 +0,0 @@ -Module for website management. - -Contains: - -- DocTypes for Web Page, Blogs -- Templates -- Settings -- Generators for Item, Blog Post, Item Group \ No newline at end of file diff --git a/website/__init__.py b/website/__init__.py deleted file mode 100644 index aace68bb64..0000000000 --- a/website/__init__.py +++ /dev/null @@ -1,20 +0,0 @@ -from __future__ import unicode_literals -install_docs = [ - {"doctype":"Role", "role_name":"Blogger", "name":"Blogger"}, - {"doctype":"Role", "role_name":"Website Manager", "name":"Website Manager"}, -] - -import webnotes - - -def get_site_address(): - from webnotes.utils import get_request_site_address - url = get_request_site_address() - - if not url or url=='http://localhost': - new_url = webnotes.conn.get_value('Website Settings', 'Website Settings', - 'subdomain') - if new_url: - url = "http://" + new_url - - return url \ No newline at end of file diff --git a/website/css/website.css b/website/css/website.css deleted file mode 100644 index 4cd7ac7735..0000000000 --- a/website/css/website.css +++ /dev/null @@ -1,204 +0,0 @@ -.container { - max-width: 728px !important; -} - -h1, h2, h3, h4, h5 { - font-weight: bold; -} - -a { - cursor: pointer; -} - -img { - max-width: 100%; -} - -.content { - padding-bottom: 30px; -} - -.banner { - margin-top: 20px; - padding: 0px 20px; -} - -.missing-image { - background-color: #eee; - padding: 40px; - width: 112px; - font-size: 32px; - color: #888; -} - -.social-icons { - font-size: 120%; - float: right; - text-align: right; -} -.social-icons a:hover { - text-decoration: none; -} -.social-icons a i:hover { - text-decoration: none; -} -.social-icons i { - margin-left: 5px; -} - -div.web-footer { - padding-top: 10px; - padding-bottom: 20px; -} - -.web-footer-menu ul { - list-style: none; - margin: 0px; - padding: 0px; -} - -.web-footer-menu ul li { - display: inline; - padding: 2px 14px 2px 0px; - margin: 0px; -} - -.avatar { - display: inline-block; - vertical-align: middle; - overflow: hidden; - background-color: #ddd; - border: 1px solid #eee; -} - -.avatar-small { - margin-right: 5px; - width: 30px; - height: 30px; - border-radius: 30px; - -moz-border-radius: 30px; - -webkit-border-radius: 30px; -} -.avatar-small img { - width: 30px; -} - -.avatar-medium { - margin-right: 5px; - width: 48px; - height: 48px; - border-radius: 48px; - -moz-border-radius: 48px; - -webkit-border-radius: 48px; -} -.avatar-medium img { - width: 48px; -} - -.avatar-large { - margin-right: 10px; - width: 72px; - height: 72px; - border-radius: 72px; - -moz-border-radius: 72px; - -webkit-border-radius: 72px; -} -.avatar-large img { - width: 72px; -} - -.avatar-x-large { - margin-right: 10px; - width: 100px; - height: 100px; - border-radius: 100px; - -moz-border-radius: 100px; - -webkit-border-radius: 100px; -} -.avatar-x-large img { - width: 100px; -} - -.carousel-control .icon { - position: absolute; - top: 50%; - left: 50%; - z-index: 5; - display: inline-block; - width: 20px; - height: 20px; - margin-top: -10px; - margin-left: -10px; -} - -.hidden-sm-inline { - display: none; -} - -@media (min-width: 768px) { - .hidden-sm-inline { - display: inline; - } -} - -.panel-heading, -.panel-body { - padding-left: 15px; -} - - -.breadcrumb { - margin: 0px -20px; - margin-bottom: 20px; -} - -fieldset { - margin-bottom: 20px; -} - -/* buttons */ - -.btn-default { - color: #ffffff; - background-color: #a7a9aa; - border-color: #a7a9aa; -} - -.dropup .btn-default .caret, -.btn-default .caret { - border-bottom-color: #ffffff; - border-top-color: #ffffff; -} - -.btn-default:hover, -.btn-default:focus, -.btn-default:active, -.btn-default.active, -.open .dropdown-toggle.btn-default { - background-color: #9a9c9d; - border-color: #8d9091; - color: #ffffff; -} - -.btn-default.disabled, -.btn-default[disabled], -fieldset[disabled] .btn-default, -.btn-default.disabled:hover, -.btn-default[disabled]:hover, -fieldset[disabled] .btn-default:hover, -.btn-default.disabled:focus, -.btn-default[disabled]:focus, -fieldset[disabled] .btn-default:focus, -.btn-default.disabled:active, -.btn-default[disabled]:active, -fieldset[disabled] .btn-default:active, -.btn-default.disabled.active, -.btn-default[disabled].active, -fieldset[disabled] .btn-default.active { - background-color: #a7a9aa; - border-color: #a7a9aa; -} - -.label { - padding-top: 0.3em; -} \ No newline at end of file diff --git a/website/doctype/__init__.py b/website/doctype/__init__.py deleted file mode 100644 index baffc48825..0000000000 --- a/website/doctype/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from __future__ import unicode_literals diff --git a/website/doctype/about_us_settings/README.md b/website/doctype/about_us_settings/README.md deleted file mode 100644 index 977a7a35e4..0000000000 --- a/website/doctype/about_us_settings/README.md +++ /dev/null @@ -1 +0,0 @@ -Configuration for "About" page in the website that shows company, history and team. \ No newline at end of file diff --git a/website/doctype/about_us_settings/__init__.py b/website/doctype/about_us_settings/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/website/doctype/about_us_settings/about_us_settings.py b/website/doctype/about_us_settings/about_us_settings.py deleted file mode 100644 index 139abc20c1..0000000000 --- a/website/doctype/about_us_settings/about_us_settings.py +++ /dev/null @@ -1,21 +0,0 @@ -# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. -# License: GNU General Public License v3. See license.txt - -# For license information, please see license.txt - -from __future__ import unicode_literals -import webnotes - -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl - - def on_update(self): - from webnotes.webutils import clear_cache - clear_cache("about") - -def get_args(): - obj = webnotes.get_obj("About Us Settings") - return { - "obj": obj - } \ No newline at end of file diff --git a/website/doctype/about_us_settings/about_us_settings.txt b/website/doctype/about_us_settings/about_us_settings.txt deleted file mode 100644 index 0e34d67083..0000000000 --- a/website/doctype/about_us_settings/about_us_settings.txt +++ /dev/null @@ -1,110 +0,0 @@ -[ - { - "creation": "2013-03-19 12:02:15", - "docstatus": 0, - "modified": "2013-07-05 14:23:27", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "allow_attach": 1, - "description": "Settings for the About Us Page", - "doctype": "DocType", - "document_type": "Other", - "icon": "icon-group", - "issingle": 1, - "module": "Website", - "name": "__common__" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "About Us Settings", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0, - "read_only": 0 - }, - { - "create": 1, - "doctype": "DocPerm", - "name": "__common__", - "parent": "About Us Settings", - "parentfield": "permissions", - "parenttype": "DocType", - "permlevel": 0, - "read": 1, - "report": 0, - "role": "Website Manager", - "submit": 0, - "write": 1 - }, - { - "doctype": "DocType", - "name": "About Us Settings" - }, - { - "doctype": "DocField", - "fieldname": "help", - "fieldtype": "HTML", - "label": "Help", - "options": "
Link for About Us Page is \"/about\"
" - }, - { - "description": "Introduce your company to the website visitor.", - "doctype": "DocField", - "fieldname": "company_introduction", - "fieldtype": "Text Editor", - "label": "Company Introduction" - }, - { - "doctype": "DocField", - "fieldname": "sb0", - "fieldtype": "Section Break", - "label": "Company History" - }, - { - "description": "\"Company History\"", - "doctype": "DocField", - "fieldname": "company_history_heading", - "fieldtype": "Data", - "label": "Company History Heading" - }, - { - "doctype": "DocField", - "fieldname": "company_history", - "fieldtype": "Table", - "label": "Company History", - "options": "Company History" - }, - { - "doctype": "DocField", - "fieldname": "sb1", - "fieldtype": "Section Break", - "label": "Team Members" - }, - { - "description": "\"Team Members\" or \"Management\"", - "doctype": "DocField", - "fieldname": "team_members_heading", - "fieldtype": "Data", - "label": "Team Members Heading" - }, - { - "doctype": "DocField", - "fieldname": "team_members", - "fieldtype": "Table", - "label": "Team Members", - "options": "About Us Team Member" - }, - { - "description": "More content for the bottom of the page.", - "doctype": "DocField", - "fieldname": "footer", - "fieldtype": "Text Editor", - "label": "Footer" - }, - { - "doctype": "DocPerm" - } -] \ No newline at end of file diff --git a/website/doctype/about_us_settings/templates/about.html b/website/doctype/about_us_settings/templates/about.html deleted file mode 100644 index 277f790cf7..0000000000 --- a/website/doctype/about_us_settings/templates/about.html +++ /dev/null @@ -1,34 +0,0 @@ -{% extends "app/website/templates/html/page.html" %} - -{% set title="About Us" %} - -{% block content %} -
- {{ obj.doc.company_introduction or "

About Us

Some Introduction about your company that you would like your website visitor to know. More people than you think will read your About page. People always like to know who the are doing business with. Be authentic and avoid using jargon like 'value added services' etc. Be sure to update your company history and list of key team members in Website > About Us Settings

" }} - {% if obj.doclist.get({"doctype":"Company History"}) %} -

{{ obj.doc.company_history_heading or "Company History" }}

- {% for d in obj.doclist.get({"doctype":"Company History"}) %} -
-

{{ d.year }}

-

{{ d.highlight }}

-
- {% endfor %} - {% endif %} - {% if obj.doclist.get({"doctype":"About Us Team Member"}) %} -

{{ obj.doc.team_members_heading or "Team Members" }}

- {% for d in obj.doclist.get({"doctype":"About Us Team Member"}) %} -
- -
- -
-
-

{{ d.full_name }}

-

{{ d.bio }}

-
-
- {% endfor %} - {% endif %} - {{ obj.doc.footer or "" }} -
-{% endblock %} \ No newline at end of file diff --git a/website/doctype/about_us_team_member/README.md b/website/doctype/about_us_team_member/README.md deleted file mode 100644 index 98b794f8d4..0000000000 --- a/website/doctype/about_us_team_member/README.md +++ /dev/null @@ -1 +0,0 @@ -Details of team member for About Us page. \ No newline at end of file diff --git a/website/doctype/about_us_team_member/__init__.py b/website/doctype/about_us_team_member/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/website/doctype/about_us_team_member/about_us_team_member.py b/website/doctype/about_us_team_member/about_us_team_member.py deleted file mode 100644 index 784339de7d..0000000000 --- a/website/doctype/about_us_team_member/about_us_team_member.py +++ /dev/null @@ -1,11 +0,0 @@ -# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. -# License: GNU General Public License v3. See license.txt - -# For license information, please see license.txt - -from __future__ import unicode_literals -import webnotes - -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file diff --git a/website/doctype/about_us_team_member/about_us_team_member.txt b/website/doctype/about_us_team_member/about_us_team_member.txt deleted file mode 100644 index c5e6d164e9..0000000000 --- a/website/doctype/about_us_team_member/about_us_team_member.txt +++ /dev/null @@ -1,52 +0,0 @@ -[ - { - "creation": "2013-03-07 11:55:11", - "docstatus": 0, - "modified": "2013-07-10 14:54:03", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doctype": "DocType", - "istable": 1, - "module": "Website", - "name": "__common__" - }, - { - "doctype": "DocField", - "in_list_view": 1, - "name": "__common__", - "parent": "About Us Team Member", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "doctype": "DocType", - "name": "About Us Team Member" - }, - { - "doctype": "DocField", - "fieldname": "full_name", - "fieldtype": "Data", - "label": "Full Name", - "reqd": 1, - "width": "150px" - }, - { - "doctype": "DocField", - "fieldname": "image_link", - "fieldtype": "Select", - "label": "Image Link", - "options": "attach_files:", - "width": "150px" - }, - { - "doctype": "DocField", - "fieldname": "bio", - "fieldtype": "Small Text", - "label": "Bio", - "reqd": 1, - "width": "200px" - } -] \ No newline at end of file diff --git a/website/doctype/blog_category/README.md b/website/doctype/blog_category/README.md deleted file mode 100644 index af14b5dc14..0000000000 --- a/website/doctype/blog_category/README.md +++ /dev/null @@ -1 +0,0 @@ -Blog category. \ No newline at end of file diff --git a/website/doctype/blog_category/__init__.py b/website/doctype/blog_category/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/website/doctype/blog_category/blog_category.py b/website/doctype/blog_category/blog_category.py deleted file mode 100644 index 7d99e2a968..0000000000 --- a/website/doctype/blog_category/blog_category.py +++ /dev/null @@ -1,17 +0,0 @@ -# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. -# License: GNU General Public License v3. See license.txt - -# For license information, please see license.txt - -from __future__ import unicode_literals -import webnotes - -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl - - def on_update(self): - # for blog footer - from webnotes.webutils import clear_cache - clear_cache() - \ No newline at end of file diff --git a/website/doctype/blog_category/blog_category.txt b/website/doctype/blog_category/blog_category.txt deleted file mode 100644 index b986c441a5..0000000000 --- a/website/doctype/blog_category/blog_category.txt +++ /dev/null @@ -1,56 +0,0 @@ -[ - { - "creation": "2013-03-08 09:41:11", - "docstatus": 0, - "modified": "2013-07-05 14:27:02", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "autoname": "field:category_name", - "doctype": "DocType", - "document_type": "Master", - "icon": "icon-tag", - "module": "Website", - "name": "__common__" - }, - { - "doctype": "DocField", - "fieldname": "category_name", - "fieldtype": "Data", - "label": "Category Name", - "name": "__common__", - "parent": "Blog Category", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0, - "reqd": 1 - }, - { - "doctype": "DocPerm", - "name": "__common__", - "parent": "Blog Category", - "parentfield": "permissions", - "parenttype": "DocType", - "permlevel": 0, - "read": 1 - }, - { - "doctype": "DocType", - "name": "Blog Category" - }, - { - "doctype": "DocField" - }, - { - "cancel": 1, - "create": 1, - "doctype": "DocPerm", - "role": "Website Manager", - "write": 1 - }, - { - "doctype": "DocPerm", - "role": "Blogger" - } -] \ No newline at end of file diff --git a/website/doctype/blog_post/README.md b/website/doctype/blog_post/README.md deleted file mode 100644 index 63d3c0f31e..0000000000 --- a/website/doctype/blog_post/README.md +++ /dev/null @@ -1 +0,0 @@ -Blog post for "Blogs" section of website. \ No newline at end of file diff --git a/website/doctype/blog_post/__init__.py b/website/doctype/blog_post/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/website/doctype/blog_post/blog_feed.py b/website/doctype/blog_post/blog_feed.py deleted file mode 100644 index 577cde6123..0000000000 --- a/website/doctype/blog_post/blog_feed.py +++ /dev/null @@ -1,61 +0,0 @@ -# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. -# License: GNU General Public License v3. See license.txt - -from __future__ import unicode_literals -""" -Generate RSS feed for blog -""" - -rss = u""" - - - %(title)s - %(description)s - %(link)s - %(modified)s - %(modified)s - 1800 - %(items)s - -""" - -rss_item = u""" - - %(title)s - %(content)s - %(link)s - %(name)s - %(published_on)s -""" - -def generate(): - """generate rss feed""" - import os, urllib - import webnotes - from webnotes.model.doc import Document - from webnotes.utils import escape_html - - host = (os.environ.get('HTTPS') and 'https://' or 'http://') + os.environ.get('HTTP_HOST') - - items = '' - blog_list = webnotes.conn.sql("""\ - select page_name as name, published_on, modified, title, content from `tabBlog Post` - where ifnull(published,0)=1 - order by published_on desc limit 20""", as_dict=1) - - for blog in blog_list: - blog.link = urllib.quote(host + '/' + blog.name + '.html') - blog.content = escape_html(blog.content or "") - - items += rss_item % blog - - modified = max((blog['modified'] for blog in blog_list)) - - ws = Document('Website Settings', 'Website Settings') - return (rss % { - 'title': ws.title_prefix, - 'description': ws.description or (ws.title_prefix + ' Blog'), - 'modified': modified, - 'items': items, - 'link': host + '/blog.html' - }).encode('utf-8', 'ignore') diff --git a/website/doctype/blog_post/blog_post.js b/website/doctype/blog_post/blog_post.js deleted file mode 100644 index af4dcc9677..0000000000 --- a/website/doctype/blog_post/blog_post.js +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. -// License: GNU General Public License v3. See license.txt - -cur_frm.cscript.refresh = function(doc) { - if(!doc.__islocal && doc.published && !doc.email_sent) { - cur_frm.add_custom_button('Email Subscribers', function() { - $c_obj(make_doclist(doc.doctype, doc.name), 'send_emails', '', function(r) { - cur_frm.refresh(); - }); - }) - } -} \ No newline at end of file diff --git a/website/doctype/blog_post/blog_post.py b/website/doctype/blog_post/blog_post.py deleted file mode 100644 index 143b64d586..0000000000 --- a/website/doctype/blog_post/blog_post.py +++ /dev/null @@ -1,176 +0,0 @@ -# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. -# License: GNU General Public License v3. See license.txt - -from __future__ import unicode_literals - -import webnotes -import webnotes.webutils -from webnotes import _ - -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl - - def autoname(self): - from webnotes.webutils import page_name - self.doc.name = page_name(self.doc.title) - - def validate(self): - if self.doc.blog_intro: - self.doc.blog_intro = self.doc.blog_intro[:140] - - # update posts - webnotes.conn.sql("""update tabBlogger set posts=(select count(*) from `tabBlog Post` - where ifnull(blogger,'')=tabBlogger.name) - where name=%s""", self.doc.blogger) - - def on_update(self): - webnotes.webutils.update_page_name(self.doc, self.doc.title) - webnotes.webutils.delete_page_cache("writers") - - def prepare_template_args(self): - import webnotes.utils - import markdown2 - - # this is for double precaution. usually it wont reach this code if not published - if not webnotes.utils.cint(self.doc.published): - raise Exception, "This blog has not been published yet!" - - # temp fields - from webnotes.utils import global_date_format, get_fullname - self.doc.full_name = get_fullname(self.doc.owner) - self.doc.updated = global_date_format(self.doc.published_on) - self.doc.content_html = self.doc.content - - if self.doc.blogger: - self.doc.blogger_info = webnotes.doc("Blogger", self.doc.blogger).fields - - self.doc.description = self.doc.blog_intro or self.doc.content[:140] - self.doc.meta_description = self.doc.description - - self.doc.categories = webnotes.conn.sql_list("select name from `tabBlog Category` order by name") - - self.doc.texts = { - "comments": _("Comments"), - "first_comment": _("Be the first one to comment"), - "add_comment": _("Add Comment"), - "submit": _("Submit"), - "all_posts_by": _("All posts by"), - } - - comment_list = webnotes.conn.sql("""\ - select comment, comment_by_fullname, creation - from `tabComment` where comment_doctype="Blog Post" - and comment_docname=%s order by creation""", self.doc.name, as_dict=1) - - self.doc.comment_list = comment_list or [] - for comment in self.doc.comment_list: - comment['comment_date'] = webnotes.utils.global_date_format(comment['creation']) - comment['comment'] = markdown2.markdown(comment['comment']) - -def clear_blog_cache(): - for blog in webnotes.conn.sql_list("""select page_name from - `tabBlog Post` where ifnull(published,0)=1"""): - webnotes.webutils.delete_page_cache(blog) - - webnotes.webutils.delete_page_cache("writers") - -@webnotes.whitelist(allow_guest=True) -def get_blog_list(start=0, by=None, category=None): - import webnotes - condition = "" - if by: - condition = " and t1.blogger='%s'" % by.replace("'", "\'") - if category: - condition += " and t1.blog_category='%s'" % category.replace("'", "\'") - query = """\ - select - t1.title, t1.name, t1.page_name, t1.published_on as creation, - ifnull(t1.blog_intro, t1.content) as content, - t2.full_name, t2.avatar, t1.blogger, - (select count(name) from `tabComment` where - comment_doctype='Blog Post' and comment_docname=t1.name) as comments - from `tabBlog Post` t1, `tabBlogger` t2 - where ifnull(t1.published,0)=1 - and t1.blogger = t2.name - %(condition)s - order by published_on desc, name asc - limit %(start)s, 20""" % {"start": start, "condition": condition} - - result = webnotes.conn.sql(query, as_dict=1) - - # strip html tags from content - import webnotes.utils - - for res in result: - from webnotes.utils import global_date_format - res['published'] = global_date_format(res['creation']) - if not res['content']: - res['content'] = webnotes.webutils.get_html(res['page_name']) - res['content'] = res['content'][:140] - - return result - -@webnotes.whitelist(allow_guest=True) -def add_comment(args=None): - """ - args = { - 'comment': '', - 'comment_by': '', - 'comment_by_fullname': '', - 'comment_doctype': '', - 'comment_docname': '', - 'page_name': '', - } - """ - import webnotes - import webnotes.utils, markdown2 - - if not args: args = webnotes.form_dict - args['comment'] = unicode(markdown2.markdown(args.get('comment') or '')) - args['doctype'] = "Comment" - - page_name = args.get("page_name") - if "page_name" in args: - del args["page_name"] - if "cmd" in args: - del args["cmd"] - - comment = webnotes.bean(args) - comment.ignore_permissions = True - comment.insert() - - # since comments are embedded in the page, clear the web cache - webnotes.webutils.clear_cache(page_name) - - args['comment_date'] = webnotes.utils.global_date_format(comment.doc.creation) - template_args = { 'comment_list': [args], 'template': 'app/website/templates/html/comment.html' } - - # get html of comment row - comment_html = webnotes.webutils.build_html(template_args) - - # notify commentors - commentors = [d[0] for d in webnotes.conn.sql("""select comment_by from tabComment where - comment_doctype='Blog Post' and comment_docname=%s and - ifnull(unsubscribed, 0)=0""", args.get('comment_docname'))] - - blog = webnotes.doc("Blog Post", args.get("comment_docname")) - blogger_profile = webnotes.conn.get_value("Blogger", blog.blogger, "profile") - blogger_email = webnotes.conn.get_value("Profile", blogger_profile, "email") - - from webnotes.utils.email_lib.bulk import send - send(recipients=list(set(commentors + [blogger_email])), - doctype='Comment', - email_field='comment_by', - subject='New Comment on Blog: ' + blog.title, - message='%(comment)s

By %(comment_by_fullname)s

' % args, - ref_doctype='Blog Post', ref_docname=blog.name) - - return comment_html.replace("\n", "") - -def get_blog_template_args(): - args = { - "categories": webnotes.conn.sql_list("select name from `tabBlog Category` order by name") - } - args.update(webnotes.doc("Blog Settings", "Blog Settings").fields) - return args diff --git a/website/doctype/blog_post/blog_post.txt b/website/doctype/blog_post/blog_post.txt deleted file mode 100644 index 79c1aee94f..0000000000 --- a/website/doctype/blog_post/blog_post.txt +++ /dev/null @@ -1,135 +0,0 @@ -[ - { - "creation": "2013-03-28 10:35:30", - "docstatus": 0, - "modified": "2013-07-05 15:08:30", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "allow_attach": 1, - "allow_import": 1, - "doctype": "DocType", - "icon": "icon-quote-left", - "max_attachments": 5, - "module": "Website", - "name": "__common__" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Blog Post", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "doctype": "DocPerm", - "name": "__common__", - "parent": "Blog Post", - "parentfield": "permissions", - "parenttype": "DocType", - "permlevel": 0, - "read": 1, - "report": 1, - "submit": 0 - }, - { - "doctype": "DocType", - "name": "Blog Post" - }, - { - "doctype": "DocField", - "fieldname": "title", - "fieldtype": "Data", - "label": "Title", - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "published", - "fieldtype": "Check", - "label": "Published" - }, - { - "doctype": "DocField", - "fieldname": "published_on", - "fieldtype": "Date", - "label": "Published On" - }, - { - "doctype": "DocField", - "fieldname": "column_break_3", - "fieldtype": "Column Break" - }, - { - "doctype": "DocField", - "fieldname": "blogger", - "fieldtype": "Link", - "in_list_view": 1, - "label": "Blogger", - "options": "Blogger", - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "blog_category", - "fieldtype": "Link", - "in_list_view": 1, - "label": "Blog Category", - "options": "Blog Category" - }, - { - "doctype": "DocField", - "fieldname": "section_break_5", - "fieldtype": "Section Break" - }, - { - "description": "Description for listing page, in plain text, only a couple of lines. (max 140 characters)", - "doctype": "DocField", - "fieldname": "blog_intro", - "fieldtype": "Small Text", - "in_list_view": 1, - "label": "Blog Intro", - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "content", - "fieldtype": "Text Editor", - "label": "Content", - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "page_name", - "fieldtype": "Data", - "hidden": 1, - "label": "Page Name", - "read_only": 1 - }, - { - "doctype": "DocField", - "fieldname": "email_sent", - "fieldtype": "Check", - "hidden": 1, - "label": "Email Sent" - }, - { - "create": 1, - "doctype": "DocPerm", - "role": "Website Manager", - "write": 1 - }, - { - "create": 1, - "doctype": "DocPerm", - "role": "Blogger", - "write": 1 - }, - { - "doctype": "DocPerm", - "role": "Guest", - "write": 0 - } -] \ No newline at end of file diff --git a/website/doctype/blog_post/templates/blog.html b/website/doctype/blog_post/templates/blog.html deleted file mode 100644 index 9bd1abf178..0000000000 --- a/website/doctype/blog_post/templates/blog.html +++ /dev/null @@ -1,33 +0,0 @@ -{% extends "app/website/templates/html/page.html" %} - -{% block javascript %} - {% include "app/website/templates/js/blog.js" %} -{% endblock %} - -{% block css %} - {% include "app/website/templates/css/blog.css" %} -{% endblock %} - -{% set title="Blog" %} - -{% block content %} -
-

{{ blog_title }}

- {% if blog_introduction %} -

{{ blog_introduction }}

- {% endif %} - -
-
-
-
-
- -
-
- -
-
-{% include 'app/website/templates/html/blog_footer.html' %} -{% endblock %} \ No newline at end of file diff --git a/website/doctype/blog_post/templates/blog_post.html b/website/doctype/blog_post/templates/blog_post.html deleted file mode 100644 index 90f6a79f2b..0000000000 --- a/website/doctype/blog_post/templates/blog_post.html +++ /dev/null @@ -1,58 +0,0 @@ -{% extends "app/website/templates/html/page.html" %} - -{% block javascript %} - {% include "app/website/templates/js/blog_page.js" %} -{% endblock %} - -{% block css %} - {% include "app/website/templates/css/blog_page.css" %} -{% endblock %} - -{% block content %} -
-

{{ title }}

- - -
- / - {{ updated }}
-
-
- {{ content_html }} -
- - {% if blogger_info %} -
- {% include "app/website/templates/html/blogger.html" %} - {% endif %} -
-

{{ texts.comments }}


-
- - {% if not comment_list %} -
-

{{ texts.first_comment }}

-
- {% endif %} - - {% include 'app/website/templates/html/comment.html' %} -
-
- -
-{% include 'app/website/templates/html/blog_footer.html' %} -{% endblock %} \ No newline at end of file diff --git a/website/doctype/blog_post/templates/includes/blog.css b/website/doctype/blog_post/templates/includes/blog.css deleted file mode 100644 index 199df1ac77..0000000000 --- a/website/doctype/blog_post/templates/includes/blog.css +++ /dev/null @@ -1,7 +0,0 @@ - \ No newline at end of file diff --git a/website/doctype/blog_post/templates/includes/blog.js b/website/doctype/blog_post/templates/includes/blog.js deleted file mode 100644 index d5e9d5081b..0000000000 --- a/website/doctype/blog_post/templates/includes/blog.js +++ /dev/null @@ -1,86 +0,0 @@ -// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. -// License: GNU General Public License v3. See license.txt - -// js inside blog page - -$(document).ready(function() { - // make list of blogs - blog.get_list(); - - $("#next-page").click(function() { - blog.get_list(); - }) - - if(get_url_arg("by_name")) { - $("#blot-subtitle").html("Posts by " + get_url_arg("by_name")).toggle(true); - } - - if(get_url_arg("category")) { - $("#blot-subtitle").html("Posts filed under " + get_url_arg("category")).toggle(true); - } - -}); - -var blog = { - start: 0, - get_list: function() { - $.ajax({ - method: "GET", - url: "server.py", - data: { - cmd: "website.doctype.blog_post.blog_post.get_blog_list", - start: blog.start, - by: get_url_arg("by"), - category: get_url_arg("category") - }, - dataType: "json", - success: function(data) { - $(".progress").toggle(false); - if(data.exc) console.log(data.exc); - blog.render(data.message); - } - }); - }, - render: function(data) { - var $wrap = $("#blog-list"); - $.each(data, function(i, b) { - // comments - if(!b.comments) { - b.comment_text = 'No comments yet.' - } else if (b.comments===1) { - b.comment_text = '1 comment.' - } else { - b.comment_text = b.comments + ' comments.' - } - - b.page_name = encodeURIComponent(b.page_name); - - $(repl('
\ -
\ -
\ - \ -
\ -
\ -
\ -

%(title)s

\ -

%(content)s

\ -

\ - \ - %(full_name)s wrote this on %(published)s / %(comment_text)s

\ -
\ -

', b)).appendTo($wrap); - }); - blog.start += (data.length || 0); - if(!data.length || data.length < 20) { - if(blog.start) { - $("#next-page").toggle(false) - .parent().append("
Nothing more to show.
"); - } else { - $("#next-page").toggle(false) - .parent().append("
No blogs written yet.
"); - } - } else { - $("#next-page").toggle(true); - } - } -} \ No newline at end of file diff --git a/website/doctype/blog_post/templates/includes/blog_footer.html b/website/doctype/blog_post/templates/includes/blog_footer.html deleted file mode 100644 index e71b3eccb1..0000000000 --- a/website/doctype/blog_post/templates/includes/blog_footer.html +++ /dev/null @@ -1,13 +0,0 @@ -
-
- {% if categories %} -
Explore posts by categories
- -

- {% endif %} -

Show posts by everyone. Meet the writers of this blog

-
diff --git a/website/doctype/blog_post/templates/includes/blog_page.css b/website/doctype/blog_post/templates/includes/blog_page.css deleted file mode 100644 index 8f56cd2fec..0000000000 --- a/website/doctype/blog_post/templates/includes/blog_page.css +++ /dev/null @@ -1,13 +0,0 @@ - \ No newline at end of file diff --git a/website/doctype/blog_post/templates/includes/blog_page.js b/website/doctype/blog_post/templates/includes/blog_page.js deleted file mode 100644 index 3d45925da0..0000000000 --- a/website/doctype/blog_post/templates/includes/blog_page.js +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. -// License: GNU General Public License v3. See license.txt - -// js inside blog page - -$(document).ready(function() { - var n_comments = $(".comment-row").length; - - if(n_comments) { - $(".no_comment").toggle(false); - } - if(n_comments > 50) { - $(".add-comment").toggle(false) - .parent().append("
Comments are closed.
") - } - $(".add-comment").click(function() { - $(this).toggle(false); - $("#comment-form").toggle(); - $("#comment-form input, #comment-form, textarea").val(""); - }) - $("#submit-comment").click(function() { - var args = { - comment_by_fullname: $("[name='comment_by_fullname']").val(), - comment_by: $("[name='comment_by']").val(), - comment: $("[name='comment']").val(), - cmd: "website.doctype.blog_post.blog_post.add_comment", - comment_doctype: "Blog Post", - comment_docname: "{{ name }}", - page_name: "{{ page_name }}", - _type: "POST" - } - - $("#comment-form .alert").toggle(false); - - if(!args.comment_by_fullname || !args.comment_by || !args.comment) { - $("#comment-form .alert") - .html("All fields are necessary to submit the comment.") - .toggle(true); - return false; - } - - - $.ajax({ - type: "POST", - url: "server.py", - data: args, - dataType: "json", - success: function(data) { - if(data.exc) { - $("#comment-form .alert") - .html(data.exc) - .toggle(true) - } else { - $(data.message).appendTo(".blog-comments"); - $(".no_comment").toggle(false); - $(".add-comment").toggle(false); - $("#comment-form") - .replaceWith("
Thank you for your comment!
") - } - } - }) - - return false; - }) -}) \ No newline at end of file diff --git a/website/doctype/blog_post/templates/includes/blog_subscribe.html b/website/doctype/blog_post/templates/includes/blog_subscribe.html deleted file mode 100644 index 1238d837f0..0000000000 --- a/website/doctype/blog_post/templates/includes/blog_subscribe.html +++ /dev/null @@ -1,9 +0,0 @@ -

Subscribe

-
-

- -

-

- -RSS Feed -

\ No newline at end of file diff --git a/website/doctype/blog_post/templates/includes/blogger.html b/website/doctype/blog_post/templates/includes/blogger.html deleted file mode 100644 index 90c3571e7b..0000000000 --- a/website/doctype/blog_post/templates/includes/blogger.html +++ /dev/null @@ -1,13 +0,0 @@ -
-
-
- -
-
-
-

{{ blogger_info.full_name }}

-

{{ blogger_info.bio }}

-

- {{ texts.all_posts_by }} {{ blogger_info.full_name }}

-
-
\ No newline at end of file diff --git a/website/doctype/blog_post/templates/includes/comment.html b/website/doctype/blog_post/templates/includes/comment.html deleted file mode 100644 index 27baaad54d..0000000000 --- a/website/doctype/blog_post/templates/includes/comment.html +++ /dev/null @@ -1,17 +0,0 @@ -{# - this template generates comment rows for a blog - it is to be included in the blog/blog.html template -#} - -
- {% for comment in comment_list %} -
-
- {{ comment.comment_by_fullname }} / - {{ comment.comment_date }}: -
-

{{ comment.comment }}

-
-
- {% endfor %} -
\ No newline at end of file diff --git a/website/doctype/blog_settings/README.md b/website/doctype/blog_settings/README.md deleted file mode 100644 index 0a76d4e261..0000000000 --- a/website/doctype/blog_settings/README.md +++ /dev/null @@ -1 +0,0 @@ -Blog titles and introduction texts. \ No newline at end of file diff --git a/website/doctype/blog_settings/__init__.py b/website/doctype/blog_settings/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/website/doctype/blog_settings/blog_settings.py b/website/doctype/blog_settings/blog_settings.py deleted file mode 100644 index 784339de7d..0000000000 --- a/website/doctype/blog_settings/blog_settings.py +++ /dev/null @@ -1,11 +0,0 @@ -# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. -# License: GNU General Public License v3. See license.txt - -# For license information, please see license.txt - -from __future__ import unicode_literals -import webnotes - -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file diff --git a/website/doctype/blog_settings/blog_settings.txt b/website/doctype/blog_settings/blog_settings.txt deleted file mode 100644 index 27fa5630dd..0000000000 --- a/website/doctype/blog_settings/blog_settings.txt +++ /dev/null @@ -1,62 +0,0 @@ -[ - { - "creation": "2013-03-11 17:48:16", - "docstatus": 0, - "modified": "2013-07-05 14:27:31", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "description": "Blog Settings", - "doctype": "DocType", - "icon": "icon-cog", - "issingle": 1, - "module": "Website", - "name": "__common__" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Blog Settings", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "create": 1, - "doctype": "DocPerm", - "name": "__common__", - "parent": "Blog Settings", - "parentfield": "permissions", - "parenttype": "DocType", - "permlevel": 0, - "read": 1, - "role": "Website Manager", - "write": 1 - }, - { - "doctype": "DocType", - "name": "Blog Settings" - }, - { - "doctype": "DocField", - "fieldname": "blog_title", - "fieldtype": "Data", - "label": "Blog Title" - }, - { - "doctype": "DocField", - "fieldname": "blog_introduction", - "fieldtype": "Small Text", - "label": "Blog Introduction" - }, - { - "doctype": "DocField", - "fieldname": "writers_introduction", - "fieldtype": "Small Text", - "label": "Writers Introduction" - }, - { - "doctype": "DocPerm" - } -] \ No newline at end of file diff --git a/website/doctype/blogger/README.md b/website/doctype/blogger/README.md deleted file mode 100644 index 13ddecda70..0000000000 --- a/website/doctype/blogger/README.md +++ /dev/null @@ -1 +0,0 @@ -Profile of blog writer in "Blog" section. \ No newline at end of file diff --git a/website/doctype/blogger/__init__.py b/website/doctype/blogger/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/website/doctype/blogger/blogger.py b/website/doctype/blogger/blogger.py deleted file mode 100644 index fd646fded4..0000000000 --- a/website/doctype/blogger/blogger.py +++ /dev/null @@ -1,41 +0,0 @@ -# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. -# License: GNU General Public License v3. See license.txt - -# For license information, please see license.txt - -from __future__ import unicode_literals -import webnotes -from webnotes import _ - -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl - - def on_update(self): - "if profile is set, then update all older blogs" - - from website.doctype.blog_post.blog_post import clear_blog_cache - clear_blog_cache() - - if self.doc.profile: - for blog in webnotes.conn.sql_list("""select name from `tabBlog Post` where owner=%s - and ifnull(blogger,'')=''""", self.doc.profile): - b = webnotes.bean("Blog Post", blog) - b.doc.blogger = self.doc.name - b.save() - -def get_writers_args(): - bloggers = webnotes.conn.sql("""select * from `tabBlogger` - where ifnull(posts,0) > 0 and ifnull(disabled,0)=0 - order by posts desc""", as_dict=1) - - args = { - "bloggers": bloggers, - "texts": { - "all_posts_by": _("All posts by") - }, - "categories": webnotes.conn.sql_list("select name from `tabBlog Category` order by name") - } - - args.update(webnotes.doc("Blog Settings", "Blog Settings").fields) - return args \ No newline at end of file diff --git a/website/doctype/blogger/blogger.txt b/website/doctype/blogger/blogger.txt deleted file mode 100644 index 1486c01247..0000000000 --- a/website/doctype/blogger/blogger.txt +++ /dev/null @@ -1,102 +0,0 @@ -[ - { - "creation": "2013-03-25 16:00:51", - "docstatus": 0, - "modified": "2013-08-30 16:35:24", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "allow_attach": 1, - "autoname": "field:short_name", - "description": "Profile of a Blogger", - "doctype": "DocType", - "document_type": "Master", - "icon": "icon-user", - "max_attachments": 1, - "module": "Website", - "name": "__common__" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Blogger", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "doctype": "DocPerm", - "name": "__common__", - "parent": "Blogger", - "parentfield": "permissions", - "parenttype": "DocType", - "permlevel": 0, - "read": 1, - "write": 1 - }, - { - "doctype": "DocType", - "name": "Blogger" - }, - { - "doctype": "DocField", - "fieldname": "disabled", - "fieldtype": "Check", - "label": "Disabled" - }, - { - "description": "Will be used in url (usually first name).", - "doctype": "DocField", - "fieldname": "short_name", - "fieldtype": "Data", - "label": "Short Name", - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "full_name", - "fieldtype": "Data", - "in_list_view": 1, - "label": "Full Name", - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "profile", - "fieldtype": "Link", - "label": "Profile", - "options": "Profile" - }, - { - "doctype": "DocField", - "fieldname": "bio", - "fieldtype": "Small Text", - "label": "Bio" - }, - { - "doctype": "DocField", - "fieldname": "avatar", - "fieldtype": "Select", - "label": "Avatar", - "options": "attach_files:" - }, - { - "doctype": "DocField", - "fieldname": "posts", - "fieldtype": "Int", - "in_list_view": 1, - "label": "Posts", - "read_only": 1 - }, - { - "create": 1, - "doctype": "DocPerm", - "role": "Website Manager" - }, - { - "doctype": "DocPerm", - "match": "owner:profile", - "role": "Blogger" - } -] \ No newline at end of file diff --git a/website/doctype/blogger/templates/writers.html b/website/doctype/blogger/templates/writers.html deleted file mode 100644 index 5b254b0407..0000000000 --- a/website/doctype/blogger/templates/writers.html +++ /dev/null @@ -1,17 +0,0 @@ -{% extends "app/website/templates/html/page.html" %} - -{% set title="Blog Writers" %} - -{% block content %} -
-

Blog Writers

- {% if writers_introduction %} -

{{ writers_introduction }}

- {% endif %} -
- {% for blogger_info in bloggers %} - {% include "app/website/templates/html/blogger.html" %} - {% endfor %} -
-{% include 'app/website/templates/html/blog_footer.html' %} -{% endblock %} \ No newline at end of file diff --git a/website/doctype/company_history/README.md b/website/doctype/company_history/README.md deleted file mode 100644 index 482c8d33d5..0000000000 --- a/website/doctype/company_history/README.md +++ /dev/null @@ -1 +0,0 @@ -Company history detail for "About Us" section. \ No newline at end of file diff --git a/website/doctype/company_history/__init__.py b/website/doctype/company_history/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/website/doctype/company_history/company_history.py b/website/doctype/company_history/company_history.py deleted file mode 100644 index 784339de7d..0000000000 --- a/website/doctype/company_history/company_history.py +++ /dev/null @@ -1,11 +0,0 @@ -# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. -# License: GNU General Public License v3. See license.txt - -# For license information, please see license.txt - -from __future__ import unicode_literals -import webnotes - -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file diff --git a/website/doctype/company_history/company_history.txt b/website/doctype/company_history/company_history.txt deleted file mode 100644 index c0f230c347..0000000000 --- a/website/doctype/company_history/company_history.txt +++ /dev/null @@ -1,42 +0,0 @@ -[ - { - "creation": "2013-02-22 01:28:08", - "docstatus": 0, - "modified": "2013-07-10 14:54:06", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doctype": "DocType", - "istable": 1, - "module": "Website", - "name": "__common__" - }, - { - "doctype": "DocField", - "in_list_view": 1, - "name": "__common__", - "parent": "Company History", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "doctype": "DocType", - "name": "Company History" - }, - { - "doctype": "DocField", - "fieldname": "year", - "fieldtype": "Data", - "label": "Year" - }, - { - "doctype": "DocField", - "fieldname": "highlight", - "fieldtype": "Text", - "label": "Highlight", - "print_width": "300px", - "width": "300px" - } -] \ No newline at end of file diff --git a/website/doctype/contact_us_settings/README.md b/website/doctype/contact_us_settings/README.md deleted file mode 100644 index 61f589f796..0000000000 --- a/website/doctype/contact_us_settings/README.md +++ /dev/null @@ -1 +0,0 @@ -Settings, introduction for "Contact Us" section. \ No newline at end of file diff --git a/website/doctype/contact_us_settings/__init__.py b/website/doctype/contact_us_settings/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/website/doctype/contact_us_settings/contact_us_settings.py b/website/doctype/contact_us_settings/contact_us_settings.py deleted file mode 100644 index 37df106b0b..0000000000 --- a/website/doctype/contact_us_settings/contact_us_settings.py +++ /dev/null @@ -1,24 +0,0 @@ -# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. -# License: GNU General Public License v3. See license.txt - -# For license information, please see license.txt - -from __future__ import unicode_literals -import webnotes - -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl - - def onload(self): - """load address""" - if self.doc.query_options: - self.query_options = filter(None, self.doc.query_options.replace(",", "\n").split()) - else: - self.query_options = ["Sales", "Support", "General"] - if self.doc.address: - self.address = webnotes.bean("Address", self.doc.address).doc - - def on_update(self): - from webnotes.webutils import clear_cache - clear_cache("contact") \ No newline at end of file diff --git a/website/doctype/contact_us_settings/contact_us_settings.txt b/website/doctype/contact_us_settings/contact_us_settings.txt deleted file mode 100644 index 21db27efce..0000000000 --- a/website/doctype/contact_us_settings/contact_us_settings.txt +++ /dev/null @@ -1,82 +0,0 @@ -[ - { - "creation": "2013-02-21 20:12:42", - "docstatus": 0, - "modified": "2013-07-05 14:32:24", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "description": "Settings for Contact Us Page", - "doctype": "DocType", - "icon": "icon-cog", - "issingle": 1, - "module": "Website", - "name": "__common__" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Contact Us Settings", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "create": 1, - "doctype": "DocPerm", - "name": "__common__", - "parent": "Contact Us Settings", - "parentfield": "permissions", - "parenttype": "DocType", - "permlevel": 0, - "read": 1, - "report": 0, - "role": "Website Manager", - "submit": 0, - "write": 1 - }, - { - "doctype": "DocType", - "name": "Contact Us Settings" - }, - { - "doctype": "DocField", - "fieldname": "help", - "fieldtype": "HTML", - "label": "Help", - "options": "
Link for Contact Page is \"/contact\"
" - }, - { - "description": "Address to be displayed on the Contact Page", - "doctype": "DocField", - "fieldname": "address", - "fieldtype": "Link", - "label": "Address", - "options": "Address" - }, - { - "description": "Default: \"Contact Us\"", - "doctype": "DocField", - "fieldname": "heading", - "fieldtype": "Data", - "label": "Heading" - }, - { - "description": "Introductory information for the Contact Us Page", - "doctype": "DocField", - "fieldname": "introduction", - "fieldtype": "Text Editor", - "label": "Introduction" - }, - { - "description": "Contact options, like \"Sales Query, Support Query\" etc each on a new line or separated by commas.", - "doctype": "DocField", - "fieldname": "query_options", - "fieldtype": "Small Text", - "label": "Query Options" - }, - { - "doctype": "DocPerm" - } -] \ No newline at end of file diff --git a/website/doctype/contact_us_settings/templates/contact.html b/website/doctype/contact_us_settings/templates/contact.html deleted file mode 100644 index 86be163f8e..0000000000 --- a/website/doctype/contact_us_settings/templates/contact.html +++ /dev/null @@ -1,60 +0,0 @@ -{% extends "app/website/templates/html/page.html" %} - -{% block javascript %} - {% include "app/website/templates/js/contact.js" %} -{% endblock %} - -{% set title="Contact Us" %} - -{% block content %} -
-

{{ obj.doc.heading or "Contact Us"}}

-
-
- -

- -

-

- -

-

- -

-

- -

-
- {% if obj.doc.address %} -
-

{{ obj.address.address_title }}

- {% if obj.address.address_line1 %} - {{ obj.address.address_line1 }}
- {% endif %} - {% if obj.address.address_line2 %} - {{ obj.address.address_line2 }}
- {% endif %} - {% if obj.address.city %} - {{ obj.address.city }}
- {% endif %} - {% if obj.address.state %} - {{ obj.address.state }}
- {% endif %} - {% if obj.address.pincode %} - {{ obj.address.pincode }}
- {% endif %} - {% if obj.address.country %} - {{ obj.address.country }}
- {% endif %} -
- {% endif %} -
- {{ obj.doc.introduction }} -
-{% endblock %} \ No newline at end of file diff --git a/website/doctype/contact_us_settings/templates/includes/contact.js b/website/doctype/contact_us_settings/templates/includes/contact.js deleted file mode 100644 index dece898755..0000000000 --- a/website/doctype/contact_us_settings/templates/includes/contact.js +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. -// License: GNU General Public License v3. See license.txt - -$(document).ready(function() { - - $('.btn-send').click(function() { - var email = $('[name="email"]').val(); - var message = $('[name="message"]').val(); - - if(!(email && message)) { - msgprint("Please enter both your email and message so that we \ - can get back to you. Thanks!"); - return false; - } - - if(!valid_email(email)) { - msgprint("You seem to have written your name instead of your email. \ - Please enter a valid email address so that we can get back."); - $('[name="email"]').focus(); - return false; - } - - $("#contact-alert").toggle(false); - erpnext.send_message({ - subject: $('[name="subject"]').val(), - sender: email, - message: message, - callback: function(r) { - if(r.status==="okay") { - msgprint(r.message || "Thank you for your message.") - } else { - msgprint("There were errors"); - console.log(r.exc); - } - $(':input').val(''); - } - }); - return false; - }); - -}); - -var msgprint = function(txt) { - if(txt) $("#contact-alert").html(txt).toggle(true); -} diff --git a/website/doctype/shopping_cart_price_list/__init__.py b/website/doctype/shopping_cart_price_list/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/website/doctype/shopping_cart_price_list/shopping_cart_price_list.py b/website/doctype/shopping_cart_price_list/shopping_cart_price_list.py deleted file mode 100644 index 784339de7d..0000000000 --- a/website/doctype/shopping_cart_price_list/shopping_cart_price_list.py +++ /dev/null @@ -1,11 +0,0 @@ -# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. -# License: GNU General Public License v3. See license.txt - -# For license information, please see license.txt - -from __future__ import unicode_literals -import webnotes - -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file diff --git a/website/doctype/shopping_cart_price_list/shopping_cart_price_list.txt b/website/doctype/shopping_cart_price_list/shopping_cart_price_list.txt deleted file mode 100644 index 361edf69e2..0000000000 --- a/website/doctype/shopping_cart_price_list/shopping_cart_price_list.txt +++ /dev/null @@ -1,36 +0,0 @@ -[ - { - "creation": "2013-06-20 16:00:18", - "docstatus": 0, - "modified": "2013-08-09 14:47:12", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doctype": "DocType", - "istable": 1, - "module": "Website", - "name": "__common__" - }, - { - "doctype": "DocField", - "fieldname": "selling_price_list", - "fieldtype": "Link", - "in_list_view": 1, - "label": "Price List", - "name": "__common__", - "options": "Price List", - "parent": "Shopping Cart Price List", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0, - "reqd": 1 - }, - { - "doctype": "DocType", - "name": "Shopping Cart Price List" - }, - { - "doctype": "DocField" - } -] \ No newline at end of file diff --git a/website/doctype/shopping_cart_settings/__init__.py b/website/doctype/shopping_cart_settings/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/website/doctype/shopping_cart_settings/shopping_cart_settings.js b/website/doctype/shopping_cart_settings/shopping_cart_settings.js deleted file mode 100644 index c38c757a5e..0000000000 --- a/website/doctype/shopping_cart_settings/shopping_cart_settings.js +++ /dev/null @@ -1,10 +0,0 @@ -// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. -// License: GNU General Public License v3. See license.txt - -$.extend(cur_frm.cscript, { - onload: function() { - if(cur_frm.doc.__quotation_series) { - cur_frm.fields_dict.quotation_series.df.options = cur_frm.doc.__quotation_series; - } - } -}); \ No newline at end of file diff --git a/website/doctype/shopping_cart_settings/shopping_cart_settings.py b/website/doctype/shopping_cart_settings/shopping_cart_settings.py deleted file mode 100644 index 74cc217d28..0000000000 --- a/website/doctype/shopping_cart_settings/shopping_cart_settings.py +++ /dev/null @@ -1,149 +0,0 @@ -# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. -# License: GNU General Public License v3. See license.txt - -# For license information, please see license.txt - -from __future__ import unicode_literals -import webnotes -from webnotes import _, msgprint -from webnotes.utils import comma_and -from webnotes.model.controller import DocListController - -class ShoppingCartSetupError(webnotes.ValidationError): pass - -class DocType(DocListController): - def onload(self): - self.doc.fields["__quotation_series"] = webnotes.get_doctype("Quotation").get_options("naming_series") - - def validate(self): - if self.doc.enabled: - self.validate_price_lists() - self.validate_tax_masters() - self.validate_exchange_rates_exist() - - def on_update(self): - webnotes.conn.set_default("shopping_cart_enabled", self.doc.fields.get("enabled") or 0) - webnotes.conn.set_default("shopping_cart_quotation_series", self.doc.fields.get("quotation_series")) - - def validate_overlapping_territories(self, parentfield, fieldname): - # for displaying message - doctype = self.meta.get_field(parentfield).options - - # specify atleast one entry in the table - self.validate_table_has_rows(parentfield, raise_exception=ShoppingCartSetupError) - - territory_name_map = self.get_territory_name_map(parentfield, fieldname) - for territory, names in territory_name_map.items(): - if len(names) > 1: - msgprint(_("Error for") + " " + _(doctype) + ": " + comma_and(names) + - " " + _("have a common territory") + ": " + territory, - raise_exception=ShoppingCartSetupError) - - return territory_name_map - - def validate_price_lists(self): - territory_name_map = self.validate_overlapping_territories("price_lists", - "selling_price_list") - - # validate that a Shopping Cart Price List exists for the root territory - # as a catch all! - from setup.utils import get_root_of - root_territory = get_root_of("Territory") - - if root_territory not in territory_name_map.keys(): - msgprint(_("Please specify a Price List which is valid for Territory") + - ": " + root_territory, raise_exception=ShoppingCartSetupError) - - def validate_tax_masters(self): - self.validate_overlapping_territories("sales_taxes_and_charges_masters", - "sales_taxes_and_charges_master") - - def get_territory_name_map(self, parentfield, fieldname): - territory_name_map = {} - - # entries in table - names = [doc.fields.get(fieldname) for doc in self.doclist.get({"parentfield": parentfield})] - - if names: - # for condition in territory check - parenttype = self.meta.get_field(fieldname, parentfield=parentfield).options - - # to validate territory overlap - # make a map of territory: [list of names] - # if list against each territory has more than one element, raise exception - territory_name = webnotes.conn.sql("""select `territory`, `parent` - from `tabFor Territory` - where `parenttype`=%s and `parent` in (%s)""" % - ("%s", ", ".join(["%s"]*len(names))), tuple([parenttype] + names)) - - for territory, name in territory_name: - territory_name_map.setdefault(territory, []).append(name) - - if len(territory_name_map[territory]) > 1: - territory_name_map[territory].sort(key=lambda val: names.index(val)) - - return territory_name_map - - def validate_exchange_rates_exist(self): - """check if exchange rates exist for all Price List currencies (to company's currency)""" - company_currency = webnotes.conn.get_value("Company", self.doc.company, "default_currency") - if not company_currency: - msgprint(_("Please specify currency in Company") + ": " + self.doc.company, - raise_exception=ShoppingCartSetupError) - - price_list_currency_map = webnotes.conn.get_values("Price List", - [d.selling_price_list for d in self.doclist.get({"parentfield": "price_lists"})], - "currency") - - expected_to_exist = [currency + "-" + company_currency - for currency in price_list_currency_map.values() - if currency != company_currency] - - if expected_to_exist: - exists = webnotes.conn.sql_list("""select name from `tabCurrency Exchange` - where name in (%s)""" % (", ".join(["%s"]*len(expected_to_exist)),), - tuple(expected_to_exist)) - - missing = list(set(expected_to_exist).difference(exists)) - - if missing: - msgprint(_("Missing Currency Exchange Rates for" + ": " + comma_and(missing)), - raise_exception=ShoppingCartSetupError) - - def get_name_from_territory(self, territory, parentfield, fieldname): - name = None - territory_name_map = self.get_territory_name_map(parentfield, fieldname) - - if territory_name_map.get(territory): - name = territory_name_map.get(territory) - else: - territory_ancestry = self.get_territory_ancestry(territory) - for ancestor in territory_ancestry: - if territory_name_map.get(ancestor): - name = territory_name_map.get(ancestor) - break - - return name - - def get_price_list(self, billing_territory): - price_list = self.get_name_from_territory(billing_territory, "price_lists", "selling_price_list") - return price_list and price_list[0] or None - - def get_tax_master(self, billing_territory): - tax_master = self.get_name_from_territory(billing_territory, "sales_taxes_and_charges_masters", - "sales_taxes_and_charges_master") - return tax_master and tax_master[0] or None - - def get_shipping_rules(self, shipping_territory): - return self.get_name_from_territory(shipping_territory, "shipping_rules", "shipping_rule") - - def get_territory_ancestry(self, territory): - from setup.utils import get_ancestors_of - - if not hasattr(self, "_territory_ancestry"): - self._territory_ancestry = {} - - if not self._territory_ancestry.get(territory): - self._territory_ancestry[territory] = get_ancestors_of("Territory", territory) - - return self._territory_ancestry[territory] \ No newline at end of file diff --git a/website/doctype/shopping_cart_settings/shopping_cart_settings.txt b/website/doctype/shopping_cart_settings/shopping_cart_settings.txt deleted file mode 100644 index 21e6ee37c4..0000000000 --- a/website/doctype/shopping_cart_settings/shopping_cart_settings.txt +++ /dev/null @@ -1,125 +0,0 @@ -[ - { - "creation": "2013-06-19 15:57:32", - "docstatus": 0, - "modified": "2013-07-15 17:33:05", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "description": "Default settings for Shopping Cart", - "doctype": "DocType", - "icon": "icon-shopping-cart", - "issingle": 1, - "module": "Website", - "name": "__common__" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Shopping Cart Settings", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "create": 1, - "doctype": "DocPerm", - "name": "__common__", - "parent": "Shopping Cart Settings", - "parentfield": "permissions", - "parenttype": "DocType", - "permlevel": 0, - "read": 1, - "role": "Website Manager", - "write": 1 - }, - { - "doctype": "DocType", - "name": "Shopping Cart Settings" - }, - { - "doctype": "DocField", - "fieldname": "enabled", - "fieldtype": "Check", - "label": "Enable Shopping Cart" - }, - { - "doctype": "DocField", - "fieldname": "section_break_2", - "fieldtype": "Section Break" - }, - { - "doctype": "DocField", - "fieldname": "company", - "fieldtype": "Link", - "label": "Company", - "options": "Company", - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "default_territory", - "fieldtype": "Link", - "label": "Default Territory", - "options": "Territory", - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "column_break_4", - "fieldtype": "Column Break" - }, - { - "doctype": "DocField", - "fieldname": "default_customer_group", - "fieldtype": "Link", - "label": "Default Customer Group", - "options": "Customer Group", - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "quotation_series", - "fieldtype": "Select", - "label": "Quotation Series", - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "section_break_6", - "fieldtype": "Section Break" - }, - { - "doctype": "DocField", - "fieldname": "price_lists", - "fieldtype": "Table", - "label": "Shopping Cart Price Lists", - "options": "Shopping Cart Price List", - "reqd": 0 - }, - { - "doctype": "DocField", - "fieldname": "shipping_rules", - "fieldtype": "Table", - "label": "Shopping Cart Shipping Rules", - "options": "Shopping Cart Shipping Rule", - "reqd": 0 - }, - { - "doctype": "DocField", - "fieldname": "column_break_10", - "fieldtype": "Column Break" - }, - { - "doctype": "DocField", - "fieldname": "sales_taxes_and_charges_masters", - "fieldtype": "Table", - "label": "Shopping Cart Taxes and Charges Masters", - "options": "Shopping Cart Taxes and Charges Master", - "reqd": 0 - }, - { - "doctype": "DocPerm" - } -] \ No newline at end of file diff --git a/website/doctype/shopping_cart_settings/test_shopping_cart_settings.py b/website/doctype/shopping_cart_settings/test_shopping_cart_settings.py deleted file mode 100644 index 3417cec13a..0000000000 --- a/website/doctype/shopping_cart_settings/test_shopping_cart_settings.py +++ /dev/null @@ -1,81 +0,0 @@ -# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. -# License: GNU General Public License v3. See license.txt - -# For license information, please see license.txt - -from __future__ import unicode_literals -import webnotes -import unittest -from website.doctype.shopping_cart_settings.shopping_cart_settings import ShoppingCartSetupError - -class TestShoppingCartSettings(unittest.TestCase): - def setUp(self): - webnotes.conn.sql("""delete from `tabSingles` where doctype="Shipping Cart Settings" """) - webnotes.conn.sql("""delete from `tabShopping Cart Price List`""") - webnotes.conn.sql("""delete from `tabShopping Cart Taxes and Charges Master`""") - webnotes.conn.sql("""delete from `tabShopping Cart Shipping Rule`""") - - def get_cart_settings(self): - return webnotes.bean({"doctype": "Shopping Cart Settings", - "company": "_Test Company"}) - - def test_price_list_territory_overlap(self): - cart_settings = self.get_cart_settings() - - def _add_price_list(price_list): - cart_settings.doclist.append({ - "doctype": "Shopping Cart Price List", - "parentfield": "price_lists", - "selling_price_list": price_list - }) - - for price_list in ("_Test Price List Rest of the World", "_Test Price List India", - "_Test Price List"): - _add_price_list(price_list) - - controller = cart_settings.make_controller() - controller.validate_overlapping_territories("price_lists", "selling_price_list") - - _add_price_list("_Test Price List 2") - - controller = cart_settings.make_controller() - self.assertRaises(ShoppingCartSetupError, controller.validate_overlapping_territories, - "price_lists", "selling_price_list") - - return cart_settings - - def test_taxes_territory_overlap(self): - cart_settings = self.get_cart_settings() - - def _add_tax_master(tax_master): - cart_settings.doclist.append({ - "doctype": "Shopping Cart Taxes and Charges Master", - "parentfield": "sales_taxes_and_charges_masters", - "sales_taxes_and_charges_master": tax_master - }) - - for tax_master in ("_Test Sales Taxes and Charges Master", "_Test India Tax Master"): - _add_tax_master(tax_master) - - controller = cart_settings.make_controller() - controller.validate_overlapping_territories("sales_taxes_and_charges_masters", - "sales_taxes_and_charges_master") - - _add_tax_master("_Test Sales Taxes and Charges Master 2") - - controller = cart_settings.make_controller() - self.assertRaises(ShoppingCartSetupError, controller.validate_overlapping_territories, - "sales_taxes_and_charges_masters", "sales_taxes_and_charges_master") - - def test_exchange_rate_exists(self): - webnotes.conn.sql("""delete from `tabCurrency Exchange`""") - - cart_settings = self.test_price_list_territory_overlap() - controller = cart_settings.make_controller() - self.assertRaises(ShoppingCartSetupError, controller.validate_exchange_rates_exist) - - from setup.doctype.currency_exchange.test_currency_exchange import test_records as \ - currency_exchange_records - webnotes.bean(currency_exchange_records[0]).insert() - controller.validate_exchange_rates_exist() - diff --git a/website/doctype/shopping_cart_shipping_rule/__init__.py b/website/doctype/shopping_cart_shipping_rule/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/website/doctype/shopping_cart_shipping_rule/shopping_cart_shipping_rule.py b/website/doctype/shopping_cart_shipping_rule/shopping_cart_shipping_rule.py deleted file mode 100644 index 784339de7d..0000000000 --- a/website/doctype/shopping_cart_shipping_rule/shopping_cart_shipping_rule.py +++ /dev/null @@ -1,11 +0,0 @@ -# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. -# License: GNU General Public License v3. See license.txt - -# For license information, please see license.txt - -from __future__ import unicode_literals -import webnotes - -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file diff --git a/website/doctype/shopping_cart_shipping_rule/shopping_cart_shipping_rule.txt b/website/doctype/shopping_cart_shipping_rule/shopping_cart_shipping_rule.txt deleted file mode 100644 index 302b0aef8e..0000000000 --- a/website/doctype/shopping_cart_shipping_rule/shopping_cart_shipping_rule.txt +++ /dev/null @@ -1,36 +0,0 @@ -[ - { - "creation": "2013-07-03 13:15:34", - "docstatus": 0, - "modified": "2013-07-10 14:54:23", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doctype": "DocType", - "istable": 1, - "module": "Website", - "name": "__common__" - }, - { - "doctype": "DocField", - "fieldname": "shipping_rule", - "fieldtype": "Link", - "in_list_view": 1, - "label": "Shipping Rule", - "name": "__common__", - "options": "Shipping Rule", - "parent": "Shopping Cart Shipping Rule", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0, - "reqd": 1 - }, - { - "doctype": "DocType", - "name": "Shopping Cart Shipping Rule" - }, - { - "doctype": "DocField" - } -] \ No newline at end of file diff --git a/website/doctype/shopping_cart_taxes_and_charges_master/__init__.py b/website/doctype/shopping_cart_taxes_and_charges_master/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/website/doctype/shopping_cart_taxes_and_charges_master/shopping_cart_taxes_and_charges_master.py b/website/doctype/shopping_cart_taxes_and_charges_master/shopping_cart_taxes_and_charges_master.py deleted file mode 100644 index 784339de7d..0000000000 --- a/website/doctype/shopping_cart_taxes_and_charges_master/shopping_cart_taxes_and_charges_master.py +++ /dev/null @@ -1,11 +0,0 @@ -# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. -# License: GNU General Public License v3. See license.txt - -# For license information, please see license.txt - -from __future__ import unicode_literals -import webnotes - -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file diff --git a/website/doctype/shopping_cart_taxes_and_charges_master/shopping_cart_taxes_and_charges_master.txt b/website/doctype/shopping_cart_taxes_and_charges_master/shopping_cart_taxes_and_charges_master.txt deleted file mode 100644 index f00a23d2e6..0000000000 --- a/website/doctype/shopping_cart_taxes_and_charges_master/shopping_cart_taxes_and_charges_master.txt +++ /dev/null @@ -1,36 +0,0 @@ -[ - { - "creation": "2013-06-20 16:57:03", - "docstatus": 0, - "modified": "2013-07-10 14:54:23", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doctype": "DocType", - "istable": 1, - "module": "Website", - "name": "__common__" - }, - { - "doctype": "DocField", - "fieldname": "sales_taxes_and_charges_master", - "fieldtype": "Link", - "in_list_view": 1, - "label": "Tax Master", - "name": "__common__", - "options": "Sales Taxes and Charges Master", - "parent": "Shopping Cart Taxes and Charges Master", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0, - "reqd": 1 - }, - { - "doctype": "DocType", - "name": "Shopping Cart Taxes and Charges Master" - }, - { - "doctype": "DocField" - } -] \ No newline at end of file diff --git a/website/doctype/style_settings/README.md b/website/doctype/style_settings/README.md deleted file mode 100644 index de9d0cd57f..0000000000 --- a/website/doctype/style_settings/README.md +++ /dev/null @@ -1,6 +0,0 @@ -Style settings for website. Includes settings for: - -- Site colours (background, toolbars) -- Fonts (family and size) -- Background (image if any) -- Custom CSS \ No newline at end of file diff --git a/website/doctype/style_settings/__init__.py b/website/doctype/style_settings/__init__.py deleted file mode 100644 index baffc48825..0000000000 --- a/website/doctype/style_settings/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from __future__ import unicode_literals diff --git a/website/doctype/style_settings/custom_template.css b/website/doctype/style_settings/custom_template.css deleted file mode 100644 index 7abdb4b89f..0000000000 --- a/website/doctype/style_settings/custom_template.css +++ /dev/null @@ -1,235 +0,0 @@ -{% if doc.at_import %} -{{ doc.at_import }} -{% endif %} - -body { -{% if doc.background_image %} - background: url("../{{ doc.background_image }}") repeat; -{% elif doc.background_color %} - background-color: #{{ doc.background_color }}; - background-image: none; -{% else %} - background-color: #ffffff; -{% endif %} -{% if doc.font or doc.google_web_font_for_text %} - font-family: '{{ doc.google_web_font_for_text or doc.font }}', 'Helvetica Neue', Arial, Sans !important; -{% endif %} - {% if doc.font_size %}font-size: {{ doc.font_size }} !important;{% endif %} - {% if doc.page_text %}color: #{{ doc.page_text }};{% endif %} -} - -{% if doc.page_links %}a, a:hover { - color: #{{ doc.page_links }}; -}{% endif %} - -{% if doc.font_size %} -.small { - font-size: {{ doc.small_font_size }} !important; -} -{% endif %} - -div.outer { - background-color: #{{ doc.page_background }}; -} - -{% if doc.google_web_font_for_heading or doc.heading_font %}h1, h2, h3, h4, h5 { - font-family: '{{ doc.google_web_font_for_heading or doc.heading_font }}', 'Helvetica Neue', Arial !important; -}{% endif %} - -{% if doc.heading_text_style %}h1, h2, h3, h4, h5 { - text-transform: {{ doc.heading_text_style }}; -}{% endif %} - -{% if doc.page_headings %}h1, h2, h3, h4, h5 { - color: #{{ doc.page_headings }}; -}{% endif %} - -{% if doc.page_border %} -/* Page Border*/ -div.outer { - box-shadow: 0 0 8px rgba(0, 0, 0, 0.2); - -moz-box-shadow: 0 0 8px rgba(0, 0, 0, 0.2); - -webkibox-shadow: 0 0 8px rgba(0, 0, 0, 0.2); -} -{% else %} -{% if doc.background_color.lower() == doc.page_background.lower() %} -div.web-footer { - border-top: 1px solid #{{ get_hex_shade(doc.page_background, 15) }}; - padding-top: 10px; -} -{% endif %} -{% endif %} - -div.web-footer, div.web-footer a { - font-size: 90%; - color: #{{ get_hex_shade(doc.background_color, 70) }}; -} - -/* Bootstrap Navbar */ -.navbar-default { - border: 0px; -} - -.navbar { - box-shadow: none; - border-radius: 0px; - background-color: #{{ doc.top_bar_background}}; - background-repeat: repeat-x; - background-image: none; - border-bottom: 1px solid {% if doc.top_bar_background.lower() == doc.page_background.lower() -%} - #{{ get_hex_shade(doc.page_background, 15) }}; - {%- else -%} - transparent; - {%- endif %} -} - -.navbar .navbar-brand, -.navbar .navbar-brand:hover, -.navbar .navbar-brand:focus, -.navbar .nav > li > a { - color: #{{ doc.top_bar_foreground }}; - text-shadow: none; -} - -.navbar .nav > li > a:hover, -.navbar .nav > li > a:focus { - color: #{{ doc.top_bar_foreground }}; - background-color: transparent; -} - -.navbar .navbar-text { - color: #999999; -} - -.navbar .nav .active > a, -.navbar .nav .active > a:hover, -.navbar .nav .active > a:focus { - color: #{{ doc.top_bar_foreground }}; - background-color: transparent; -} - -.navbar .navbar-link { - color: #444444; -} - -.navbar .navbar-link:hover, -.navbar .navbar-link:focus { - color: #{{ doc.top_bar_foreground}}; -} - -.navbar-fixed-top, -.navbar-static-top { - -webkit-box-shadow: none; - -moz-box-shadow: none; - box-shadow: none; - -} -.navbar .nav > .active > a, -.navbar .nav > .active > a:hover, -.navbar .nav > .active > a:focus { - color: #424242; - text-decoration: none; - background-color: transparent; - -webkit-box-shadow: none; - -moz-box-shadow: none; - box-shadow: none; -} - -.navbar .nav li.dropdown > .dropdown-toggle .caret, -.navbar .nav li.dropdown > .dropdown-toggle:hover .caret { - border-top-color: #{{ doc.top_bar_foreground}}; - border-bottom-color: #{{ doc.top_bar_foreground}}; -} - -.navbar .nav li.dropdown.open > .dropdown-toggle .caret, -.navbar .nav li.dropdown.open > .dropdown-toggle:hover .caret { - border-top-color: #{{ doc.top_bar_background}}; - border-bottom-color: #{{ doc.top_bar_background}}; -} - -.navbar .nav li.dropdown.open > .dropdown-toggle { - color: #{{ doc.top_bar_background}}; - background-color: #{{ doc.top_bar_foreground}}; -} - -@media (max-width: 800px) { - .navbar .nav-collapse .nav > li > a, - .navbar .nav-collapse .dropdown-menu a { - background-color: #{{ doc.top_bar_background}}; - color: #{{ doc.top_bar_foreground}}; - } - .navbar .nav-collapse .nav > li > a:hover, - .navbar .nav-collapse .dropdown-menu a:hover { - background-color: #{{ doc.top_bar_foreground}}; - color: #{{ doc.top_bar_background}}; - } - - .navbar .nav li.dropdown > .dropdown-toggle .caret { - border-top-color: #{{ doc.top_bar_foreground }}; - border-bottom-color: #{{ doc.top_bar_foreground }}; - } - - .navbar .nav li.dropdown > .dropdown-toggle:hover .caret { - border-top-color: #{{ doc.top_bar_foreground }}; - border-bottom-color: #{{ doc.top_bar_foreground }}; - } - - .navbar .nav li.dropdown.open > .dropdown-toggle .caret, - .navbar .nav li.dropdown.open > .dropdown-toggle:hover .caret { - border-top-color: #{{ doc.top_bar_background }}; - border-bottom-color: #{{ doc.top_bar_background }}; - } - -} - -.navbar-default .navbar-toggle .icon-bar { - background-color: #{{ doc.top_bar_foreground }}; -} - -.breadcrumb { - background-color: #{{ get_hex_shade(doc.page_background, 5) }}; -} - -.breadcrumb > li { - text-shadow: none; -} - - -.table-striped tbody > tr:nth-child(odd) > td, -.table-striped tbody > tr:nth-child(odd) > th { - background-color: #{{ get_hex_shade(doc.page_background, 5) }}; -} - -.table-hover tbody tr:hover td, -.table-hover tbody tr:hover th { - background-color: #{{ get_hex_shade(doc.page_background, 10) }}; -} - -.table-bordered { - border: 1px solid #{{ get_hex_shade(doc.page_background, 15) }}; -} - -.table th, -.table td { - border-top: 1px solid #{{ get_hex_shade(doc.page_background, 15) }}; -} - -.table-bordered th, -.table-bordered td { - border-left: 1px solid #{{ get_hex_shade(doc.page_background, 15) }}; -} - - - -.hero-unit { - background-color: #{{ get_hex_shade(doc.page_background, 15) }}; -} - -pre, code { - background-color: #{{ get_hex_shade(doc.page_background, 5) }}; -} - -hr { - border-top: 1px solid #{{ get_hex_shade(doc.page_background, 15) }}; - border-bottom: 1px solid #{{ get_hex_shade(doc.page_background, 5) }}; -} diff --git a/website/doctype/style_settings/style_settings.js b/website/doctype/style_settings/style_settings.js deleted file mode 100644 index f94246d22c..0000000000 --- a/website/doctype/style_settings/style_settings.js +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. -// License: GNU General Public License v3. See license.txt - - -cur_frm.cscript.onload_post_render = function() { - wn.require('lib/public/js/lib/jscolor/jscolor.js'); - $.each(["background_color", "page_background", "page_text", "page_links", - "top_bar_background", "top_bar_foreground", "page_headings"], function(i, v) { - $(cur_frm.fields_dict[v].input).addClass('color'); - }) - jscolor.bind(); -} \ No newline at end of file diff --git a/website/doctype/style_settings/style_settings.py b/website/doctype/style_settings/style_settings.py deleted file mode 100644 index 073d3f9e23..0000000000 --- a/website/doctype/style_settings/style_settings.py +++ /dev/null @@ -1,98 +0,0 @@ -# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. -# License: GNU General Public License v3. See license.txt - -from __future__ import unicode_literals -import webnotes - -from webnotes.utils import cint, cstr -from webnotes import _ - -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl - - def validate(self): - """make custom css""" - from jinja2 import Template - from webnotes.webutils import get_hex_shade - import os - - default_colours = { - "background_color": "FFFFFF", - "page_background": "FFFFFF", - "top_bar_background": "FFFFFF", - "top_bar_foreground": "444444", - "page_headings": "222222", - "page_text": "000000" - } - - for d in default_colours: - if not self.doc.fields.get(d): - self.doc.fields[d] = default_colours[d] - - self.validate_colors() - - with open(os.path.join( - os.path.dirname(os.path.abspath(__file__)), - 'custom_template.css'), 'r') as f: - temp = Template(f.read()) - - self.prepare() - - self.doc.custom_css = temp.render(doc = self.doc, get_hex_shade=get_hex_shade) - if self.doc.add_css: - self.doc.custom_css += '\n\n/* User CSS */\n\n' + self.doc.add_css - - from webnotes.sessions import clear_cache - clear_cache('Guest') - - from webnotes.webutils import clear_cache - clear_cache() - - for f in ["small_font_size", "at_import", "heading_text_style"]: - if f in self.doc.fields: - del self.doc.fields[f] - - def validate_colors(self): - if (self.doc.page_background or self.doc.page_text) and \ - self.doc.page_background==self.doc.page_text: - webnotes.msgprint(_("Page text and background is same color. Please change."), - raise_exception=1) - - if (self.doc.top_bar_background or self.doc.top_bar_foreground) and \ - self.doc.top_bar_background==self.doc.top_bar_foreground: - webnotes.msgprint(_("Top Bar text and background is same color. Please change."), - raise_exception=1) - - - def prepare(self): - if not self.doc.font_size: - self.doc.font_size = '13px' - - self.doc.small_font_size = cstr(cint(self.doc.font_size[:-2])-2) + 'px' - self.doc.page_border = cint(self.doc.page_border) - - fonts = [] - if self.doc.google_web_font_for_heading: - fonts.append(self.doc.google_web_font_for_heading) - if self.doc.google_web_font_for_text: - fonts.append(self.doc.google_web_font_for_text) - - fonts = list(set(fonts)) - - if self.doc.heading_text_as: - self.doc.heading_text_style = { - "UPPERCASE": "uppercase", - "Title Case":"capitalize", - "lowercase": "lowercase" - }.get(self.doc.heading_text_as) or "" - - self.doc.at_import = "" - for f in fonts: - self.doc.at_import += "\n@import url(https://fonts.googleapis.com/css?family=%s:400,700);" % f.replace(" ", "+") - - - def on_update(self): - """rebuild pages""" - from website.doctype.website_settings.make_web_include_files import make - make() \ No newline at end of file diff --git a/website/doctype/style_settings/style_settings.txt b/website/doctype/style_settings/style_settings.txt deleted file mode 100644 index 7119d2c250..0000000000 --- a/website/doctype/style_settings/style_settings.txt +++ /dev/null @@ -1,201 +0,0 @@ -[ - { - "creation": "2013-03-25 16:01:33", - "docstatus": 0, - "modified": "2013-07-05 14:57:01", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "allow_attach": 1, - "description": "Set your background color, font and image (tiled)", - "doctype": "DocType", - "icon": "icon-cog", - "issingle": 1, - "max_attachments": 1, - "module": "Website", - "name": "__common__" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Style Settings", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "doctype": "DocPerm", - "name": "__common__", - "parent": "Style Settings", - "parentfield": "permissions", - "parenttype": "DocType", - "read": 1, - "report": 0, - "role": "Website Manager", - "submit": 0 - }, - { - "doctype": "DocType", - "name": "Style Settings" - }, - { - "doctype": "DocField", - "fieldname": "color", - "fieldtype": "Section Break", - "label": "Color" - }, - { - "description": "If image is selected, color will be ignored (attach first)", - "doctype": "DocField", - "fieldname": "background_image", - "fieldtype": "Select", - "label": "Background Image", - "options": "attach_files:" - }, - { - "description": "Solid background color (default light gray)", - "doctype": "DocField", - "fieldname": "background_color", - "fieldtype": "Data", - "label": "Background Color" - }, - { - "doctype": "DocField", - "fieldname": "page_background", - "fieldtype": "Data", - "label": "Page Background" - }, - { - "doctype": "DocField", - "fieldname": "page_border", - "fieldtype": "Check", - "label": "Page Border" - }, - { - "doctype": "DocField", - "fieldname": "page_headings", - "fieldtype": "Data", - "label": "Page Headings" - }, - { - "doctype": "DocField", - "fieldname": "page_text", - "fieldtype": "Data", - "label": "Page Text" - }, - { - "doctype": "DocField", - "fieldname": "page_links", - "fieldtype": "Data", - "label": "Page Links" - }, - { - "doctype": "DocField", - "fieldname": "cb0", - "fieldtype": "Column Break", - "label": "Top Bar", - "print_width": "50%", - "width": "50%" - }, - { - "doctype": "DocField", - "fieldname": "top_bar_background", - "fieldtype": "Data", - "label": "Top Bar Background" - }, - { - "description": "000 is black, fff is white", - "doctype": "DocField", - "fieldname": "top_bar_foreground", - "fieldtype": "Data", - "label": "Top Bar Text" - }, - { - "doctype": "DocField", - "fieldname": "fonts", - "fieldtype": "Section Break", - "label": "Fonts" - }, - { - "doctype": "DocField", - "fieldname": "heading_font", - "fieldtype": "Select", - "label": "Font (Heading)", - "options": "\nHelvetica Neue\nLucida Grande\nVerdana\nArial\nGeorgia\nTahoma\nLato\nOpen Sans" - }, - { - "doctype": "DocField", - "fieldname": "font", - "fieldtype": "Select", - "label": "Font (Text)", - "options": "\nHelvetica Neue\nLucida Grande\nVerdana\nArial\nGeorgia\nTahoma" - }, - { - "doctype": "DocField", - "fieldname": "font_size", - "fieldtype": "Select", - "label": "Font Size (Text)", - "options": "\n12px\n13px\n14px\n15px\n16px" - }, - { - "doctype": "DocField", - "fieldname": "heading_text_as", - "fieldtype": "Select", - "label": "Heading Text As", - "options": "\nUPPERCASE\nTitle Case\nlowercase" - }, - { - "doctype": "DocField", - "fieldname": "column_break_13", - "fieldtype": "Column Break" - }, - { - "description": "Add the name of Google Web Font e.g. \"Open Sans\"", - "doctype": "DocField", - "fieldname": "google_web_font_for_heading", - "fieldtype": "Data", - "label": "Google Web Font (Heading)" - }, - { - "description": "Add the name of Google Web Font e.g. \"Open Sans\"", - "doctype": "DocField", - "fieldname": "google_web_font_for_text", - "fieldtype": "Data", - "label": "Google Web Font (Text)" - }, - { - "doctype": "DocField", - "fieldname": "css", - "fieldtype": "Section Break", - "label": "CSS" - }, - { - "description": "add your own CSS (careful!)", - "doctype": "DocField", - "fieldname": "add_css", - "fieldtype": "Code", - "label": "Add CSS" - }, - { - "description": "Auto generated", - "doctype": "DocField", - "fieldname": "custom_css", - "fieldtype": "Code", - "label": "Custom CSS", - "read_only": 1 - }, - { - "create": 1, - "doctype": "DocPerm", - "permlevel": 0, - "write": 1 - }, - { - "amend": 0, - "cancel": 0, - "create": 0, - "doctype": "DocPerm", - "permlevel": 1 - } -] \ No newline at end of file diff --git a/website/doctype/top_bar_item/README.md b/website/doctype/top_bar_item/README.md deleted file mode 100644 index 3300367c7d..0000000000 --- a/website/doctype/top_bar_item/README.md +++ /dev/null @@ -1 +0,0 @@ -Link in the header or footer of the website. \ No newline at end of file diff --git a/website/doctype/top_bar_item/__init__.py b/website/doctype/top_bar_item/__init__.py deleted file mode 100644 index baffc48825..0000000000 --- a/website/doctype/top_bar_item/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from __future__ import unicode_literals diff --git a/website/doctype/top_bar_item/top_bar_item.py b/website/doctype/top_bar_item/top_bar_item.py deleted file mode 100644 index 26d0f76968..0000000000 --- a/website/doctype/top_bar_item/top_bar_item.py +++ /dev/null @@ -1,9 +0,0 @@ -# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. -# License: GNU General Public License v3. See license.txt - -from __future__ import unicode_literals -import webnotes - -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file diff --git a/website/doctype/top_bar_item/top_bar_item.txt b/website/doctype/top_bar_item/top_bar_item.txt deleted file mode 100644 index 58d101e12a..0000000000 --- a/website/doctype/top_bar_item/top_bar_item.txt +++ /dev/null @@ -1,57 +0,0 @@ -[ - { - "creation": "2013-02-22 01:28:08", - "docstatus": 0, - "modified": "2013-07-10 14:54:25", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doctype": "DocType", - "istable": 1, - "module": "Website", - "name": "__common__" - }, - { - "doctype": "DocField", - "in_list_view": 1, - "name": "__common__", - "parent": "Top Bar Item", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "doctype": "DocType", - "name": "Top Bar Item" - }, - { - "doctype": "DocField", - "fieldname": "label", - "fieldtype": "Data", - "label": "Label", - "print_width": "120px", - "width": "120px" - }, - { - "doctype": "DocField", - "fieldname": "url", - "fieldtype": "Data", - "label": "URL", - "print_width": "200px", - "width": "200px" - }, - { - "doctype": "DocField", - "fieldname": "target", - "fieldtype": "Select", - "label": "Target", - "options": "\ntarget = \"_blank\"" - }, - { - "doctype": "DocField", - "fieldname": "parent_label", - "fieldtype": "Select", - "label": "Parent Label" - } -] \ No newline at end of file diff --git a/website/doctype/web_page/README.md b/website/doctype/web_page/README.md deleted file mode 100644 index 1ef179b9e4..0000000000 --- a/website/doctype/web_page/README.md +++ /dev/null @@ -1 +0,0 @@ -Static (HTML / JS / CSS) page created by the user for the website. \ No newline at end of file diff --git a/website/doctype/web_page/__init__.py b/website/doctype/web_page/__init__.py deleted file mode 100644 index baffc48825..0000000000 --- a/website/doctype/web_page/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from __future__ import unicode_literals diff --git a/website/doctype/web_page/templates/index.html b/website/doctype/web_page/templates/index.html deleted file mode 100644 index 761da0c8da..0000000000 --- a/website/doctype/web_page/templates/index.html +++ /dev/null @@ -1 +0,0 @@ -{% extends "app/website/templates/html/web_page.html" %} \ No newline at end of file diff --git a/website/doctype/web_page/templates/web_page.html b/website/doctype/web_page/templates/web_page.html deleted file mode 100644 index c857263816..0000000000 --- a/website/doctype/web_page/templates/web_page.html +++ /dev/null @@ -1,14 +0,0 @@ -{% extends "app/website/templates/html/page.html" %} - -{% block javascript %} - {% if insert_code %} - {{ javascript }} - {% endif %} -{% endblock %} - -{% block content %} -
- {% include "app/website/templates/html/slideshow.html" %} - {{ main_section }} -
-{% endblock %} \ No newline at end of file diff --git a/website/doctype/web_page/web_page.js b/website/doctype/web_page/web_page.js deleted file mode 100644 index 9e523607e6..0000000000 --- a/website/doctype/web_page/web_page.js +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. -// License: GNU General Public License v3. See license.txt - -$.extend(cur_frm.cscript, { - layout: function(doc) { - if(!doc.__islocal) { - if(doc.insert_code) { - if(!doc.javascript) { - cur_frm.set_value("javascript", - 'wn.pages["'+doc.name+'"].onload = function(wrapper) { }'); - } - } - if(doc.insert_style) { - if(!doc.css) { - cur_frm.set_value("css", '#page-'+doc.name+' { }'); - } - } - } - }, - refresh: function(doc) { - cur_frm.cscript.layout(doc); - }, - insert_style: function(doc) { - cur_frm.cscript.layout(doc); - }, - insert_code: function(doc) { - cur_frm.cscript.layout(doc); - } -}) \ No newline at end of file diff --git a/website/doctype/web_page/web_page.py b/website/doctype/web_page/web_page.py deleted file mode 100644 index f0045fdda5..0000000000 --- a/website/doctype/web_page/web_page.py +++ /dev/null @@ -1,35 +0,0 @@ -# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. -# License: GNU General Public License v3. See license.txt - -from __future__ import unicode_literals -import webnotes - -class DocType(): - def __init__(self, d, dl): - self.doc, self.doclist = d, dl - - def autoname(self): - from webnotes.webutils import page_name - self.doc.name = page_name(self.doc.title) - - def on_update(self): - from webnotes.webutils import update_page_name - update_page_name(self.doc, self.doc.title) - self.if_home_clear_cache() - - def if_home_clear_cache(self): - """if home page, clear cache""" - if webnotes.conn.get_value("Website Settings", None, "home_page")==self.doc.name: - from webnotes.sessions import clear_cache - clear_cache('Guest') - - from webnotes.webutils import clear_cache - clear_cache(self.doc.page_name) - clear_cache('index') - - def prepare_template_args(self): - if self.doc.slideshow: - from website.doctype.website_slideshow.website_slideshow import get_slideshow - get_slideshow(self) - - self.doc.meta_description = self.doc.description diff --git a/website/doctype/web_page/web_page.txt b/website/doctype/web_page/web_page.txt deleted file mode 100644 index 34fa266928..0000000000 --- a/website/doctype/web_page/web_page.txt +++ /dev/null @@ -1,154 +0,0 @@ -[ - { - "creation": "2013-03-28 10:35:30", - "docstatus": 0, - "modified": "2013-07-05 15:02:45", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "allow_attach": 1, - "description": "Page to show on the website\n", - "doctype": "DocType", - "document_type": "Transaction", - "icon": "icon-file-alt", - "max_attachments": 20, - "module": "Website", - "name": "__common__" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Web Page", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "doctype": "DocPerm", - "name": "__common__", - "parent": "Web Page", - "parentfield": "permissions", - "parenttype": "DocType", - "read": 1, - "role": "Website Manager", - "submit": 0 - }, - { - "doctype": "DocType", - "name": "Web Page" - }, - { - "description": "Title / headline of your page", - "doctype": "DocField", - "fieldname": "title", - "fieldtype": "Data", - "label": "Title", - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "cb1", - "fieldtype": "Column Break", - "width": "50%" - }, - { - "doctype": "DocField", - "fieldname": "published", - "fieldtype": "Check", - "label": "Published" - }, - { - "description": "Page url name (auto-generated) (add \".html\")", - "doctype": "DocField", - "fieldname": "page_name", - "fieldtype": "Data", - "in_list_view": 1, - "label": "Page Name", - "read_only": 1 - }, - { - "description": "Page content", - "doctype": "DocField", - "fieldname": "sb1", - "fieldtype": "Section Break", - "label": "Content" - }, - { - "description": "Begin this page with a slideshow of images", - "doctype": "DocField", - "fieldname": "slideshow", - "fieldtype": "Link", - "label": "Slideshow", - "options": "Website Slideshow" - }, - { - "description": "Description for page header.", - "doctype": "DocField", - "fieldname": "description", - "fieldtype": "Small Text", - "label": "Description" - }, - { - "description": "Content in markdown format that appears on the main side of your page", - "doctype": "DocField", - "fieldname": "main_section", - "fieldtype": "Text Editor", - "label": "Main Section" - }, - { - "description": "Link to other pages in the side bar and next section", - "doctype": "DocField", - "fieldname": "sb2", - "fieldtype": "Section Break", - "label": "More" - }, - { - "doctype": "DocField", - "fieldname": "text_align", - "fieldtype": "Select", - "label": "Text Align", - "options": "Left\nCenter\nRight" - }, - { - "description": "Add code as <script>", - "doctype": "DocField", - "fieldname": "insert_code", - "fieldtype": "Check", - "label": "Insert Code" - }, - { - "doctype": "DocField", - "fieldname": "javascript", - "fieldtype": "Code", - "label": "Javascript", - "options": "Javascript" - }, - { - "doctype": "DocField", - "fieldname": "insert_style", - "fieldtype": "Check", - "label": "Insert Style" - }, - { - "doctype": "DocField", - "fieldname": "css", - "fieldtype": "Code", - "label": "CSS", - "options": "CSS" - }, - { - "create": 1, - "doctype": "DocPerm", - "permlevel": 0, - "report": 1, - "write": 1 - }, - { - "amend": 0, - "cancel": 0, - "create": 0, - "doctype": "DocPerm", - "permlevel": 1 - } -] \ No newline at end of file diff --git a/website/doctype/website_item_group/README.md b/website/doctype/website_item_group/README.md deleted file mode 100644 index 54abfaf4fb..0000000000 --- a/website/doctype/website_item_group/README.md +++ /dev/null @@ -1 +0,0 @@ -Alternate grouping of parent Item (for website, so an Item can be listed under multiple groups). \ No newline at end of file diff --git a/website/doctype/website_item_group/__init__.py b/website/doctype/website_item_group/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/website/doctype/website_item_group/website_item_group.py b/website/doctype/website_item_group/website_item_group.py deleted file mode 100644 index 784339de7d..0000000000 --- a/website/doctype/website_item_group/website_item_group.py +++ /dev/null @@ -1,11 +0,0 @@ -# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. -# License: GNU General Public License v3. See license.txt - -# For license information, please see license.txt - -from __future__ import unicode_literals -import webnotes - -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file diff --git a/website/doctype/website_item_group/website_item_group.txt b/website/doctype/website_item_group/website_item_group.txt deleted file mode 100644 index 3d26e85315..0000000000 --- a/website/doctype/website_item_group/website_item_group.txt +++ /dev/null @@ -1,37 +0,0 @@ -[ - { - "creation": "2013-02-22 01:28:09", - "docstatus": 0, - "modified": "2013-07-10 14:54:25", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "description": "Cross Listing of Item in multiple groups", - "doctype": "DocType", - "document_type": "Other", - "istable": 1, - "module": "Website", - "name": "__common__" - }, - { - "doctype": "DocField", - "fieldname": "item_group", - "fieldtype": "Link", - "in_list_view": 1, - "label": "Item Group", - "name": "__common__", - "options": "Item Group", - "parent": "Website Item Group", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "doctype": "DocType", - "name": "Website Item Group" - }, - { - "doctype": "DocField" - } -] \ No newline at end of file diff --git a/website/doctype/website_script/README.md b/website/doctype/website_script/README.md deleted file mode 100644 index 65af2a13d2..0000000000 --- a/website/doctype/website_script/README.md +++ /dev/null @@ -1 +0,0 @@ -Custom javascript to be appended at the end of the page. Used to include 3rd party tracking / analytics tools. \ No newline at end of file diff --git a/website/doctype/website_script/__init__.py b/website/doctype/website_script/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/website/doctype/website_script/website_script.py b/website/doctype/website_script/website_script.py deleted file mode 100644 index c449df6271..0000000000 --- a/website/doctype/website_script/website_script.py +++ /dev/null @@ -1,16 +0,0 @@ -# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. -# License: GNU General Public License v3. See license.txt - -# For license information, please see license.txt - -from __future__ import unicode_literals -import webnotes - -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl - - def on_update(self): - # make js and css - from website.doctype.website_settings.make_web_include_files import make - make() \ No newline at end of file diff --git a/website/doctype/website_script/website_script.txt b/website/doctype/website_script/website_script.txt deleted file mode 100644 index ae22a345dc..0000000000 --- a/website/doctype/website_script/website_script.txt +++ /dev/null @@ -1,52 +0,0 @@ -[ - { - "creation": "2012-12-27 11:51:24", - "docstatus": 0, - "modified": "2013-07-05 15:02:48", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "description": "Script to attach to all web pages.", - "doctype": "DocType", - "document_type": "Other", - "icon": "icon-code", - "issingle": 1, - "module": "Website", - "name": "__common__" - }, - { - "doctype": "DocField", - "fieldname": "javascript", - "fieldtype": "Code", - "label": "Javascript", - "name": "__common__", - "options": "Javascript", - "parent": "Website Script", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "create": 1, - "doctype": "DocPerm", - "name": "__common__", - "parent": "Website Script", - "parentfield": "permissions", - "parenttype": "DocType", - "permlevel": 0, - "read": 1, - "role": "Website Manager", - "write": 1 - }, - { - "doctype": "DocType", - "name": "Website Script" - }, - { - "doctype": "DocField" - }, - { - "doctype": "DocPerm" - } -] \ No newline at end of file diff --git a/website/doctype/website_settings/README.md b/website/doctype/website_settings/README.md deleted file mode 100644 index 8e654fca58..0000000000 --- a/website/doctype/website_settings/README.md +++ /dev/null @@ -1 +0,0 @@ -Overall website settings. Including banners, items appearing in the top and bottom menus, tracking code for Google Analytics etc. \ No newline at end of file diff --git a/website/doctype/website_settings/__init__.py b/website/doctype/website_settings/__init__.py deleted file mode 100644 index baffc48825..0000000000 --- a/website/doctype/website_settings/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from __future__ import unicode_literals diff --git a/website/doctype/website_settings/make_web_include_files.py b/website/doctype/website_settings/make_web_include_files.py deleted file mode 100644 index a9df23bb1c..0000000000 --- a/website/doctype/website_settings/make_web_include_files.py +++ /dev/null @@ -1,60 +0,0 @@ -# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. -# License: GNU General Public License v3. See license.txt - -import os -import webnotes - -def make(): - from startup.webutils import get_home_page - - if not webnotes.conn: - webnotes.connect() - - home_page = get_home_page() - - fname = 'js/wn-web.js' - if os.path.basename(os.path.abspath('.'))!='public': - fname = os.path.join('public', fname) - - with open(fname, 'w') as f: - f.write(get_web_script()) - - fname = 'css/wn-web.css' - if os.path.basename(os.path.abspath('.'))!='public': - fname = os.path.join('public', fname) - - # style - wn.css - with open(fname, 'w') as f: - f.write(get_web_style()) - -def get_web_script(): - """returns web startup script""" - user_script = "" - - ws = webnotes.doc("Website Settings", "Website Settings") - - if ws.google_analytics_id: - user_script += google_analytics_template % ws.google_analytics_id - - user_script += (webnotes.conn.get_value('Website Script', None, 'javascript') or '') - - return user_script - -def get_web_style(): - """returns web css""" - return webnotes.conn.get_value('Style Settings', None, 'custom_css') or '' - -google_analytics_template = """ - -// Google Analytics template - -window._gaq = window._gaq || []; -window._gaq.push(['_setAccount', '%s']); -window._gaq.push(['_trackPageview']); - -(function() { - var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; - ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; - var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); -})(); -""" \ No newline at end of file diff --git a/website/doctype/website_settings/website_settings.js b/website/doctype/website_settings/website_settings.js deleted file mode 100644 index 21b55be5ea..0000000000 --- a/website/doctype/website_settings/website_settings.js +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. -// License: GNU General Public License v3. See license.txt - -// update parent select - -$.extend(cur_frm.cscript, { - refresh: function(doc) { - cur_frm.add_custom_button("Auto Build Website", function() { - cur_frm.call({ - doc: cur_frm.doc, - method: "make_website" - }) - }, 'icon-magic') - }, - onload_post_render: function(doc) { - this.set_parent_label_options(); - }, - - label: function(doc, cdt, cdn) { - var item = wn.model.get_doc(cdt, cdn); - if(item.parentfield === "top_bar_items") { - this.set_parent_label_options(); - } - }, - - parent_label: function(doc, cdt, cdn) { - this.label(doc, cdt, cdn); - }, - - url: function(doc, cdt, cdn) { - this.label(doc, cdt, cdn); - }, - - set_parent_label_options: function() { - wn.meta.get_docfield("Top Bar Item", "parent_label", cur_frm.docname).options = - this.get_parent_options("top_bar_items"); - - if($(cur_frm.fields_dict.top_bar_items.grid.wrapper).find(".grid-row-open")) { - cur_frm.fields_dict.top_bar_items.grid.refresh(); - } - }, - - // get labels of parent items - get_parent_options: function(table_field) { - var items = getchildren('Top Bar Item', cur_frm.doc.name, table_field); - var main_items = ['']; - for(var i in items) { - var d = items[i]; - if(!d.parent_label && !d.url && d.label) { - main_items.push(d.label); - } - } - return main_items.join('\n'); - } -}); - -cur_frm.cscript.set_banner_from_image = function(doc) { - if(!doc.banner_image) { - msgprint(wn._("Select a Banner Image first.")); - } - var src = doc.banner_image; - cur_frm.set_value("banner_html", ""); -} \ No newline at end of file diff --git a/website/doctype/website_settings/website_settings.py b/website/doctype/website_settings/website_settings.py deleted file mode 100644 index 135c7531b3..0000000000 --- a/website/doctype/website_settings/website_settings.py +++ /dev/null @@ -1,78 +0,0 @@ -# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. -# License: GNU General Public License v3. See license.txt - -from __future__ import unicode_literals -import webnotes -from webnotes import _, msgprint - -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl - - def validate(self): - self.set_home_page() - self.validate_top_bar_items() - self.validate_footer_items() - - def make_website(self): - # set item pages - for name in webnotes.conn.sql_list("""select name from tabItem where - ifnull(show_in_website, 0)=0 and is_sales_item ='Yes' """): - webnotes.msgprint("Setting 'Show in Website' for:" + name) - item = webnotes.bean("Item", name) - item.doc.show_in_website = 1 - item.doc.website_warehouse = item.doc.default_warehouse - item.doc.website_image = item.doc.image - item.save() - - # set item group pages - for name in webnotes.conn.sql_list("""select name from `tabItem Group` where - ifnull(show_in_website, 0)=0 and exists (select name from tabItem where - ifnull(show_in_website, 0)=1)"""): - webnotes.msgprint("Setting 'Show in Website' for:" + name) - item_group = webnotes.bean("Item Group", name) - item_group.doc.show_in_website = 1 - item_group.save() - - def validate_top_bar_items(self): - """validate url in top bar items""" - for top_bar_item in self.doclist.get({"parentfield": "top_bar_items"}): - if top_bar_item.parent_label: - parent_label_item = self.doclist.get({"parentfield": "top_bar_items", - "label": top_bar_item.parent_label}) - - if not parent_label_item: - # invalid item - msgprint(_(self.meta.get_label("parent_label", parentfield="top_bar_items")) + - (" \"%s\": " % top_bar_item.parent_label) + _("does not exist"), raise_exception=True) - - elif not parent_label_item[0] or parent_label_item[0].url: - # parent cannot have url - msgprint(_("Top Bar Item") + (" \"%s\": " % top_bar_item.parent_label) + - _("cannot have a URL, because it has child item(s)"), raise_exception=True) - - def validate_footer_items(self): - """clear parent label in footer""" - for footer_item in self.doclist.get({"parentfield": "footer_items"}): - footer_item.parent_label = None - - def on_update(self): - # make js and css - from website.doctype.website_settings.make_web_include_files import make - make() - - # clear web cache (for menus!) - from webnotes.webutils import clear_cache - clear_cache() - - def set_home_page(self): - from webnotes.model.doc import Document - webnotes.conn.sql("""delete from `tabDefault Home Page` where role='Guest'""") - - d = Document('Default Home Page') - d.parent = 'Control Panel' - d.parenttype = 'Control Panel' - d.parentfield = 'default_home_pages' - d.role = 'Guest' - d.home_page = self.doc.home_page - d.save() \ No newline at end of file diff --git a/website/doctype/website_settings/website_settings.txt b/website/doctype/website_settings/website_settings.txt deleted file mode 100644 index f8ceafe162..0000000000 --- a/website/doctype/website_settings/website_settings.txt +++ /dev/null @@ -1,249 +0,0 @@ -[ - { - "creation": "2013-04-30 12:58:46", - "docstatus": 0, - "modified": "2013-07-10 20:37:38", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "allow_attach": 1, - "doctype": "DocType", - "document_type": "Other", - "icon": "icon-cog", - "issingle": 1, - "max_attachments": 10, - "module": "Website", - "name": "__common__" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Website Settings", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "doctype": "DocPerm", - "name": "__common__", - "parent": "Website Settings", - "parentfield": "permissions", - "parenttype": "DocType", - "read": 1, - "report": 0, - "submit": 0 - }, - { - "doctype": "DocType", - "name": "Website Settings" - }, - { - "doctype": "DocField", - "fieldname": "sb0", - "fieldtype": "Section Break", - "label": "Landing Page" - }, - { - "description": "The \"Web Page\" that is the website home page", - "doctype": "DocField", - "fieldname": "home_page", - "fieldtype": "Link", - "label": "Home Page", - "options": "Web Page", - "reqd": 0 - }, - { - "description": "The name of your company / website as you want to appear on browser title bar. All pages will have this as the prefix to the title.", - "doctype": "DocField", - "fieldname": "title_prefix", - "fieldtype": "Data", - "label": "Title Prefix" - }, - { - "doctype": "DocField", - "fieldname": "cb4", - "fieldtype": "Column Break" - }, - { - "description": "If checked, the Home page will be the default Item Group for the website.", - "doctype": "DocField", - "fieldname": "home_page_is_products", - "fieldtype": "Check", - "label": "Home Page is Products" - }, - { - "description": "Add a banner to the site. (small banners are usually good)", - "doctype": "DocField", - "fieldname": "banner", - "fieldtype": "Section Break", - "label": "Banner" - }, - { - "description": "Select an image of approx width 150px with a transparent background for best results.", - "doctype": "DocField", - "fieldname": "banner_image", - "fieldtype": "Select", - "label": "Banner Image", - "options": "attach_files:" - }, - { - "doctype": "DocField", - "fieldname": "set_banner_from_image", - "fieldtype": "Button", - "label": "Set Banner from Image" - }, - { - "description": "Banner is above the Top Menu Bar.", - "doctype": "DocField", - "fieldname": "banner_html", - "fieldtype": "Small Text", - "label": "Banner HTML" - }, - { - "description": "Menu items in the Top Bar. For setting the color of the Top Bar, go to Style Settings", - "doctype": "DocField", - "fieldname": "top_bar", - "fieldtype": "Section Break", - "label": "Top Bar" - }, - { - "description": "Brand is what appears on the top-right of the toolbar. If it is an image, make sure it\nhas a transparent background and use the <img /> tag. Keep size as 200px x 30px", - "doctype": "DocField", - "fieldname": "brand_html", - "fieldtype": "Small Text", - "label": "Brand HTML" - }, - { - "doctype": "DocField", - "fieldname": "top_bar_items", - "fieldtype": "Table", - "label": "Top Bar Items", - "options": "Top Bar Item" - }, - { - "doctype": "DocField", - "fieldname": "footer", - "fieldtype": "Section Break", - "label": "Footer" - }, - { - "description": "Address and other legal information you may want to put in the footer.", - "doctype": "DocField", - "fieldname": "address", - "fieldtype": "Text Editor", - "label": "Address" - }, - { - "doctype": "DocField", - "fieldname": "copyright", - "fieldtype": "Data", - "label": "Copyright" - }, - { - "doctype": "DocField", - "fieldname": "footer_items", - "fieldtype": "Table", - "label": "Footer Items", - "options": "Top Bar Item" - }, - { - "doctype": "DocField", - "fieldname": "integrations", - "fieldtype": "Section Break", - "label": "Integrations" - }, - { - "description": "Add Google Analytics ID: eg. UA-89XXX57-1. Please search help on Google Analytics for more information.", - "doctype": "DocField", - "fieldname": "google_analytics_id", - "fieldtype": "Data", - "label": "Google Analytics ID" - }, - { - "doctype": "DocField", - "fieldname": "column_break_17", - "fieldtype": "Column Break" - }, - { - "doctype": "DocField", - "fieldname": "google_plus_one", - "fieldtype": "Check", - "label": "Google Plus One" - }, - { - "doctype": "DocField", - "fieldname": "facebook_share", - "fieldtype": "Check", - "label": "Facebook Share" - }, - { - "doctype": "DocField", - "fieldname": "linked_in_share", - "fieldtype": "Check", - "label": "Linked In Share" - }, - { - "doctype": "DocField", - "fieldname": "twitter_share", - "fieldtype": "Check", - "label": "Twitter Share" - }, - { - "description": "Tweet will be shared via your user account (if specified)", - "doctype": "DocField", - "fieldname": "twitter_share_via", - "fieldtype": "Data", - "label": "Twitter Share via" - }, - { - "doctype": "DocField", - "fieldname": "misc_section", - "fieldtype": "Section Break", - "label": "Misc" - }, - { - "description": "An icon file with .ico extension. Should be 16 x 16 px. Generated using a favicon generator. [favicon-generator.org]", - "doctype": "DocField", - "fieldname": "favicon", - "fieldtype": "Select", - "label": "FavIcon", - "options": "attach_files:" - }, - { - "description": "Sub-domain provided by erpnext.com", - "doctype": "DocField", - "fieldname": "subdomain", - "fieldtype": "Text", - "label": "Subdomain", - "read_only": 1, - "reqd": 0 - }, - { - "doctype": "DocField", - "fieldname": "column_break_28", - "fieldtype": "Column Break" - }, - { - "description": "Disable Customer Signup link in Login page", - "doctype": "DocField", - "fieldname": "disable_signup", - "fieldtype": "Check", - "label": "Disable Signup" - }, - { - "create": 1, - "doctype": "DocPerm", - "permlevel": 0, - "role": "Website Manager", - "write": 1 - }, - { - "amend": 0, - "cancel": 0, - "create": 0, - "doctype": "DocPerm", - "permlevel": 1, - "role": "All" - } -] \ No newline at end of file diff --git a/website/doctype/website_slideshow/README.md b/website/doctype/website_slideshow/README.md deleted file mode 100644 index e6afaed16e..0000000000 --- a/website/doctype/website_slideshow/README.md +++ /dev/null @@ -1 +0,0 @@ -Image slide show for Web Page, Product (Item) page, Item Group page. \ No newline at end of file diff --git a/website/doctype/website_slideshow/__init__.py b/website/doctype/website_slideshow/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/website/doctype/website_slideshow/templates/includes/slideshow.html b/website/doctype/website_slideshow/templates/includes/slideshow.html deleted file mode 100644 index b148cb1ce8..0000000000 --- a/website/doctype/website_slideshow/templates/includes/slideshow.html +++ /dev/null @@ -1,39 +0,0 @@ -{% if slideshow %} -{{ slideshow_header }} - - - - - -{% endif %} diff --git a/website/doctype/website_slideshow/website_slideshow.js b/website/doctype/website_slideshow/website_slideshow.js deleted file mode 100644 index a28e1c75ec..0000000000 --- a/website/doctype/website_slideshow/website_slideshow.js +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. -// License: GNU General Public License v3. See license.txt - -cur_frm.cscript.refresh = function(doc) { - cur_frm.set_intro(""); - if(doc.__islocal) { - cur_frm.set_intro("First set the name and save the record."); - } - else { - cur_frm.set_intro("Attach files / urls and add in table."); - } -} \ No newline at end of file diff --git a/website/doctype/website_slideshow/website_slideshow.py b/website/doctype/website_slideshow/website_slideshow.py deleted file mode 100644 index eb7de7a33a..0000000000 --- a/website/doctype/website_slideshow/website_slideshow.py +++ /dev/null @@ -1,21 +0,0 @@ -# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. -# License: GNU General Public License v3. See license.txt - -# For license information, please see license.txt - -from __future__ import unicode_literals -import webnotes - -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl - - def on_update(self): - # a slide show can be in use and any change in it should get reflected - from webnotes.webutils import clear_cache - clear_cache() - -def get_slideshow(obj): - slideshow = webnotes.bean("Website Slideshow", obj.doc.slideshow) - obj.slides = slideshow.doclist.get({"doctype":"Website Slideshow Item"}) - obj.doc.slideshow_header = slideshow.doc.header or "" \ No newline at end of file diff --git a/website/doctype/website_slideshow/website_slideshow.txt b/website/doctype/website_slideshow/website_slideshow.txt deleted file mode 100644 index e8ca08e4f6..0000000000 --- a/website/doctype/website_slideshow/website_slideshow.txt +++ /dev/null @@ -1,82 +0,0 @@ -[ - { - "creation": "2013-03-07 15:53:15", - "docstatus": 0, - "modified": "2013-07-05 15:03:30", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "allow_attach": 1, - "autoname": "field:slideshow_name", - "description": "Slideshow like display for the website", - "doctype": "DocType", - "document_type": "Transaction", - "icon": "icon-play", - "max_attachments": 10, - "module": "Website", - "name": "__common__" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Website Slideshow", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "cancel": 1, - "create": 1, - "doctype": "DocPerm", - "name": "__common__", - "parent": "Website Slideshow", - "parentfield": "permissions", - "parenttype": "DocType", - "permlevel": 0, - "read": 1, - "report": 1, - "role": "Website Manager", - "submit": 0, - "write": 1 - }, - { - "doctype": "DocType", - "name": "Website Slideshow" - }, - { - "doctype": "DocField", - "fieldname": "slideshow_name", - "fieldtype": "Data", - "label": "Slideshow Name", - "read_only": 0, - "reqd": 1 - }, - { - "depends_on": "eval:!doc.__islocal", - "description": "Note: For best results, images must be of the same size and width must be greater than height.", - "doctype": "DocField", - "fieldname": "sb0", - "fieldtype": "Section Break", - "label": "Slideshow Items" - }, - { - "depends_on": "eval:!doc.__islocal", - "doctype": "DocField", - "fieldname": "slideshow_items", - "fieldtype": "Table", - "label": "Slideshow Items", - "options": "Website Slideshow Item" - }, - { - "depends_on": "eval:!doc.__islocal", - "description": "This goes above the slideshow.", - "doctype": "DocField", - "fieldname": "header", - "fieldtype": "Text Editor", - "label": "Header" - }, - { - "doctype": "DocPerm" - } -] \ No newline at end of file diff --git a/website/doctype/website_slideshow_item/README.md b/website/doctype/website_slideshow_item/README.md deleted file mode 100644 index 2f52d24794..0000000000 --- a/website/doctype/website_slideshow_item/README.md +++ /dev/null @@ -1 +0,0 @@ -Slide (image) details for Website Slideshow. \ No newline at end of file diff --git a/website/doctype/website_slideshow_item/__init__.py b/website/doctype/website_slideshow_item/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/website/doctype/website_slideshow_item/website_slideshow_item.py b/website/doctype/website_slideshow_item/website_slideshow_item.py deleted file mode 100644 index 784339de7d..0000000000 --- a/website/doctype/website_slideshow_item/website_slideshow_item.py +++ /dev/null @@ -1,11 +0,0 @@ -# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. -# License: GNU General Public License v3. See license.txt - -# For license information, please see license.txt - -from __future__ import unicode_literals -import webnotes - -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file diff --git a/website/doctype/website_slideshow_item/website_slideshow_item.txt b/website/doctype/website_slideshow_item/website_slideshow_item.txt deleted file mode 100644 index c6fd78caf0..0000000000 --- a/website/doctype/website_slideshow_item/website_slideshow_item.txt +++ /dev/null @@ -1,53 +0,0 @@ -[ - { - "creation": "2013-03-07 12:26:33", - "docstatus": 0, - "modified": "2013-07-10 14:54:25", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "allow_attach": 0, - "doctype": "DocType", - "istable": 1, - "max_attachments": 10, - "module": "Website", - "name": "__common__" - }, - { - "doctype": "DocField", - "in_list_view": 1, - "name": "__common__", - "parent": "Website Slideshow Item", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "doctype": "DocType", - "name": "Website Slideshow Item" - }, - { - "doctype": "DocField", - "fieldname": "image", - "fieldtype": "Select", - "label": "Image", - "options": "attach_files:" - }, - { - "doctype": "DocField", - "fieldname": "heading", - "fieldtype": "Data", - "label": "Heading", - "print_width": "200px", - "width": "200px" - }, - { - "doctype": "DocField", - "fieldname": "description", - "fieldtype": "Text", - "label": "Description", - "print_width": "200px", - "width": "200px" - } -] \ No newline at end of file diff --git a/website/page/__init__.py b/website/page/__init__.py deleted file mode 100644 index baffc48825..0000000000 --- a/website/page/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from __future__ import unicode_literals diff --git a/website/page/website_home/__init__.py b/website/page/website_home/__init__.py deleted file mode 100644 index baffc48825..0000000000 --- a/website/page/website_home/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from __future__ import unicode_literals diff --git a/website/page/website_home/website_home.js b/website/page/website_home/website_home.js deleted file mode 100644 index a197f69638..0000000000 --- a/website/page/website_home/website_home.js +++ /dev/null @@ -1,111 +0,0 @@ -// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. -// License: GNU General Public License v3. See license.txt" - -wn.module_page["Website"] = [ - { - title: wn._("Web Content"), - icon: "icon-copy", - top: true, - items: [ - { - label: wn._("Web Page"), - description: wn._("Content web page."), - doctype:"Web Page" - }, - { - label: wn._("Blog Post"), - description: wn._("Single Post (article)."), - doctype:"Blog Post" - }, - ] - }, - { - title: wn._("Documents"), - icon: "icon-edit", - items: [ - { - label: wn._("Website Slideshow"), - description: wn._("Embed image slideshows in website pages."), - doctype:"Website Slideshow" - }, - { - label: wn._("Blogger"), - description: wn._("Profile of a blog writer."), - doctype:"Blogger" - }, - { - label: wn._("Blog Category"), - description: wn._("Categorize blog posts."), - doctype:"Blog Category" - }, - { - label: wn._("Blog Settings"), - description: wn._("Write titles and introductions to your blog."), - doctype:"Blog Settings", - route: "Form/Blog Settings" - }, - ] - }, - - { - title: wn._("Website Overall Settings"), - icon: "icon-wrench", - right: true, - items: [ - { - "route":"Form/Website Settings", - "label":wn._("Website Settings"), - "description":wn._("Setup of top navigation bar, footer and logo."), - doctype:"Website Settings" - }, - { - "route":"Form/Style Settings", - "label":wn._("Style Settings"), - "description":wn._("Setup of fonts and background."), - doctype:"Style Settings" - }, - { - "route":"Form/Shopping Cart Settings", - "label":wn._("Shopping Cart Settings"), - "description":wn._("Setup of Shopping Cart."), - doctype:"Shopping Cart Settings" - }, - ] - }, - { - title: wn._("Special Page Settings"), - icon: "icon-wrench", - right: true, - items: [ - { - "route":"Form/About Us Settings", - "label":wn._("About Us Settings"), - "description":wn._("Settings for About Us Page."), - doctype:"About Us Settings" - }, - { - "route":"Form/Contact Us Settings", - "label":wn._("Contact Us Settings"), - "description":wn._("Settings for Contact Us Page."), - doctype:"Contact Us Settings" - }, - ] - }, - { - title: wn._("Advanced Scripting"), - icon: "icon-wrench", - right: true, - items: [ - { - "route":"Form/Website Script", - "label":wn._("Website Script"), - "description":wn._("Javascript to append to the head section of the page."), - doctype:"Website Script" - }, - ] - } -] - -pscript['onload_website-home'] = function(wrapper) { - wn.views.moduleview.make(wrapper, "Website"); -} \ No newline at end of file diff --git a/website/page/website_home/website_home.txt b/website/page/website_home/website_home.txt deleted file mode 100644 index eeede04589..0000000000 --- a/website/page/website_home/website_home.txt +++ /dev/null @@ -1,22 +0,0 @@ -[ - { - "creation": "2012-02-21 13:23:51", - "docstatus": 0, - "modified": "2013-07-11 14:45:29", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doctype": "Page", - "icon": "icon-th", - "module": "Website", - "name": "__common__", - "page_name": "website-home", - "standard": "Yes", - "title": "Website Home" - }, - { - "doctype": "Page", - "name": "website-home" - } -] \ No newline at end of file diff --git a/website/sitemap.py b/website/sitemap.py deleted file mode 100644 index fb0d0707ea..0000000000 --- a/website/sitemap.py +++ /dev/null @@ -1,55 +0,0 @@ -# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. -# License: GNU General Public License v3. See license.txt - -from __future__ import unicode_literals - -frame_xml = """ -%s -""" - -link_xml = """\n%s%s""" - -# generate the sitemap XML -def generate(domain): - global frame_xml, link_xml - import urllib, os - import webnotes - import webnotes.webutils - from webnotes.utils import nowdate - - # settings - max_items = 1000 - count = 0 - - site_map = '' - if domain: - today = nowdate() - - # generated pages - for doctype, opts in webnotes.webutils.get_generators().items(): - pages = webnotes.conn.sql("""select page_name, `modified` - from `tab%s` where ifnull(%s,0)=1 - order by modified desc""" % (doctype, opts.get("condition_field"))) - - for p in pages: - if count >= max_items: break - if p[0]: - page_url = os.path.join(domain, urllib.quote(p[0])) - modified = p[1].strftime('%Y-%m-%d') - site_map += link_xml % (page_url, modified) - count += 1 - - if count >= max_items: break - - # standard pages - for page, opts in webnotes.get_config()["web"]["pages"].items(): - if "no_cache" in opts: - continue - - if count >= max_items: break - page_url = os.path.join(domain, urllib.quote(page)) - modified = today - site_map += link_xml % (page_url, modified) - count += 1 - - return frame_xml % site_map diff --git a/website/templates/__init__.py b/website/templates/__init__.py deleted file mode 100644 index baffc48825..0000000000 --- a/website/templates/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from __future__ import unicode_literals diff --git a/website/templates/includes/footer.html b/website/templates/includes/footer.html deleted file mode 100644 index e391794dd1..0000000000 --- a/website/templates/includes/footer.html +++ /dev/null @@ -1,79 +0,0 @@ -
- - -
diff --git a/website/templates/includes/navbar.html b/website/templates/includes/navbar.html deleted file mode 100644 index 9e827c4ebe..0000000000 --- a/website/templates/includes/navbar.html +++ /dev/null @@ -1,39 +0,0 @@ - - diff --git a/website/templates/includes/outer.html b/website/templates/includes/outer.html deleted file mode 100644 index 3ecb0573e6..0000000000 --- a/website/templates/includes/outer.html +++ /dev/null @@ -1,34 +0,0 @@ -{% extends "lib/templates/base.html" %} - -{% block body %} - {% include "app/website/templates/html/navbar.html" %} -
-
- {% if shopping_cart_enabled -%} - - | - {%- endif %} - Login -
-
- | - {% if shopping_cart_enabled -%} - - | - {%- endif %} - -
-
- {% if banner_html %}{% endif %} -
-
- {%- block content -%} - {%- endblock -%} -
-
-
- {% include "app/website/templates/html/footer.html" %} - -{% endblock %} \ No newline at end of file diff --git a/website/templates/includes/page.html b/website/templates/includes/page.html deleted file mode 100644 index c9fbec449a..0000000000 --- a/website/templates/includes/page.html +++ /dev/null @@ -1,20 +0,0 @@ -{% extends "app/website/templates/html/outer.html" %} - -{% block title -%}{{ title }}{%- endblock %} - -{% block header -%} - {{ super() }} - - {% block css -%} - {% if insert_style -%} - - {%- endif %} - {%- endblock %} -{%- endblock -%} - -{%- block content -%} - {{ content }} -{%- endblock %} \ No newline at end of file From bdb846f665d647ce81595c03dec7ea50d783f514 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Mon, 9 Sep 2013 17:31:19 +0530 Subject: [PATCH 06/37] [website] [minor] moving to framework --- config.json | 69 +++++-------------- .../p03_move_website_to_framework.py | 4 +- portal/templates/base.html | 19 +++++ setup/doctype/item_group/item_group.py | 2 +- .../item_group/templates/item_group.html | 0 setup/doctype/sales_partner/sales_partner.py | 2 +- startup/webutils.py | 9 --- stock/doctype/item/item.py | 2 +- .../{product_page.html => item.html} | 0 9 files changed, 42 insertions(+), 65 deletions(-) create mode 100644 portal/templates/base.html rename stock/doctype/item/templates/product_group.html => setup/doctype/item_group/templates/item_group.html (100%) rename stock/doctype/item/templates/{product_page.html => item.html} (100%) diff --git a/config.json b/config.json index 76ab832280..0ce1c0c658 100644 --- a/config.json +++ b/config.json @@ -43,12 +43,6 @@ "color": "#7f8c8d", "icon": "icon-cogs" }, - "Website": { - "type": "module", - "link": "website-home", - "color": "#16a085", - "icon": "icon-globe" - }, "HR": { "type": "module", "link": "hr-home", @@ -80,28 +74,13 @@ }, "web": { "pages": { - "about": { - "template": "app/website/templates/pages/about", - "args_method": "website.doctype.about_us_settings.about_us_settings.get_args" - }, "account": { "no_cache": true, - "template": "app/website/templates/pages/account" - }, - "blog": { - "template": "app/website/templates/pages/blog", - "args_method": "website.doctype.blog_post.blog_post.get_blog_template_args" - }, - "contact": { - "template": "app/website/templates/pages/contact", - "args_doctype": "Contact Us Settings" - }, - "index": { - "template": "app/website/templates/pages/index" + "template": "app/portal/templates/account.html" }, "order": { "no_cache": true, - "template": "app/website/templates/pages/sale", + "template": "app/portal/templates/sale.html", "args_method": "utilities.website_transactions.get_order_args", "portal": { "doctype": "Sales Order", @@ -112,12 +91,12 @@ }, "orders": { "no_cache": true, - "template": "app/website/templates/pages/sales_transactions", + "template": "app/portal/templates/sales_transactions.html", "args_method": "utilities.website_transactions.order_list_args" }, "invoice": { "no_cache": true, - "template": "app/website/templates/pages/sale", + "template": "app/portal/templates/sale.html", "args_method": "utilities.website_transactions.get_invoice_args", "portal": { "doctype": "Sales Invoice", @@ -128,12 +107,12 @@ }, "invoices": { "no_cache": true, - "template": "app/website/templates/pages/sales_transactions", + "template": "app/portal/templates/sales_transactions.html", "args_method": "utilities.website_transactions.invoice_list_args" }, "shipment": { "no_cache": true, - "template": "app/website/templates/pages/sale", + "template": "app/portal/templates/sale.html", "args_method": "utilities.website_transactions.get_shipment_args", "portal": { "doctype": "Delivery Note", @@ -144,69 +123,57 @@ }, "shipments": { "no_cache": true, - "template": "app/website/templates/pages/sales_transactions", + "template": "app/portal/templates/sales_transactions.html", "args_method": "utilities.website_transactions.shipment_list_args" }, "product_search": { - "template": "app/website/templates/pages/product_search" + "template": "app/stock/doctype/item/templates/product_search.html" }, "ticket": { "no_cache": true, - "template": "app/website/templates/pages/ticket", + "template": "app/support/doctype/support_ticket/templates/ticket.html", "args_method": "support.doctype.support_ticket.support_ticket.get_website_args", "portal": { "doctype": "Support Ticket" } }, "tickets": { - "template": "app/website/templates/pages/tickets", + "template": "app/support/doctype/support_ticket/templates/tickets.html", "args_method": "utilities.website_transactions.ticket_list_args" }, "address": { "no_cache": true, - "template": "app/website/templates/pages/address", + "template": "app/utilities/doctype/address/templates/address.html", "args_method": "utilities.doctype.address.address.get_website_args" }, "addresses": { - "template": "app/website/templates/pages/addresses" - }, - "writers": { - "template": "app/website/templates/pages/writers", - "args_method": "website.doctype.blogger.blogger.get_writers_args" + "template": "app/utilities/doctype/address/templates/addresses.html" }, "profile": { "no_cache": true, - "template": "app/website/templates/pages/profile", + "template": "app/portal/templates/profile.html", "args_method": "startup.webutils.get_profile_args" }, "cart": { "no_cache": true, - "template": "app/website/templates/pages/cart.html" + "template": "app/portal/templates/cart.html" }, "partners": { - "template": "app/website/templates/pages/partners", + "template": "app/setup/doctype/sales_partners/templates/partners.html", "args_method": "setup.doctype.sales_partner.sales_partner.get_partner_args" } }, "generators": { - "Web Page": { - "template": "app/website/templates/html/web_page.html", - "condition_field": "published" - }, - "Blog Post": { - "template": "app/website/templates/html/blog_page.html", - "condition_field": "published" - }, "Item": { - "template": "app/website/templates/html/product_page.html", + "template": "app/stock/doctype/item/templates/item.html", "condition_field": "show_in_website" }, "Item Group":{ - "template": "app/website/templates/html/product_group.html", + "template": "app/setup/doctype/item_group/templates/item_group.html", "condition_field": "show_in_website" }, "Sales Partner": { - "template": "app/website/templates/html/partner_page.html", + "template": "app/setup/doctype/sales_partner/templates/partner_page.html", "condition_field": "show_in_website" } } diff --git a/patches/september_2013/p03_move_website_to_framework.py b/patches/september_2013/p03_move_website_to_framework.py index 69bd505456..4aac892d4b 100644 --- a/patches/september_2013/p03_move_website_to_framework.py +++ b/patches/september_2013/p03_move_website_to_framework.py @@ -4,7 +4,7 @@ from __future__ import unicode_literals import webnotes from webnotes.utils import get_base_path -import os +import os, shutil def execute(): # remove pyc files @@ -13,5 +13,5 @@ def execute(): print exists os.remove(utils_pyc) - # TODO remove website folder + shutil.rmtree(os.path.join(get_base_path(), "app", "website")) \ No newline at end of file diff --git a/portal/templates/base.html b/portal/templates/base.html new file mode 100644 index 0000000000..57388d6c9b --- /dev/null +++ b/portal/templates/base.html @@ -0,0 +1,19 @@ +{% extends "lib/website/templates/base.html" %} + +{% block toolbar %} +
+ {% if shopping_cart_enabled -%} + + | + {%- endif %} + Login +
+
+ | + {% if shopping_cart_enabled -%} + + | + {%- endif %} + +
+{% endblock %} \ No newline at end of file diff --git a/setup/doctype/item_group/item_group.py b/setup/doctype/item_group/item_group.py index ccc6c29061..5eae4d180d 100644 --- a/setup/doctype/item_group/item_group.py +++ b/setup/doctype/item_group/item_group.py @@ -44,7 +44,7 @@ class DocType(DocTypeNestedSet): webnotes.msgprint("An item exists with same name (%s), please change the \ item group name or rename the item" % self.doc.name, raise_exception=1) - def prepare_template_args(self): + def get_context(self): from selling.utils.product import get_product_list_for_group, \ get_parent_item_groups, get_group_item_count diff --git a/stock/doctype/item/templates/product_group.html b/setup/doctype/item_group/templates/item_group.html similarity index 100% rename from stock/doctype/item/templates/product_group.html rename to setup/doctype/item_group/templates/item_group.html diff --git a/setup/doctype/sales_partner/sales_partner.py b/setup/doctype/sales_partner/sales_partner.py index d63376d537..545ae71f0e 100644 --- a/setup/doctype/sales_partner/sales_partner.py +++ b/setup/doctype/sales_partner/sales_partner.py @@ -29,7 +29,7 @@ class DocType: else: return '' - def prepare_template_args(self): + def get_context(self): address = webnotes.conn.get_value("Address", {"sales_partner": self.doc.name, "is_primary_address": 1}, "*", as_dict=True) diff --git a/startup/webutils.py b/startup/webutils.py index b9b6182408..9ce3f0a582 100644 --- a/startup/webutils.py +++ b/startup/webutils.py @@ -7,15 +7,6 @@ from webnotes.utils import cint, cstr, encode def get_templates_path(): return os.path.join(os.path.dirname(conf.__file__), "app", "website", "templates") -def get_home_page(): - doc_name = webnotes.conn.get_value('Website Settings', None, 'home_page') - if doc_name: - page_name = webnotes.conn.get_value('Web Page', doc_name, 'page_name') - else: - page_name = 'login' - - return page_name - def update_template_args(page_name, args): from webnotes.utils import get_request_site_address diff --git a/stock/doctype/item/item.py b/stock/doctype/item/item.py index f6f8d516af..25f3feb447 100644 --- a/stock/doctype/item/item.py +++ b/stock/doctype/item/item.py @@ -258,7 +258,7 @@ class DocType(DocListController): def get_tax_rate(self, tax_type): return { "tax_rate": webnotes.conn.get_value("Account", tax_type, "tax_rate") } - def prepare_template_args(self): + def get_context(self): from selling.utils.product import get_parent_item_groups self.parent_groups = get_parent_item_groups(self.doc.item_group) + [{"name":self.doc.name}] self.doc.title = self.doc.item_name diff --git a/stock/doctype/item/templates/product_page.html b/stock/doctype/item/templates/item.html similarity index 100% rename from stock/doctype/item/templates/product_page.html rename to stock/doctype/item/templates/item.html From 4c6120ae048b1c7f42d9b9afe3ed23116e0221fd Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Tue, 10 Sep 2013 12:18:58 +0530 Subject: [PATCH 07/37] [website] [minor] moving to framework --- config.json | 1 + portal/templates/base.html | 4 ++- portal/templates/includes/footer.html | 44 +++++++++++++++++++++++++++ 3 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 portal/templates/includes/footer.html diff --git a/config.json b/config.json index 0ce1c0c658..3f5851113d 100644 --- a/config.json +++ b/config.json @@ -1,5 +1,6 @@ { "app_name": "ERPNext", + "base_template": "app/portal/templates/base.html", "modules": { "Selling": { "link": "selling-home", diff --git a/portal/templates/base.html b/portal/templates/base.html index 57388d6c9b..701d86c4cc 100644 --- a/portal/templates/base.html +++ b/portal/templates/base.html @@ -16,4 +16,6 @@ {%- endif %} -{% endblock %} \ No newline at end of file +{% endblock %} + +{% block footer %}{% include "app/portal/templates/includes/footer.html" %}{% endblock %} \ No newline at end of file diff --git a/portal/templates/includes/footer.html b/portal/templates/includes/footer.html new file mode 100644 index 0000000000..1e8dd76142 --- /dev/null +++ b/portal/templates/includes/footer.html @@ -0,0 +1,44 @@ +{% extends "lib/website/templates/includes/footer.html" %} + +{% block powered %} +

+ ERPNext Powered +

+{% endblock %} + +{% block extension %} +
+
+ + + + +
+
+ +{% endblock %} From 7c2312a74c7e186bd7d16c9b872dbc0e1d32c883 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Tue, 10 Sep 2013 12:51:52 +0530 Subject: [PATCH 08/37] [website] [minor] moving to framework --- selling/utils/product.py | 14 ++++++++------ setup/doctype/item_group/templates/__init__.py | 0 .../templates/generators/__init__.py | 0 .../templates/{ => generators}/item_group.html | 10 +++++----- .../templates/generators/item_group.py | 2 ++ setup/doctype/sales_partner/sales_partner.py | 8 +------- .../sales_partner/templates/__init__.py | 0 .../templates/generators/__init__.py | 0 .../partner.html} | 2 +- .../templates/generators/partner.py | 2 ++ .../sales_partner/templates/pages/__init__.py | 0 .../templates/{ => pages}/partners.html | 2 +- .../sales_partner/templates/pages/partners.py | 7 +++++++ stock/doctype/item/templates/__init__.py | 0 .../item/templates/generators/__init__.py | 0 .../item/templates/{ => generators}/item.html | 18 +++++++++++------- .../doctype/item/templates/generators/item.py | 2 ++ .../includes/product_breadcrumbs.html | 2 +- .../templates/includes/product_in_grid.html | 2 +- .../templates/{ => pages}/product_search.html | 2 +- 20 files changed, 43 insertions(+), 30 deletions(-) create mode 100644 setup/doctype/item_group/templates/__init__.py create mode 100644 setup/doctype/item_group/templates/generators/__init__.py rename setup/doctype/item_group/templates/{ => generators}/item_group.html (72%) create mode 100644 setup/doctype/item_group/templates/generators/item_group.py create mode 100644 setup/doctype/sales_partner/templates/__init__.py create mode 100644 setup/doctype/sales_partner/templates/generators/__init__.py rename setup/doctype/sales_partner/templates/{partner_page.html => generators/partner.html} (94%) create mode 100644 setup/doctype/sales_partner/templates/generators/partner.py create mode 100644 setup/doctype/sales_partner/templates/pages/__init__.py rename setup/doctype/sales_partner/templates/{ => pages}/partners.html (93%) create mode 100644 setup/doctype/sales_partner/templates/pages/partners.py create mode 100644 stock/doctype/item/templates/__init__.py create mode 100644 stock/doctype/item/templates/generators/__init__.py rename stock/doctype/item/templates/{ => generators}/item.html (79%) create mode 100644 stock/doctype/item/templates/generators/item.py rename stock/doctype/item/templates/{ => pages}/product_search.html (93%) diff --git a/selling/utils/product.py b/selling/utils/product.py index fb0605e51d..13a9b15a22 100644 --- a/selling/utils/product.py +++ b/selling/utils/product.py @@ -4,8 +4,8 @@ from __future__ import unicode_literals import webnotes -from webnotes.utils import cstr, cint, fmt_money -from webnotes.webutils import build_html, delete_page_cache +from webnotes.utils import cstr, cint, fmt_money, get_base_path +from webnotes.webutils import delete_page_cache from selling.utils.cart import _get_cart_quotation @webnotes.whitelist(allow_guest=True) @@ -106,10 +106,12 @@ def get_group_item_count(item_group): or name in (select parent from `tabWebsite Item Group` where item_group in (%s))) """ % (child_groups, child_groups))[0][0] -def get_item_for_list_in_html(r): - scrub_item_for_list(r) - r.template = "app/website/templates/html/product_in_grid.html" - return build_html(r) +def get_item_for_list_in_html(context): + from jinja2 import Environment, FileSystemLoader + scrub_item_for_list(context) + jenv = Environment(loader = FileSystemLoader(get_base_path())) + template = jenv.get_template("app/stock/doctype/item/templates/includes/product_in_grid.html") + return template.render(context) def scrub_item_for_list(r): if not r.website_description: diff --git a/setup/doctype/item_group/templates/__init__.py b/setup/doctype/item_group/templates/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/setup/doctype/item_group/templates/generators/__init__.py b/setup/doctype/item_group/templates/generators/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/setup/doctype/item_group/templates/item_group.html b/setup/doctype/item_group/templates/generators/item_group.html similarity index 72% rename from setup/doctype/item_group/templates/item_group.html rename to setup/doctype/item_group/templates/generators/item_group.html index 4bf52c5372..22570d10c8 100644 --- a/setup/doctype/item_group/templates/item_group.html +++ b/setup/doctype/item_group/templates/generators/item_group.html @@ -1,11 +1,11 @@ -{% extends "app/website/templates/html/page.html" %} +{% extends base_template %} {% block content %} -{% include 'app/website/templates/html/product_search_box.html' %} -{% include 'app/website/templates/html/product_breadcrumbs.html' %} +{% include 'app/stock/doctype/item/templates/includes/product_search_box.html' %} +{% include 'app/stock/doctype/item/templates/includes/product_breadcrumbs.html' %}
{% if slideshow %} - {% include "app/website/templates/html/slideshow.html" %} + {% include "lib/website/templates/includes/slideshow.html" %} {% endif %} {% if description %}
{{ description or ""}}
@@ -31,7 +31,7 @@ {{ item }} {% endfor %}
- {% if len(items)==100 %} + {% if (items|length)==100 %}
Showing top 100 items.
{% endif %} {% else %} diff --git a/setup/doctype/item_group/templates/generators/item_group.py b/setup/doctype/item_group/templates/generators/item_group.py new file mode 100644 index 0000000000..12ef51378c --- /dev/null +++ b/setup/doctype/item_group/templates/generators/item_group.py @@ -0,0 +1,2 @@ +doctype = "Item Group" +condition_field = "show_in_website" \ No newline at end of file diff --git a/setup/doctype/sales_partner/sales_partner.py b/setup/doctype/sales_partner/sales_partner.py index 545ae71f0e..0d7e12d999 100644 --- a/setup/doctype/sales_partner/sales_partner.py +++ b/setup/doctype/sales_partner/sales_partner.py @@ -42,10 +42,4 @@ class DocType: "email": address.email_id, "partner_address": filter_strip_join(address_rows, "\n
"), "phone": filter_strip_join(cstr(address.phone).split(","), "\n
") - }) - -def get_partner_args(): - return { - "partners": webnotes.conn.sql("""select * from `tabSales Partner` - where show_in_website=1 order by name asc""", as_dict=True), - } \ No newline at end of file + }) \ No newline at end of file diff --git a/setup/doctype/sales_partner/templates/__init__.py b/setup/doctype/sales_partner/templates/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/setup/doctype/sales_partner/templates/generators/__init__.py b/setup/doctype/sales_partner/templates/generators/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/setup/doctype/sales_partner/templates/partner_page.html b/setup/doctype/sales_partner/templates/generators/partner.html similarity index 94% rename from setup/doctype/sales_partner/templates/partner_page.html rename to setup/doctype/sales_partner/templates/generators/partner.html index e5aac3593b..eb1481b224 100644 --- a/setup/doctype/sales_partner/templates/partner_page.html +++ b/setup/doctype/sales_partner/templates/generators/partner.html @@ -1,4 +1,4 @@ -{% extends "app/website/templates/html/page.html" %} +{% extends base_template %} {% block content %}
diff --git a/setup/doctype/sales_partner/templates/generators/partner.py b/setup/doctype/sales_partner/templates/generators/partner.py new file mode 100644 index 0000000000..2229f0379b --- /dev/null +++ b/setup/doctype/sales_partner/templates/generators/partner.py @@ -0,0 +1,2 @@ +doctype = "Sales Partner" +condition_field = "show_in_website" \ No newline at end of file diff --git a/setup/doctype/sales_partner/templates/pages/__init__.py b/setup/doctype/sales_partner/templates/pages/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/setup/doctype/sales_partner/templates/partners.html b/setup/doctype/sales_partner/templates/pages/partners.html similarity index 93% rename from setup/doctype/sales_partner/templates/partners.html rename to setup/doctype/sales_partner/templates/pages/partners.html index 50a095dd1b..14c72ae87e 100644 --- a/setup/doctype/sales_partner/templates/partners.html +++ b/setup/doctype/sales_partner/templates/pages/partners.html @@ -1,4 +1,4 @@ -{% extends "app/website/templates/html/page.html" %} +{% extends base_template %} {% set title="Partners" %} diff --git a/setup/doctype/sales_partner/templates/pages/partners.py b/setup/doctype/sales_partner/templates/pages/partners.py new file mode 100644 index 0000000000..5245ec0e3f --- /dev/null +++ b/setup/doctype/sales_partner/templates/pages/partners.py @@ -0,0 +1,7 @@ +import webnotes + +def get_context(): + return { + "partners": webnotes.conn.sql("""select * from `tabSales Partner` + where show_in_website=1 order by name asc""", as_dict=True), + } \ No newline at end of file diff --git a/stock/doctype/item/templates/__init__.py b/stock/doctype/item/templates/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/stock/doctype/item/templates/generators/__init__.py b/stock/doctype/item/templates/generators/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/stock/doctype/item/templates/item.html b/stock/doctype/item/templates/generators/item.html similarity index 79% rename from stock/doctype/item/templates/item.html rename to stock/doctype/item/templates/generators/item.html index 5ac0b480b6..d85547994e 100644 --- a/stock/doctype/item/templates/item.html +++ b/stock/doctype/item/templates/generators/item.html @@ -1,28 +1,32 @@ -{% extends "app/website/templates/html/page.html" %} +{% extends base_template %} {% block javascript %} - {% include "app/website/templates/js/product_page.js" %} + {% endblock %} {% block css %} - {% include "app/website/templates/css/product_page.css" %} + {% endblock %} {% block content %} - {% include 'app/website/templates/html/product_search_box.html' %} - {% include 'app/website/templates/html/product_breadcrumbs.html' %} + {% include 'app/stock/doctype/item/templates/includes/product_search_box.html' %} + {% include 'app/stock/doctype/item/templates/includes/product_breadcrumbs.html' %}
{% if slideshow %} - {% include "app/website/templates/html/slideshow.html" %} + {% include "lib/website/templates/includes/html/slideshow.html" %} {% else %} {% if website_image %} {% else %}
- {% include 'app/website/templates/html/product_missing_image.html' %} + {% include 'app/stock/doctype/item/templates/includes/product_missing_image.html' %}
{% endif %} {% endif %} diff --git a/stock/doctype/item/templates/generators/item.py b/stock/doctype/item/templates/generators/item.py new file mode 100644 index 0000000000..c9146d1640 --- /dev/null +++ b/stock/doctype/item/templates/generators/item.py @@ -0,0 +1,2 @@ +doctype = "Item" +condition_field = "show_in_website" \ No newline at end of file diff --git a/stock/doctype/item/templates/includes/product_breadcrumbs.html b/stock/doctype/item/templates/includes/product_breadcrumbs.html index 6d267489d0..f073e6f4df 100644 --- a/stock/doctype/item/templates/includes/product_breadcrumbs.html +++ b/stock/doctype/item/templates/includes/product_breadcrumbs.html @@ -1,4 +1,4 @@ -{% if obj.parent_groups and len(obj.parent_groups) > 1 %} +{% if obj.parent_groups and (obj.parent_groups|length) > 1 %}
diff --git a/stock/doctype/item/templates/product_search.html b/stock/doctype/item/templates/pages/product_search.html similarity index 93% rename from stock/doctype/item/templates/product_search.html rename to stock/doctype/item/templates/pages/product_search.html index e969f75825..37e50dc0a1 100644 --- a/stock/doctype/item/templates/product_search.html +++ b/stock/doctype/item/templates/pages/product_search.html @@ -1,4 +1,4 @@ -{% extends "app/website/templates/html/page.html" %} +{% extends base_template %} {% set title="Product Search" %} From 330dae90cb8586b155d44df0785681c1bd366b5d Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Tue, 10 Sep 2013 13:46:15 +0530 Subject: [PATCH 09/37] [website] [minor] moving to framework --- .../p03_move_website_to_framework.py | 1 - portal/__init__.py | 0 portal/templates/__init__.py | 0 portal/templates/base.html | 30 ++-- portal/templates/includes/transactions.html | 7 +- portal/templates/invoice.html | 88 ----------- portal/templates/pages/__init__.py | 0 portal/templates/{ => pages}/account.html | 2 +- portal/templates/{ => pages}/cart.html | 2 +- portal/templates/pages/invoice.html | 1 + portal/templates/pages/invoice.py | 14 ++ portal/templates/pages/invoices.html | 1 + portal/templates/pages/invoices.py | 22 +++ portal/templates/pages/order.html | 1 + portal/templates/pages/order.py | 14 ++ portal/templates/pages/orders.html | 1 + portal/templates/pages/orders.py | 23 +++ portal/templates/pages/profile.html | 61 ++++++++ portal/templates/pages/shipment.html | 1 + portal/templates/pages/shipment.py | 14 ++ portal/templates/pages/shipments.html | 1 + portal/templates/pages/shipments.py | 22 +++ portal/templates/profile.html | 4 +- portal/templates/sale.html | 2 +- portal/templates/sales_transactions.html | 37 ++--- portal/templates/transaction_list.html | 77 ---------- portal/website_transactions.py | 50 +++++++ public/build.json | 1 - .../includes/product_search_box.html | 2 +- .../doctype/support_ticket/support_ticket.py | 16 +- .../support_ticket/templates/__init__.py | 0 .../templates/pages/__init__.py | 0 .../templates/{ => pages}/ticket.html | 2 +- .../support_ticket/templates/pages/ticket.py | 19 +++ .../templates/pages/tickets.html | 33 +++++ .../support_ticket/templates/pages/tickets.py | 26 ++++ .../support_ticket/templates/tickets.html | 31 ---- utilities/doctype/address/address.py | 22 --- .../doctype/address/templates/__init__.py | 0 .../address/templates/pages/__init__.py | 0 .../templates/{ => pages}/address.html | 2 +- .../address/templates/pages/address.py | 28 ++++ .../templates/{ => pages}/addresses.html | 2 +- utilities/website_transactions.py | 139 ------------------ 44 files changed, 382 insertions(+), 417 deletions(-) create mode 100644 portal/__init__.py create mode 100644 portal/templates/__init__.py delete mode 100644 portal/templates/invoice.html create mode 100644 portal/templates/pages/__init__.py rename portal/templates/{ => pages}/account.html (95%) rename portal/templates/{ => pages}/cart.html (97%) create mode 100644 portal/templates/pages/invoice.html create mode 100644 portal/templates/pages/invoice.py create mode 100644 portal/templates/pages/invoices.html create mode 100644 portal/templates/pages/invoices.py create mode 100644 portal/templates/pages/order.html create mode 100644 portal/templates/pages/order.py create mode 100644 portal/templates/pages/orders.html create mode 100644 portal/templates/pages/orders.py create mode 100644 portal/templates/pages/profile.html create mode 100644 portal/templates/pages/shipment.html create mode 100644 portal/templates/pages/shipment.py create mode 100644 portal/templates/pages/shipments.html create mode 100644 portal/templates/pages/shipments.py delete mode 100644 portal/templates/transaction_list.html create mode 100644 portal/website_transactions.py create mode 100644 support/doctype/support_ticket/templates/__init__.py create mode 100644 support/doctype/support_ticket/templates/pages/__init__.py rename support/doctype/support_ticket/templates/{ => pages}/ticket.html (97%) create mode 100644 support/doctype/support_ticket/templates/pages/ticket.py create mode 100644 support/doctype/support_ticket/templates/pages/tickets.html create mode 100644 support/doctype/support_ticket/templates/pages/tickets.py delete mode 100644 support/doctype/support_ticket/templates/tickets.html create mode 100644 utilities/doctype/address/templates/__init__.py create mode 100644 utilities/doctype/address/templates/pages/__init__.py rename utilities/doctype/address/templates/{ => pages}/address.html (98%) create mode 100644 utilities/doctype/address/templates/pages/address.py rename utilities/doctype/address/templates/{ => pages}/addresses.html (96%) delete mode 100644 utilities/website_transactions.py diff --git a/patches/september_2013/p03_move_website_to_framework.py b/patches/september_2013/p03_move_website_to_framework.py index 4aac892d4b..cbfed7c178 100644 --- a/patches/september_2013/p03_move_website_to_framework.py +++ b/patches/september_2013/p03_move_website_to_framework.py @@ -10,7 +10,6 @@ def execute(): # remove pyc files utils_pyc = os.path.join(get_base_path(), "app", "selling", "utils.pyc") if os.path.exists(utils_pyc): - print exists os.remove(utils_pyc) shutil.rmtree(os.path.join(get_base_path(), "app", "website")) diff --git a/portal/__init__.py b/portal/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/portal/templates/__init__.py b/portal/templates/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/portal/templates/base.html b/portal/templates/base.html index 701d86c4cc..cdbc045848 100644 --- a/portal/templates/base.html +++ b/portal/templates/base.html @@ -1,20 +1,22 @@ {% extends "lib/website/templates/base.html" %} {% block toolbar %} -
- {% if shopping_cart_enabled -%} - - | - {%- endif %} - Login -
-
- | - {% if shopping_cart_enabled -%} - - | - {%- endif %} - +
+
+ {% if shopping_cart_enabled -%} + + | + {%- endif %} + Login +
+
+ | + {% if shopping_cart_enabled -%} + + | + {%- endif %} + +
{% endblock %} diff --git a/portal/templates/includes/transactions.html b/portal/templates/includes/transactions.html index 1e61124337..23d5f812ea 100644 --- a/portal/templates/includes/transactions.html +++ b/portal/templates/includes/transactions.html @@ -1,4 +1,4 @@ -{% extends "app/website/templates/html/page.html" %} +{% extends base_template %} {% block content -%}
@@ -19,6 +19,7 @@ {%- endblock %} {% block javascript -%} + -// var render = function(doc) { }; - + {% endblock %} \ No newline at end of file diff --git a/portal/templates/invoice.html b/portal/templates/invoice.html deleted file mode 100644 index 26ddea43d2..0000000000 --- a/portal/templates/invoice.html +++ /dev/null @@ -1,88 +0,0 @@ -{% extends "app/website/templates/html/page.html" %} - -{% set title=doc.name %} - -{% block content %} -
- -

{{ doc.name }}

-
- {%- if doc.status -%} -
-
-
-
{{ doc.status }}
-
-
- {{ utils.formatdate(doc.transaction_date) }} -
-
-
-
-
- - - - - - - - - - - - {%- for row in doclist.get({"doctype":"Sales Order Item"}) %} - - - - - - - - - - {% endfor -%} - -
SrItem NameDescriptionQtyUoMBasic RateAmount
{{ row.idx }}{{ row.item_name }}{{ row.description }}{{ row.qty }}{{ row.stock_uom }}{{ utils.fmt_money(row.export_rate, currency=doc.currency) }}{{ utils.fmt_money(row.export_amount, currency=doc.currency) }}
-
-
-
-
-
- - - - - - - {%- for charge in doclist.get({"doctype":"Sales Taxes and Charges"}) -%} - {%- if not charge.included_in_print_rate -%} - - - - - {%- endif -%} - {%- endfor -%} - - - - - - - - - -
Net Total{{ - utils.fmt_money(doc.net_total/doc.conversion_rate, currency=doc.currency) - }}
{{ charge.description }}{{ utils.fmt_money(charge.tax_amount / doc.conversion_rate, currency=doc.currency) }}
Grand Total{{ utils.fmt_money(doc.grand_total_export, currency=doc.currency) }}
Rounded Total{{ utils.fmt_money(doc.rounded_total_export, currency=doc.currency) }}
-
-
-
- {%- endif -%} -
-{% endblock %} \ No newline at end of file diff --git a/portal/templates/pages/__init__.py b/portal/templates/pages/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/portal/templates/account.html b/portal/templates/pages/account.html similarity index 95% rename from portal/templates/account.html rename to portal/templates/pages/account.html index 2a5acf67e3..da43dd24fa 100644 --- a/portal/templates/account.html +++ b/portal/templates/pages/account.html @@ -1,4 +1,4 @@ -{% extends "app/website/templates/html/page.html" %} +{% extends base_template %} {% set title="My Account" %} diff --git a/portal/templates/cart.html b/portal/templates/pages/cart.html similarity index 97% rename from portal/templates/cart.html rename to portal/templates/pages/cart.html index 6708ad342b..372f5241b0 100644 --- a/portal/templates/cart.html +++ b/portal/templates/pages/cart.html @@ -1,4 +1,4 @@ -{% extends "app/website/templates/html/page.html" %} +{% extends base_template %} {% block javascript %} {% include "app/website/templates/js/cart.js" %} diff --git a/portal/templates/pages/invoice.html b/portal/templates/pages/invoice.html new file mode 100644 index 0000000000..376e5df7c2 --- /dev/null +++ b/portal/templates/pages/invoice.html @@ -0,0 +1 @@ +{% extends "app/portal/templates/sale.html" %} \ No newline at end of file diff --git a/portal/templates/pages/invoice.py b/portal/templates/pages/invoice.py new file mode 100644 index 0000000000..ed6e40a6e5 --- /dev/null +++ b/portal/templates/pages/invoice.py @@ -0,0 +1,14 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. +# License: GNU General Public License v3. See license.txt + +from __future__ import unicode_literals +import webnotes + +def get_context(): + from portal.website_transactions import get_transaction_context + context = get_transaction_context("Sales Invoice", webnotes.form_dict.name) + context.update({ + "parent_link": "invoices", + "parent_title": "Invoices" + }) + return context \ No newline at end of file diff --git a/portal/templates/pages/invoices.html b/portal/templates/pages/invoices.html new file mode 100644 index 0000000000..f108683cb9 --- /dev/null +++ b/portal/templates/pages/invoices.html @@ -0,0 +1 @@ +{% extends "app/portal/templates/sales_transactions.html" %} \ No newline at end of file diff --git a/portal/templates/pages/invoices.py b/portal/templates/pages/invoices.py new file mode 100644 index 0000000000..2bb6490903 --- /dev/null +++ b/portal/templates/pages/invoices.py @@ -0,0 +1,22 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. +# License: GNU General Public License v3. See license.txt + +from __future__ import unicode_literals +import webnotes + +def get_context(): + from portal.website_transactions import get_currency_context + context = get_currency_context() + context.update({ + "title": "Invoices", + "method": "portal.templates.pages.invoices.get_invoices", + "icon": "icon-file-text", + "empty_list_message": "No Invoices Found", + "page": "invoice" + }) + return context + +@webnotes.whitelist() +def get_invoices(start=0): + from portal.website_transactions import get_transaction_list + return get_transaction_list("Sales Invoice", start) \ No newline at end of file diff --git a/portal/templates/pages/order.html b/portal/templates/pages/order.html new file mode 100644 index 0000000000..376e5df7c2 --- /dev/null +++ b/portal/templates/pages/order.html @@ -0,0 +1 @@ +{% extends "app/portal/templates/sale.html" %} \ No newline at end of file diff --git a/portal/templates/pages/order.py b/portal/templates/pages/order.py new file mode 100644 index 0000000000..47e2c68d82 --- /dev/null +++ b/portal/templates/pages/order.py @@ -0,0 +1,14 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. +# License: GNU General Public License v3. See license.txt + +from __future__ import unicode_literals +import webnotes + +def get_context(): + from portal.website_transactions import get_transaction_context + context = get_transaction_context("Sales Order", webnotes.form_dict.name) + context.update({ + "parent_link": "orders", + "parent_title": "My Orders" + }) + return context \ No newline at end of file diff --git a/portal/templates/pages/orders.html b/portal/templates/pages/orders.html new file mode 100644 index 0000000000..f108683cb9 --- /dev/null +++ b/portal/templates/pages/orders.html @@ -0,0 +1 @@ +{% extends "app/portal/templates/sales_transactions.html" %} \ No newline at end of file diff --git a/portal/templates/pages/orders.py b/portal/templates/pages/orders.py new file mode 100644 index 0000000000..3c62d35b24 --- /dev/null +++ b/portal/templates/pages/orders.py @@ -0,0 +1,23 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. +# License: GNU General Public License v3. See license.txt + +from __future__ import unicode_literals +import webnotes + +def get_context(): + from portal.website_transactions import get_currency_context + context = get_currency_context() + context.update({ + "title": "My Orders", + "method": "portal.templates.pages.orders.get_orders", + "icon": "icon-list", + "empty_list_message": "No Orders Yet", + "page": "order", + }) + return context + +@webnotes.whitelist() +def get_orders(start=0): + from portal.website_transactions import get_transaction_list + return get_transaction_list("Sales Order", start) + \ No newline at end of file diff --git a/portal/templates/pages/profile.html b/portal/templates/pages/profile.html new file mode 100644 index 0000000000..2fe03ba911 --- /dev/null +++ b/portal/templates/pages/profile.html @@ -0,0 +1,61 @@ +{% extends base_template %} + +{% set title="My Profile" %} + +{% block content %} +
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+ +
+
+ +{% endblock %} \ No newline at end of file diff --git a/portal/templates/pages/shipment.html b/portal/templates/pages/shipment.html new file mode 100644 index 0000000000..376e5df7c2 --- /dev/null +++ b/portal/templates/pages/shipment.html @@ -0,0 +1 @@ +{% extends "app/portal/templates/sale.html" %} \ No newline at end of file diff --git a/portal/templates/pages/shipment.py b/portal/templates/pages/shipment.py new file mode 100644 index 0000000000..5d9d1d1435 --- /dev/null +++ b/portal/templates/pages/shipment.py @@ -0,0 +1,14 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. +# License: GNU General Public License v3. See license.txt + +from __future__ import unicode_literals +import webnotes + +def get_context(): + from portal.website_transactions import get_transaction_context + context = get_transaction_context("Delivery Note", webnotes.form_dict.name) + context.update({ + "parent_link": "shipments", + "parent_title": "Shipments" + }) + return context \ No newline at end of file diff --git a/portal/templates/pages/shipments.html b/portal/templates/pages/shipments.html new file mode 100644 index 0000000000..f108683cb9 --- /dev/null +++ b/portal/templates/pages/shipments.html @@ -0,0 +1 @@ +{% extends "app/portal/templates/sales_transactions.html" %} \ No newline at end of file diff --git a/portal/templates/pages/shipments.py b/portal/templates/pages/shipments.py new file mode 100644 index 0000000000..4847b9f2e3 --- /dev/null +++ b/portal/templates/pages/shipments.py @@ -0,0 +1,22 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. +# License: GNU General Public License v3. See license.txt + +from __future__ import unicode_literals +import webnotes + +def get_context(): + from portal.website_transactions import get_currency_context + context = get_currency_context() + context.update({ + "title": "Shipments", + "method": "portal.templates.pages.shipments.get_shipments", + "icon": "icon-truck", + "empty_list_message": "No Shipments Found", + "page": "shipment" + }) + return context + +@webnotes.whitelist() +def get_shipments(start=0): + from portal.website_transactions import get_transaction_list + return get_transaction_list("Delivery Note", start) diff --git a/portal/templates/profile.html b/portal/templates/profile.html index 4c03b400b9..e8e60b4cf6 100644 --- a/portal/templates/profile.html +++ b/portal/templates/profile.html @@ -1,4 +1,4 @@ -{% extends "app/website/templates/html/page.html" %} +{% extends base_template %} {% set title="My Profile" %} @@ -9,7 +9,7 @@
  • My Account
  • My Profile
  • - +
    diff --git a/portal/templates/sale.html b/portal/templates/sale.html index 1c03da261a..3a49684863 100644 --- a/portal/templates/sale.html +++ b/portal/templates/sale.html @@ -1,4 +1,4 @@ -{% extends "app/website/templates/html/page.html" %} +{% extends base_template %} {% set title=doc.name %} diff --git a/portal/templates/sales_transactions.html b/portal/templates/sales_transactions.html index 7215339c0d..10139c398b 100644 --- a/portal/templates/sales_transactions.html +++ b/portal/templates/sales_transactions.html @@ -1,25 +1,28 @@ -{% extends "app/website/templates/html/transactions.html" %} +{% extends "app/portal/templates/includes/transactions.html" %} {% block javascript -%} -global_number_format = "{{ global_number_format }}"; -currency = "{{ currency }}"; -wn.currency_symbols = {{ currency_symbols }}; + {{ super() }} -var render = function(doc) { - doc.grand_total_export = format_currency(doc.grand_total_export, doc.currency); + {%- endblock %} \ No newline at end of file diff --git a/portal/templates/transaction_list.html b/portal/templates/transaction_list.html deleted file mode 100644 index 967a6a8324..0000000000 --- a/portal/templates/transaction_list.html +++ /dev/null @@ -1,77 +0,0 @@ -{% extends "app/website/templates/html/page.html" %} - -{% block content %} -
    - -
    -
    -
    -
    -
    -
    -
    -
    -{% endblock %} - -{% block javascript %} -global_number_format = "{{ global_number_format }}"; -currency = "{{ currency }}"; -wn.currency_symbols = {{ currency_symbols }}; - -$(document).ready(function() { - var start = 0; - var $list = $(".transaction-list"); - - var $show_more = $(".btn-show-more").on("click", function() { - get_transactions(this); - }); - - var get_transactions = function(btn) { - wn.call({ - method: "{{ method }}", - args: { start: start }, - btn: btn, - callback: function(r) { - $list.find(".progress").remove(); - $show_more.toggle(!(r.message && r.message.length===20)); - - if(!(r.message && r.message.length)) { - console.log("empty"); - if(!$list.html().trim()) { - $list.html("
    \ - {{ empty_list_message }}
    "); - } - return; - } - - start += r.message.length; - - $.each(r.message, function(i, doc) { - render(doc); - }); - } - }) - }; - - var render = function(doc) { - doc.grand_total_export = format_currency(doc.grand_total_export, doc.currency); - - var $row = $(repl('\ -
    \ -
    \ -
    %(name)s
    \ -
    %(items)s...
    \ -
    \ -
    %(grand_total_export)s
    \ -
    %(creation)s
    \ -
    \ -
    ', doc)).appendTo($list); - }; - - get_transactions(); -}); -{% endblock %} \ No newline at end of file diff --git a/portal/website_transactions.py b/portal/website_transactions.py new file mode 100644 index 0000000000..21e9111254 --- /dev/null +++ b/portal/website_transactions.py @@ -0,0 +1,50 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. +# License: GNU General Public License v3. See license.txt + +from __future__ import unicode_literals +import webnotes +from webnotes.utils import cint, formatdate +import json + +def get_transaction_list(doctype, start): + # find customer id + customer = webnotes.conn.get_value("Contact", {"email_id": webnotes.session.user}, + "customer") + + if customer: + transactions = webnotes.conn.sql("""select name, creation, currency, grand_total_export + from `tab%s` where customer=%s and docstatus=1 + order by creation desc + limit %s, 20""" % (doctype, "%s", "%s"), (customer, cint(start)), as_dict=True) + for doc in transactions: + doc.items = ", ".join(webnotes.conn.sql_list("""select item_name + from `tab%s Item` where parent=%s limit 5""" % (doctype, "%s"), doc.name)) + doc.creation = formatdate(doc.creation) + return transactions + else: + return [] + +def get_currency_context(): + return { + "global_number_format": webnotes.conn.get_default("number_format") or "#,###.##", + "currency": webnotes.conn.get_default("currency"), + "currency_symbols": json.dumps(dict(webnotes.conn.sql("""select name, symbol + from tabCurrency where ifnull(enabled,0)=1"""))) + } + +def get_transaction_context(doctype, name): + customer = webnotes.conn.get_value("Contact", {"email_id": webnotes.session.user}, + "customer") + + bean = webnotes.bean(doctype, name) + if bean.doc.customer != customer: + return { + "doc": {"name": "Not Allowed"} + } + else: + return { + "doc": bean.doc, + "doclist": bean.doclist, + "webnotes": webnotes, + "utils": webnotes.utils + } \ No newline at end of file diff --git a/public/build.json b/public/build.json index b8d7dd4452..77ad4dd76d 100644 --- a/public/build.json +++ b/public/build.json @@ -1,7 +1,6 @@ { "public/css/all-web.css": [ "app/public/js/startup.css", - "app/website/css/website.css" ], "public/css/all-app.css": [ "app/public/js/startup.css" diff --git a/stock/doctype/item/templates/includes/product_search_box.html b/stock/doctype/item/templates/includes/product_search_box.html index d808bf6144..b4fa3e8783 100644 --- a/stock/doctype/item/templates/includes/product_search_box.html +++ b/stock/doctype/item/templates/includes/product_search_box.html @@ -1,4 +1,4 @@ -
    +
    diff --git a/support/doctype/support_ticket/support_ticket.py b/support/doctype/support_ticket/support_ticket.py index 5c38cc1a78..2cbd65e744 100644 --- a/support/doctype/support_ticket/support_ticket.py +++ b/support/doctype/support_ticket/support_ticket.py @@ -72,18 +72,4 @@ class DocType(TransactionBase): def set_status(name, status): st = webnotes.bean("Support Ticket", name) st.doc.status = status - st.save() - -def get_website_args(): - bean = webnotes.bean("Support Ticket", webnotes.form_dict.name) - if bean.doc.raised_by != webnotes.session.user: - return { - "doc": {"name": "Not Allowed"} - } - else: - return { - "doc": bean.doc, - "doclist": bean.doclist, - "webnotes": webnotes, - "utils": webnotes.utils - } + st.save() \ No newline at end of file diff --git a/support/doctype/support_ticket/templates/__init__.py b/support/doctype/support_ticket/templates/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/support/doctype/support_ticket/templates/pages/__init__.py b/support/doctype/support_ticket/templates/pages/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/support/doctype/support_ticket/templates/ticket.html b/support/doctype/support_ticket/templates/pages/ticket.html similarity index 97% rename from support/doctype/support_ticket/templates/ticket.html rename to support/doctype/support_ticket/templates/pages/ticket.html index 6622ed1589..1cfab9b00f 100644 --- a/support/doctype/support_ticket/templates/ticket.html +++ b/support/doctype/support_ticket/templates/pages/ticket.html @@ -1,4 +1,4 @@ -{% extends "app/website/templates/html/page.html" %} +{% extends base_template %} {% set title=doc.name %} diff --git a/support/doctype/support_ticket/templates/pages/ticket.py b/support/doctype/support_ticket/templates/pages/ticket.py new file mode 100644 index 0000000000..2227a6a5cb --- /dev/null +++ b/support/doctype/support_ticket/templates/pages/ticket.py @@ -0,0 +1,19 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. +# License: GNU General Public License v3. See license.txt + +from __future__ import unicode_literals +import webnotes + +def get_context(): + bean = webnotes.bean("Support Ticket", webnotes.form_dict.name) + if bean.doc.raised_by != webnotes.session.user: + return { + "doc": {"name": "Not Allowed"} + } + else: + return { + "doc": bean.doc, + "doclist": bean.doclist, + "webnotes": webnotes, + "utils": webnotes.utils + } diff --git a/support/doctype/support_ticket/templates/pages/tickets.html b/support/doctype/support_ticket/templates/pages/tickets.html new file mode 100644 index 0000000000..d3e316c5de --- /dev/null +++ b/support/doctype/support_ticket/templates/pages/tickets.html @@ -0,0 +1,33 @@ +{% extends "app/portal/templates/includes/transactions.html" %} + +{% block javascript -%} +{{ super() }} + + +{%- endblock %} \ No newline at end of file diff --git a/support/doctype/support_ticket/templates/pages/tickets.py b/support/doctype/support_ticket/templates/pages/tickets.py new file mode 100644 index 0000000000..21892a1cae --- /dev/null +++ b/support/doctype/support_ticket/templates/pages/tickets.py @@ -0,0 +1,26 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. +# License: GNU General Public License v3. See license.txt + +from __future__ import unicode_literals +import webnotes +from webnotes.utils import cint, formatdate + +def get_context(): + return { + "title": "My Tickets", + "method": "support.doctype.support_ticket.templates.pages.tickets.get_tickets", + "icon": "icon-ticket", + "empty_list_message": "No Tickets Raised", + "page": "ticket" + } + +@webnotes.whitelist() +def get_tickets(start=0): + tickets = webnotes.conn.sql("""select name, subject, status, creation + from `tabSupport Ticket` where raised_by=%s + order by modified desc + limit %s, 20""", (webnotes.session.user, cint(start)), as_dict=True) + for t in tickets: + t.creation = formatdate(t.creation) + + return tickets \ No newline at end of file diff --git a/support/doctype/support_ticket/templates/tickets.html b/support/doctype/support_ticket/templates/tickets.html deleted file mode 100644 index 166dbcd4d4..0000000000 --- a/support/doctype/support_ticket/templates/tickets.html +++ /dev/null @@ -1,31 +0,0 @@ -{% extends "app/website/templates/html/transactions.html" %} - -{% block javascript -%} -{{ super() }} - -var status_label = { - "Open": "label-success", - "Waiting for Customer": "label-danger", - "Closed": "label-default" -} - -var render = function(doc) { - doc.status = doc.status.trim(); - doc.label_class = status_label[doc.status] || "label-default"; - if(doc.status==="Waiting for Customer") doc.status = "To Reply"; - - $(repl('\ -
    \ -
    \ - %(status)s
    \ -
    \ -
    %(name)s
    \ -
    %(subject)s
    \ -
    \ -
    \ - %(creation)s\ -
    \ -
    \ -
    ', doc)).appendTo($list); -}; -{%- endblock %} \ No newline at end of file diff --git a/utilities/doctype/address/address.py b/utilities/doctype/address/address.py index 7ffb911417..69e81b8312 100644 --- a/utilities/doctype/address/address.py +++ b/utilities/doctype/address/address.py @@ -51,25 +51,3 @@ class DocType: webnotes.conn.sql("""update `tabAddress` set `%s`=0 where `%s`=%s and name!=%s""" % (is_address_type, fieldname, "%s", "%s"), (self.doc.fields[fieldname], self.doc.name)) break - -def get_website_args(): - def _get_fields(fieldnames): - return [webnotes._dict(zip(["label", "fieldname", "fieldtype", "options"], - [df.label, df.fieldname, df.fieldtype, df.options])) - for df in webnotes.get_doctype("Address", processed=True).get({"fieldname": ["in", fieldnames]})] - - bean = None - if webnotes.form_dict.name: - bean = webnotes.bean("Address", webnotes.form_dict.name) - - return { - "doc": bean.doc if bean else None, - "meta": webnotes._dict({ - "left_fields": _get_fields(["address_title", "address_type", "address_line1", "address_line2", - "city", "state", "pincode", "country"]), - "right_fields": _get_fields(["email_id", "phone", "fax", "is_primary_address", - "is_shipping_address"]) - }), - "cint": cint - } - diff --git a/utilities/doctype/address/templates/__init__.py b/utilities/doctype/address/templates/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/utilities/doctype/address/templates/pages/__init__.py b/utilities/doctype/address/templates/pages/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/utilities/doctype/address/templates/address.html b/utilities/doctype/address/templates/pages/address.html similarity index 98% rename from utilities/doctype/address/templates/address.html rename to utilities/doctype/address/templates/pages/address.html index 6d4273c3a5..63c3748f2a 100644 --- a/utilities/doctype/address/templates/address.html +++ b/utilities/doctype/address/templates/pages/address.html @@ -1,4 +1,4 @@ -{% extends "app/website/templates/html/page.html" %} +{% extends base_template %} {% set title=doc and doc.name or "New Address" %} {% set docname=(doc and doc.name or "") %} diff --git a/utilities/doctype/address/templates/pages/address.py b/utilities/doctype/address/templates/pages/address.py new file mode 100644 index 0000000000..d87974d0d8 --- /dev/null +++ b/utilities/doctype/address/templates/pages/address.py @@ -0,0 +1,28 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. +# License: GNU General Public License v3. See license.txt + +from __future__ import unicode_literals +import webnotes +from webnotes.utils import cint + +def get_context(): + def _get_fields(fieldnames): + return [webnotes._dict(zip(["label", "fieldname", "fieldtype", "options"], + [df.label, df.fieldname, df.fieldtype, df.options])) + for df in webnotes.get_doctype("Address", processed=True).get({"fieldname": ["in", fieldnames]})] + + bean = None + if webnotes.form_dict.name: + bean = webnotes.bean("Address", webnotes.form_dict.name) + + return { + "doc": bean.doc if bean else None, + "meta": webnotes._dict({ + "left_fields": _get_fields(["address_title", "address_type", "address_line1", "address_line2", + "city", "state", "pincode", "country"]), + "right_fields": _get_fields(["email_id", "phone", "fax", "is_primary_address", + "is_shipping_address"]) + }), + "cint": cint + } + diff --git a/utilities/doctype/address/templates/addresses.html b/utilities/doctype/address/templates/pages/addresses.html similarity index 96% rename from utilities/doctype/address/templates/addresses.html rename to utilities/doctype/address/templates/pages/addresses.html index b19780ae38..e3a5b683d7 100644 --- a/utilities/doctype/address/templates/addresses.html +++ b/utilities/doctype/address/templates/pages/addresses.html @@ -1,4 +1,4 @@ -{% extends "app/website/templates/html/page.html" %} +{% extends base_template %} {% set title="My Addresses" %} diff --git a/utilities/website_transactions.py b/utilities/website_transactions.py deleted file mode 100644 index f8710968fb..0000000000 --- a/utilities/website_transactions.py +++ /dev/null @@ -1,139 +0,0 @@ -# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. -# License: GNU General Public License v3. See license.txt - -from __future__ import unicode_literals -import webnotes -from webnotes.utils import cint, formatdate -import json - -def get_transaction_list(doctype, start): - # find customer id - customer = webnotes.conn.get_value("Contact", {"email_id": webnotes.session.user}, - "customer") - - if customer: - transactions = webnotes.conn.sql("""select name, creation, currency, grand_total_export - from `tab%s` where customer=%s and docstatus=1 - order by creation desc - limit %s, 20""" % (doctype, "%s", "%s"), (customer, cint(start)), as_dict=True) - for doc in transactions: - doc.items = ", ".join(webnotes.conn.sql_list("""select item_name - from `tab%s Item` where parent=%s limit 5""" % (doctype, "%s"), doc.name)) - doc.creation = formatdate(doc.creation) - return transactions - else: - return [] - -def get_common_args(): - return { - "global_number_format": webnotes.conn.get_default("number_format") or "#,###.##", - "currency": webnotes.conn.get_default("currency"), - "currency_symbols": json.dumps(dict(webnotes.conn.sql("""select name, symbol - from tabCurrency where ifnull(enabled,0)=1"""))) - } - -@webnotes.whitelist() -def get_orders(start=0): - return get_transaction_list("Sales Order", start) - -def order_list_args(): - args = get_common_args() - args.update({ - "title": "My Orders", - "method": "utilities.website_transactions.get_orders", - "icon": "icon-list", - "empty_list_message": "No Orders Yet", - "page": "order", - }) - return args - -@webnotes.whitelist() -def get_invoices(start=0): - return get_transaction_list("Sales Invoice", start) - -def invoice_list_args(): - args = get_common_args() - args.update({ - "title": "Invoices", - "method": "utilities.website_transactions.get_invoices", - "icon": "icon-file-text", - "empty_list_message": "No Invoices Found", - "page": "invoice" - }) - return args - -@webnotes.whitelist() -def get_shipments(start=0): - return get_transaction_list("Delivery Note", start) - -def shipment_list_args(): - args = get_common_args() - args.update({ - "title": "Shipments", - "method": "utilities.website_transactions.get_shipments", - "icon": "icon-truck", - "empty_list_message": "No Shipments Found", - "page": "shipment" - }) - return args - -@webnotes.whitelist() -def get_tickets(start=0): - tickets = webnotes.conn.sql("""select name, subject, status, creation - from `tabSupport Ticket` where raised_by=%s - order by modified desc - limit %s, 20""", (webnotes.session.user, cint(start)), as_dict=True) - for t in tickets: - t.creation = formatdate(t.creation) - - return tickets - -def ticket_list_args(): - return { - "title": "My Tickets", - "method": "utilities.website_transactions.get_tickets", - "icon": "icon-ticket", - "empty_list_message": "No Tickets Raised", - "page": "ticket" - } - -def get_transaction_args(doctype, name): - customer = webnotes.conn.get_value("Contact", {"email_id": webnotes.session.user}, - "customer") - - bean = webnotes.bean(doctype, name) - if bean.doc.customer != customer: - return { - "doc": {"name": "Not Allowed"} - } - else: - return { - "doc": bean.doc, - "doclist": bean.doclist, - "webnotes": webnotes, - "utils": webnotes.utils - } - -def get_order_args(): - args = get_transaction_args("Sales Order", webnotes.form_dict.name) - args.update({ - "parent_link": "orders", - "parent_title": "My Orders" - }) - return args - -def get_invoice_args(): - args = get_transaction_args("Sales Invoice", webnotes.form_dict.name) - args.update({ - "parent_link": "invoices", - "parent_title": "Invoices" - }) - return args - -def get_shipment_args(): - args = get_transaction_args("Delivery Note", webnotes.form_dict.name) - args.update({ - "parent_link": "shipments", - "parent_title": "Shipments" - }) - return args From 13bbf6536b468a4e5ed94752b7099c92128f8512 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Tue, 10 Sep 2013 14:44:36 +0530 Subject: [PATCH 10/37] [minor] webutils moved to lib --- .../p03_move_website_to_framework.py | 4 +- startup/webutils.py | 56 ------------------- 2 files changed, 3 insertions(+), 57 deletions(-) diff --git a/patches/september_2013/p03_move_website_to_framework.py b/patches/september_2013/p03_move_website_to_framework.py index cbfed7c178..9629b7acc1 100644 --- a/patches/september_2013/p03_move_website_to_framework.py +++ b/patches/september_2013/p03_move_website_to_framework.py @@ -12,5 +12,7 @@ def execute(): if os.path.exists(utils_pyc): os.remove(utils_pyc) - shutil.rmtree(os.path.join(get_base_path(), "app", "website")) + old_path = os.path.join(get_base_path(), "app", "website") + if os.path.exists(old_path): + shutil.rmtree(old_path) \ No newline at end of file diff --git a/startup/webutils.py b/startup/webutils.py index 9ce3f0a582..cd37be4964 100644 --- a/startup/webutils.py +++ b/startup/webutils.py @@ -3,62 +3,6 @@ import webnotes, conf, os from webnotes.utils import cint, cstr, encode - -def get_templates_path(): - return os.path.join(os.path.dirname(conf.__file__), "app", "website", "templates") - -def update_template_args(page_name, args): - - from webnotes.utils import get_request_site_address - from urllib import quote - - all_top_items = webnotes.conn.sql("""\ - select * from `tabTop Bar Item` - where parent='Website Settings' and parentfield='top_bar_items' - order by idx asc""", as_dict=1) - - top_items = [d for d in all_top_items if not d['parent_label']] - - # attach child items to top bar - for d in all_top_items: - if d['parent_label']: - for t in top_items: - if t['label']==d['parent_label']: - if not 'child_items' in t: - t['child_items'] = [] - t['child_items'].append(d) - break - - ret = webnotes._dict({ - 'top_bar_items': top_items, - 'footer_items': webnotes.conn.sql("""\ - select * from `tabTop Bar Item` - where parent='Website Settings' and parentfield='footer_items' - order by idx asc""", as_dict=1), - - 'int':int, - "webnotes": webnotes, - "utils": webnotes.utils - }) - - args.update(ret) - - settings = webnotes.doc("Website Settings", "Website Settings") - for k in ["banner_html", "brand_html", "copyright", "address", "twitter_share_via", - "favicon", "facebook_share", "google_plus_one", "twitter_share", "linked_in_share", - "disable_signup"]: - if k in settings.fields: - args[k] = settings.fields.get(k) - - for k in ["facebook_share", "google_plus_one", "twitter_share", "linked_in_share", - "disable_signup"]: - args[k] = cint(args.get(k) or 0) - - args.url = quote(str(get_request_site_address(full_address=True)), str("")) - args.encoded_title = quote(encode(args.title or ""), str("")) - args.shopping_cart_enabled = cint(webnotes.conn.get_default("shopping_cart_enabled")) - - return args @webnotes.whitelist() def update_profile(fullname, password=None, company_name=None, mobile_no=None, phone=None): From f4de333267459dc89d3310c8a42ce77b23609eff Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Tue, 10 Sep 2013 15:49:18 +0530 Subject: [PATCH 11/37] [website] [minor] moving to framework --- startup/webutils.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/startup/webutils.py b/startup/webutils.py index cd37be4964..b427b40ae6 100644 --- a/startup/webutils.py +++ b/startup/webutils.py @@ -3,6 +3,11 @@ import webnotes, conf, os from webnotes.utils import cint, cstr, encode + +def get_website_settings(): + return { + "shopping_cart_enabled": cint(webnotes.conn.get_default("shopping_cart_enabled")) + } @webnotes.whitelist() def update_profile(fullname, password=None, company_name=None, mobile_no=None, phone=None): From b0d996ffb19d7d49f51a3c2895aaa937d9fb4ca4 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Tue, 10 Sep 2013 18:29:39 +0530 Subject: [PATCH 12/37] [website] [minor] moving to framework --- .../doctype/sales_invoice/sales_invoice.py | 3 + .../sales_invoice/templates/__init__.py | 0 .../sales_invoice/templates/pages/__init__.py | 0 .../templates/pages/invoice.html | 0 .../sales_invoice}/templates/pages/invoice.py | 2 + .../templates/pages/invoices.html | 0 .../templates/pages/invoices.py | 2 + config.json | 106 ------------- portal/templates/includes/cart.js | 2 +- portal/templates/pages/account.py | 6 + portal/templates/pages/cart.html | 2 +- portal/templates/pages/cart.py | 6 + portal/templates/pages/profile.html | 4 +- portal/templates/pages/profile.py | 32 ++++ portal/templates/profile.html | 61 ------- selling/doctype/sales_order/sales_order.py | 3 + .../doctype/sales_order/templates/__init__.py | 0 .../sales_order/templates/pages/__init__.py | 0 .../sales_order}/templates/pages/order.html | 0 .../sales_order}/templates/pages/order.py | 2 + .../sales_order}/templates/pages/orders.html | 0 .../sales_order}/templates/pages/orders.py | 2 + .../shopping_cart_price_list/__init__.py | 0 .../shopping_cart_price_list.py | 11 ++ .../shopping_cart_price_list.txt | 36 +++++ .../shopping_cart_settings/__init__.py | 0 .../shopping_cart_settings.js | 10 ++ .../shopping_cart_settings.py | 149 ++++++++++++++++++ .../shopping_cart_settings.txt | 125 +++++++++++++++ .../test_shopping_cart_settings.py | 81 ++++++++++ .../shopping_cart_shipping_rule/__init__.py | 0 .../shopping_cart_shipping_rule.py | 11 ++ .../shopping_cart_shipping_rule.txt | 36 +++++ .../__init__.py | 0 .../shopping_cart_taxes_and_charges_master.py | 11 ++ ...shopping_cart_taxes_and_charges_master.txt | 36 +++++ selling/page/selling_home/selling_home.js | 6 + startup/webutils.py | 28 +--- stock/doctype/delivery_note/delivery_note.py | 3 + .../delivery_note/templates/__init__.py | 0 .../delivery_note/templates/pages/__init__.py | 0 .../templates/pages/shipment.html | 0 .../templates/pages/shipment.py | 2 + .../templates/pages/shipments.html | 0 .../templates/pages/shipments.py | 2 + .../item/templates/pages/product_search.html | 4 +- .../item/templates/pages/product_search.py | 6 + .../doctype/support_ticket/support_ticket.py | 3 + .../support_ticket/templates/pages/ticket.py | 2 + .../support_ticket/templates/pages/tickets.py | 2 + .../address/templates/pages/address.py | 2 + .../address/templates/pages/addresses.py | 6 + 52 files changed, 606 insertions(+), 199 deletions(-) create mode 100644 accounts/doctype/sales_invoice/templates/__init__.py create mode 100644 accounts/doctype/sales_invoice/templates/pages/__init__.py rename {portal => accounts/doctype/sales_invoice}/templates/pages/invoice.html (100%) rename {portal => accounts/doctype/sales_invoice}/templates/pages/invoice.py (96%) rename {portal => accounts/doctype/sales_invoice}/templates/pages/invoices.html (100%) rename {portal => accounts/doctype/sales_invoice}/templates/pages/invoices.py (97%) create mode 100644 portal/templates/pages/account.py create mode 100644 portal/templates/pages/cart.py create mode 100644 portal/templates/pages/profile.py delete mode 100644 portal/templates/profile.html create mode 100644 selling/doctype/sales_order/templates/__init__.py create mode 100644 selling/doctype/sales_order/templates/pages/__init__.py rename {portal => selling/doctype/sales_order}/templates/pages/order.html (100%) rename {portal => selling/doctype/sales_order}/templates/pages/order.py (96%) rename {portal => selling/doctype/sales_order}/templates/pages/orders.html (100%) rename {portal => selling/doctype/sales_order}/templates/pages/orders.py (97%) create mode 100644 selling/doctype/shopping_cart_price_list/__init__.py create mode 100644 selling/doctype/shopping_cart_price_list/shopping_cart_price_list.py create mode 100644 selling/doctype/shopping_cart_price_list/shopping_cart_price_list.txt create mode 100644 selling/doctype/shopping_cart_settings/__init__.py create mode 100644 selling/doctype/shopping_cart_settings/shopping_cart_settings.js create mode 100644 selling/doctype/shopping_cart_settings/shopping_cart_settings.py create mode 100644 selling/doctype/shopping_cart_settings/shopping_cart_settings.txt create mode 100644 selling/doctype/shopping_cart_settings/test_shopping_cart_settings.py create mode 100644 selling/doctype/shopping_cart_shipping_rule/__init__.py create mode 100644 selling/doctype/shopping_cart_shipping_rule/shopping_cart_shipping_rule.py create mode 100644 selling/doctype/shopping_cart_shipping_rule/shopping_cart_shipping_rule.txt create mode 100644 selling/doctype/shopping_cart_taxes_and_charges_master/__init__.py create mode 100644 selling/doctype/shopping_cart_taxes_and_charges_master/shopping_cart_taxes_and_charges_master.py create mode 100644 selling/doctype/shopping_cart_taxes_and_charges_master/shopping_cart_taxes_and_charges_master.txt create mode 100644 stock/doctype/delivery_note/templates/__init__.py create mode 100644 stock/doctype/delivery_note/templates/pages/__init__.py rename {portal => stock/doctype/delivery_note}/templates/pages/shipment.html (100%) rename {portal => stock/doctype/delivery_note}/templates/pages/shipment.py (96%) rename {portal => stock/doctype/delivery_note}/templates/pages/shipments.html (100%) rename {portal => stock/doctype/delivery_note}/templates/pages/shipments.py (97%) create mode 100644 stock/doctype/item/templates/pages/product_search.py create mode 100644 utilities/doctype/address/templates/pages/addresses.py diff --git a/accounts/doctype/sales_invoice/sales_invoice.py b/accounts/doctype/sales_invoice/sales_invoice.py index 17ae216e02..879ccaf441 100644 --- a/accounts/doctype/sales_invoice/sales_invoice.py +++ b/accounts/doctype/sales_invoice/sales_invoice.py @@ -148,6 +148,9 @@ class DocType(SellingController): self.validate_recurring_invoice() self.convert_to_recurring() + def get_portal_page(self): + return "invoice" if self.doc.docstatus==1 else None + def set_missing_values(self, for_validate=False): self.set_pos_fields(for_validate) diff --git a/accounts/doctype/sales_invoice/templates/__init__.py b/accounts/doctype/sales_invoice/templates/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/accounts/doctype/sales_invoice/templates/pages/__init__.py b/accounts/doctype/sales_invoice/templates/pages/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/portal/templates/pages/invoice.html b/accounts/doctype/sales_invoice/templates/pages/invoice.html similarity index 100% rename from portal/templates/pages/invoice.html rename to accounts/doctype/sales_invoice/templates/pages/invoice.html diff --git a/portal/templates/pages/invoice.py b/accounts/doctype/sales_invoice/templates/pages/invoice.py similarity index 96% rename from portal/templates/pages/invoice.py rename to accounts/doctype/sales_invoice/templates/pages/invoice.py index ed6e40a6e5..7196a3039b 100644 --- a/portal/templates/pages/invoice.py +++ b/accounts/doctype/sales_invoice/templates/pages/invoice.py @@ -4,6 +4,8 @@ from __future__ import unicode_literals import webnotes +no_cache = True + def get_context(): from portal.website_transactions import get_transaction_context context = get_transaction_context("Sales Invoice", webnotes.form_dict.name) diff --git a/portal/templates/pages/invoices.html b/accounts/doctype/sales_invoice/templates/pages/invoices.html similarity index 100% rename from portal/templates/pages/invoices.html rename to accounts/doctype/sales_invoice/templates/pages/invoices.html diff --git a/portal/templates/pages/invoices.py b/accounts/doctype/sales_invoice/templates/pages/invoices.py similarity index 97% rename from portal/templates/pages/invoices.py rename to accounts/doctype/sales_invoice/templates/pages/invoices.py index 2bb6490903..c72903ba12 100644 --- a/portal/templates/pages/invoices.py +++ b/accounts/doctype/sales_invoice/templates/pages/invoices.py @@ -4,6 +4,8 @@ from __future__ import unicode_literals import webnotes +no_cache = True + def get_context(): from portal.website_transactions import get_currency_context context = get_currency_context() diff --git a/config.json b/config.json index 3f5851113d..17b01edb25 100644 --- a/config.json +++ b/config.json @@ -72,111 +72,5 @@ "label": "Notes", "icon": "icon-file-alt" } - }, - "web": { - "pages": { - "account": { - "no_cache": true, - "template": "app/portal/templates/account.html" - }, - "order": { - "no_cache": true, - "template": "app/portal/templates/sale.html", - "args_method": "utilities.website_transactions.get_order_args", - "portal": { - "doctype": "Sales Order", - "conditions": { - "docstatus": 1 - } - } - }, - "orders": { - "no_cache": true, - "template": "app/portal/templates/sales_transactions.html", - "args_method": "utilities.website_transactions.order_list_args" - }, - "invoice": { - "no_cache": true, - "template": "app/portal/templates/sale.html", - "args_method": "utilities.website_transactions.get_invoice_args", - "portal": { - "doctype": "Sales Invoice", - "conditions": { - "docstatus": 1 - } - } - }, - "invoices": { - "no_cache": true, - "template": "app/portal/templates/sales_transactions.html", - "args_method": "utilities.website_transactions.invoice_list_args" - }, - "shipment": { - "no_cache": true, - "template": "app/portal/templates/sale.html", - "args_method": "utilities.website_transactions.get_shipment_args", - "portal": { - "doctype": "Delivery Note", - "conditions": { - "docstatus": 1 - } - } - }, - "shipments": { - "no_cache": true, - "template": "app/portal/templates/sales_transactions.html", - "args_method": "utilities.website_transactions.shipment_list_args" - }, - "product_search": { - "template": "app/stock/doctype/item/templates/product_search.html" - }, - "ticket": { - "no_cache": true, - "template": "app/support/doctype/support_ticket/templates/ticket.html", - "args_method": "support.doctype.support_ticket.support_ticket.get_website_args", - "portal": { - "doctype": "Support Ticket" - } - }, - "tickets": { - "template": "app/support/doctype/support_ticket/templates/tickets.html", - "args_method": "utilities.website_transactions.ticket_list_args" - }, - "address": { - "no_cache": true, - "template": "app/utilities/doctype/address/templates/address.html", - "args_method": "utilities.doctype.address.address.get_website_args" - }, - "addresses": { - "template": "app/utilities/doctype/address/templates/addresses.html" - }, - "profile": { - "no_cache": true, - "template": "app/portal/templates/profile.html", - "args_method": "startup.webutils.get_profile_args" - }, - "cart": { - "no_cache": true, - "template": "app/portal/templates/cart.html" - }, - "partners": { - "template": "app/setup/doctype/sales_partners/templates/partners.html", - "args_method": "setup.doctype.sales_partner.sales_partner.get_partner_args" - } - }, - "generators": { - "Item": { - "template": "app/stock/doctype/item/templates/item.html", - "condition_field": "show_in_website" - }, - "Item Group":{ - "template": "app/setup/doctype/item_group/templates/item_group.html", - "condition_field": "show_in_website" - }, - "Sales Partner": { - "template": "app/setup/doctype/sales_partner/templates/partner_page.html", - "condition_field": "show_in_website" - } - } } } \ No newline at end of file diff --git a/portal/templates/includes/cart.js b/portal/templates/includes/cart.js index 63c6463ac4..84d49f33c4 100644 --- a/portal/templates/includes/cart.js +++ b/portal/templates/includes/cart.js @@ -128,7 +128,7 @@ $.extend(wn.cart, { render_item_row: function($cart_items, doc) { doc.image_html = doc.image ? '
    ' : - '{% include "app/website/templates/html/product_missing_image.html" %}'; + '{% include "app/stock/doctype/item/templates/includes/product_missing_image.html" %}'; if(doc.description === doc.item_name) doc.description = ""; diff --git a/portal/templates/pages/account.py b/portal/templates/pages/account.py new file mode 100644 index 0000000000..24b474a55c --- /dev/null +++ b/portal/templates/pages/account.py @@ -0,0 +1,6 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. +# License: GNU General Public License v3. See license.txt + +from __future__ import unicode_literals + +no_cache = True \ No newline at end of file diff --git a/portal/templates/pages/cart.html b/portal/templates/pages/cart.html index 372f5241b0..f210772831 100644 --- a/portal/templates/pages/cart.html +++ b/portal/templates/pages/cart.html @@ -1,7 +1,7 @@ {% extends base_template %} {% block javascript %} - {% include "app/website/templates/js/cart.js" %} + {% endblock %} {% set title="Shopping Cart" %} diff --git a/portal/templates/pages/cart.py b/portal/templates/pages/cart.py new file mode 100644 index 0000000000..24b474a55c --- /dev/null +++ b/portal/templates/pages/cart.py @@ -0,0 +1,6 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. +# License: GNU General Public License v3. See license.txt + +from __future__ import unicode_literals + +no_cache = True \ No newline at end of file diff --git a/portal/templates/pages/profile.html b/portal/templates/pages/profile.html index 2fe03ba911..65f3e37988 100644 --- a/portal/templates/pages/profile.html +++ b/portal/templates/pages/profile.html @@ -9,7 +9,7 @@
  • My Account
  • My Profile
  • - +
    @@ -39,7 +39,7 @@ $(document).ready(function() { $("#fullname").val(getCookie("full_name") || ""); $("#update_profile").click(function() { wn.call({ - method: "startup.webutils.update_profile", + method: "portal.templates.pages.profile.update_profile", type: "POST", args: { fullname: $("#fullname").val(), diff --git a/portal/templates/pages/profile.py b/portal/templates/pages/profile.py new file mode 100644 index 0000000000..b7be74cdcd --- /dev/null +++ b/portal/templates/pages/profile.py @@ -0,0 +1,32 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. +# License: GNU General Public License v3. See license.txt + +from __future__ import unicode_literals +import webnotes +from webnotes.utils import cstr + +no_cache = True + +def get_context(): + from selling.utils.cart import get_lead_or_customer + party = get_lead_or_customer() + if party.doctype == "Lead": + mobile_no = party.mobile_no + phone = party.phone + else: + mobile_no, phone = webnotes.conn.get_value("Contact", {"email_id": webnotes.session.user, + "customer": party.name}, ["mobile_no", "phone"]) + + return { + "company_name": cstr(party.customer_name if party.doctype == "Customer" else party.company_name), + "mobile_no": cstr(mobile_no), + "phone": cstr(phone) + } + +@webnotes.whitelist() +def update_profile(fullname, password=None, company_name=None, mobile_no=None, phone=None): + from selling.utils.cart import update_party + update_party(fullname, company_name, mobile_no, phone) + + from core.doctype.profile import profile + return profile.update_profile(fullname, password) \ No newline at end of file diff --git a/portal/templates/profile.html b/portal/templates/profile.html deleted file mode 100644 index e8e60b4cf6..0000000000 --- a/portal/templates/profile.html +++ /dev/null @@ -1,61 +0,0 @@ -{% extends base_template %} - -{% set title="My Profile" %} - -{% block content %} -
    - - - -
    - - -
    -
    - - -
    -
    - - -
    -
    - - -
    -
    - - -
    - - -
    - -{% endblock %} \ No newline at end of file diff --git a/selling/doctype/sales_order/sales_order.py b/selling/doctype/sales_order/sales_order.py index 602674e072..37314845ad 100644 --- a/selling/doctype/sales_order/sales_order.py +++ b/selling/doctype/sales_order/sales_order.py @@ -286,6 +286,9 @@ class DocType(SellingController): def on_update(self): pass + def get_portal_page(self): + return "order" if self.doc.docstatus==1 else None + def set_missing_values(source, target): bean = webnotes.bean(target) bean.run_method("onload_post_render") diff --git a/selling/doctype/sales_order/templates/__init__.py b/selling/doctype/sales_order/templates/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/selling/doctype/sales_order/templates/pages/__init__.py b/selling/doctype/sales_order/templates/pages/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/portal/templates/pages/order.html b/selling/doctype/sales_order/templates/pages/order.html similarity index 100% rename from portal/templates/pages/order.html rename to selling/doctype/sales_order/templates/pages/order.html diff --git a/portal/templates/pages/order.py b/selling/doctype/sales_order/templates/pages/order.py similarity index 96% rename from portal/templates/pages/order.py rename to selling/doctype/sales_order/templates/pages/order.py index 47e2c68d82..f25a521e22 100644 --- a/portal/templates/pages/order.py +++ b/selling/doctype/sales_order/templates/pages/order.py @@ -4,6 +4,8 @@ from __future__ import unicode_literals import webnotes +no_cache = True + def get_context(): from portal.website_transactions import get_transaction_context context = get_transaction_context("Sales Order", webnotes.form_dict.name) diff --git a/portal/templates/pages/orders.html b/selling/doctype/sales_order/templates/pages/orders.html similarity index 100% rename from portal/templates/pages/orders.html rename to selling/doctype/sales_order/templates/pages/orders.html diff --git a/portal/templates/pages/orders.py b/selling/doctype/sales_order/templates/pages/orders.py similarity index 97% rename from portal/templates/pages/orders.py rename to selling/doctype/sales_order/templates/pages/orders.py index 3c62d35b24..204e3f7a15 100644 --- a/portal/templates/pages/orders.py +++ b/selling/doctype/sales_order/templates/pages/orders.py @@ -4,6 +4,8 @@ from __future__ import unicode_literals import webnotes +no_cache = True + def get_context(): from portal.website_transactions import get_currency_context context = get_currency_context() diff --git a/selling/doctype/shopping_cart_price_list/__init__.py b/selling/doctype/shopping_cart_price_list/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/selling/doctype/shopping_cart_price_list/shopping_cart_price_list.py b/selling/doctype/shopping_cart_price_list/shopping_cart_price_list.py new file mode 100644 index 0000000000..784339de7d --- /dev/null +++ b/selling/doctype/shopping_cart_price_list/shopping_cart_price_list.py @@ -0,0 +1,11 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. +# License: GNU General Public License v3. See license.txt + +# For license information, please see license.txt + +from __future__ import unicode_literals +import webnotes + +class DocType: + def __init__(self, d, dl): + self.doc, self.doclist = d, dl \ No newline at end of file diff --git a/selling/doctype/shopping_cart_price_list/shopping_cart_price_list.txt b/selling/doctype/shopping_cart_price_list/shopping_cart_price_list.txt new file mode 100644 index 0000000000..1737c65c90 --- /dev/null +++ b/selling/doctype/shopping_cart_price_list/shopping_cart_price_list.txt @@ -0,0 +1,36 @@ +[ + { + "creation": "2013-06-20 16:00:18", + "docstatus": 0, + "modified": "2013-08-09 14:47:15", + "modified_by": "Administrator", + "owner": "Administrator" + }, + { + "doctype": "DocType", + "istable": 1, + "module": "Selling", + "name": "__common__" + }, + { + "doctype": "DocField", + "fieldname": "selling_price_list", + "fieldtype": "Link", + "in_list_view": 1, + "label": "Price List", + "name": "__common__", + "options": "Price List", + "parent": "Shopping Cart Price List", + "parentfield": "fields", + "parenttype": "DocType", + "permlevel": 0, + "reqd": 1 + }, + { + "doctype": "DocType", + "name": "Shopping Cart Price List" + }, + { + "doctype": "DocField" + } +] \ No newline at end of file diff --git a/selling/doctype/shopping_cart_settings/__init__.py b/selling/doctype/shopping_cart_settings/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/selling/doctype/shopping_cart_settings/shopping_cart_settings.js b/selling/doctype/shopping_cart_settings/shopping_cart_settings.js new file mode 100644 index 0000000000..c38c757a5e --- /dev/null +++ b/selling/doctype/shopping_cart_settings/shopping_cart_settings.js @@ -0,0 +1,10 @@ +// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. +// License: GNU General Public License v3. See license.txt + +$.extend(cur_frm.cscript, { + onload: function() { + if(cur_frm.doc.__quotation_series) { + cur_frm.fields_dict.quotation_series.df.options = cur_frm.doc.__quotation_series; + } + } +}); \ No newline at end of file diff --git a/selling/doctype/shopping_cart_settings/shopping_cart_settings.py b/selling/doctype/shopping_cart_settings/shopping_cart_settings.py new file mode 100644 index 0000000000..74cc217d28 --- /dev/null +++ b/selling/doctype/shopping_cart_settings/shopping_cart_settings.py @@ -0,0 +1,149 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. +# License: GNU General Public License v3. See license.txt + +# For license information, please see license.txt + +from __future__ import unicode_literals +import webnotes +from webnotes import _, msgprint +from webnotes.utils import comma_and +from webnotes.model.controller import DocListController + +class ShoppingCartSetupError(webnotes.ValidationError): pass + +class DocType(DocListController): + def onload(self): + self.doc.fields["__quotation_series"] = webnotes.get_doctype("Quotation").get_options("naming_series") + + def validate(self): + if self.doc.enabled: + self.validate_price_lists() + self.validate_tax_masters() + self.validate_exchange_rates_exist() + + def on_update(self): + webnotes.conn.set_default("shopping_cart_enabled", self.doc.fields.get("enabled") or 0) + webnotes.conn.set_default("shopping_cart_quotation_series", self.doc.fields.get("quotation_series")) + + def validate_overlapping_territories(self, parentfield, fieldname): + # for displaying message + doctype = self.meta.get_field(parentfield).options + + # specify atleast one entry in the table + self.validate_table_has_rows(parentfield, raise_exception=ShoppingCartSetupError) + + territory_name_map = self.get_territory_name_map(parentfield, fieldname) + for territory, names in territory_name_map.items(): + if len(names) > 1: + msgprint(_("Error for") + " " + _(doctype) + ": " + comma_and(names) + + " " + _("have a common territory") + ": " + territory, + raise_exception=ShoppingCartSetupError) + + return territory_name_map + + def validate_price_lists(self): + territory_name_map = self.validate_overlapping_territories("price_lists", + "selling_price_list") + + # validate that a Shopping Cart Price List exists for the root territory + # as a catch all! + from setup.utils import get_root_of + root_territory = get_root_of("Territory") + + if root_territory not in territory_name_map.keys(): + msgprint(_("Please specify a Price List which is valid for Territory") + + ": " + root_territory, raise_exception=ShoppingCartSetupError) + + def validate_tax_masters(self): + self.validate_overlapping_territories("sales_taxes_and_charges_masters", + "sales_taxes_and_charges_master") + + def get_territory_name_map(self, parentfield, fieldname): + territory_name_map = {} + + # entries in table + names = [doc.fields.get(fieldname) for doc in self.doclist.get({"parentfield": parentfield})] + + if names: + # for condition in territory check + parenttype = self.meta.get_field(fieldname, parentfield=parentfield).options + + # to validate territory overlap + # make a map of territory: [list of names] + # if list against each territory has more than one element, raise exception + territory_name = webnotes.conn.sql("""select `territory`, `parent` + from `tabFor Territory` + where `parenttype`=%s and `parent` in (%s)""" % + ("%s", ", ".join(["%s"]*len(names))), tuple([parenttype] + names)) + + for territory, name in territory_name: + territory_name_map.setdefault(territory, []).append(name) + + if len(territory_name_map[territory]) > 1: + territory_name_map[territory].sort(key=lambda val: names.index(val)) + + return territory_name_map + + def validate_exchange_rates_exist(self): + """check if exchange rates exist for all Price List currencies (to company's currency)""" + company_currency = webnotes.conn.get_value("Company", self.doc.company, "default_currency") + if not company_currency: + msgprint(_("Please specify currency in Company") + ": " + self.doc.company, + raise_exception=ShoppingCartSetupError) + + price_list_currency_map = webnotes.conn.get_values("Price List", + [d.selling_price_list for d in self.doclist.get({"parentfield": "price_lists"})], + "currency") + + expected_to_exist = [currency + "-" + company_currency + for currency in price_list_currency_map.values() + if currency != company_currency] + + if expected_to_exist: + exists = webnotes.conn.sql_list("""select name from `tabCurrency Exchange` + where name in (%s)""" % (", ".join(["%s"]*len(expected_to_exist)),), + tuple(expected_to_exist)) + + missing = list(set(expected_to_exist).difference(exists)) + + if missing: + msgprint(_("Missing Currency Exchange Rates for" + ": " + comma_and(missing)), + raise_exception=ShoppingCartSetupError) + + def get_name_from_territory(self, territory, parentfield, fieldname): + name = None + territory_name_map = self.get_territory_name_map(parentfield, fieldname) + + if territory_name_map.get(territory): + name = territory_name_map.get(territory) + else: + territory_ancestry = self.get_territory_ancestry(territory) + for ancestor in territory_ancestry: + if territory_name_map.get(ancestor): + name = territory_name_map.get(ancestor) + break + + return name + + def get_price_list(self, billing_territory): + price_list = self.get_name_from_territory(billing_territory, "price_lists", "selling_price_list") + return price_list and price_list[0] or None + + def get_tax_master(self, billing_territory): + tax_master = self.get_name_from_territory(billing_territory, "sales_taxes_and_charges_masters", + "sales_taxes_and_charges_master") + return tax_master and tax_master[0] or None + + def get_shipping_rules(self, shipping_territory): + return self.get_name_from_territory(shipping_territory, "shipping_rules", "shipping_rule") + + def get_territory_ancestry(self, territory): + from setup.utils import get_ancestors_of + + if not hasattr(self, "_territory_ancestry"): + self._territory_ancestry = {} + + if not self._territory_ancestry.get(territory): + self._territory_ancestry[territory] = get_ancestors_of("Territory", territory) + + return self._territory_ancestry[territory] \ No newline at end of file diff --git a/selling/doctype/shopping_cart_settings/shopping_cart_settings.txt b/selling/doctype/shopping_cart_settings/shopping_cart_settings.txt new file mode 100644 index 0000000000..531f8dac4c --- /dev/null +++ b/selling/doctype/shopping_cart_settings/shopping_cart_settings.txt @@ -0,0 +1,125 @@ +[ + { + "creation": "2013-06-19 15:57:32", + "docstatus": 0, + "modified": "2013-07-15 17:33:15", + "modified_by": "Administrator", + "owner": "Administrator" + }, + { + "description": "Default settings for Shopping Cart", + "doctype": "DocType", + "icon": "icon-shopping-cart", + "issingle": 1, + "module": "Selling", + "name": "__common__" + }, + { + "doctype": "DocField", + "name": "__common__", + "parent": "Shopping Cart Settings", + "parentfield": "fields", + "parenttype": "DocType", + "permlevel": 0 + }, + { + "create": 1, + "doctype": "DocPerm", + "name": "__common__", + "parent": "Shopping Cart Settings", + "parentfield": "permissions", + "parenttype": "DocType", + "permlevel": 0, + "read": 1, + "role": "Website Manager", + "write": 1 + }, + { + "doctype": "DocType", + "name": "Shopping Cart Settings" + }, + { + "doctype": "DocField", + "fieldname": "enabled", + "fieldtype": "Check", + "label": "Enable Shopping Cart" + }, + { + "doctype": "DocField", + "fieldname": "section_break_2", + "fieldtype": "Section Break" + }, + { + "doctype": "DocField", + "fieldname": "company", + "fieldtype": "Link", + "label": "Company", + "options": "Company", + "reqd": 1 + }, + { + "doctype": "DocField", + "fieldname": "default_territory", + "fieldtype": "Link", + "label": "Default Territory", + "options": "Territory", + "reqd": 1 + }, + { + "doctype": "DocField", + "fieldname": "column_break_4", + "fieldtype": "Column Break" + }, + { + "doctype": "DocField", + "fieldname": "default_customer_group", + "fieldtype": "Link", + "label": "Default Customer Group", + "options": "Customer Group", + "reqd": 1 + }, + { + "doctype": "DocField", + "fieldname": "quotation_series", + "fieldtype": "Select", + "label": "Quotation Series", + "reqd": 1 + }, + { + "doctype": "DocField", + "fieldname": "section_break_6", + "fieldtype": "Section Break" + }, + { + "doctype": "DocField", + "fieldname": "price_lists", + "fieldtype": "Table", + "label": "Shopping Cart Price Lists", + "options": "Shopping Cart Price List", + "reqd": 0 + }, + { + "doctype": "DocField", + "fieldname": "shipping_rules", + "fieldtype": "Table", + "label": "Shopping Cart Shipping Rules", + "options": "Shopping Cart Shipping Rule", + "reqd": 0 + }, + { + "doctype": "DocField", + "fieldname": "column_break_10", + "fieldtype": "Column Break" + }, + { + "doctype": "DocField", + "fieldname": "sales_taxes_and_charges_masters", + "fieldtype": "Table", + "label": "Shopping Cart Taxes and Charges Masters", + "options": "Shopping Cart Taxes and Charges Master", + "reqd": 0 + }, + { + "doctype": "DocPerm" + } +] \ No newline at end of file diff --git a/selling/doctype/shopping_cart_settings/test_shopping_cart_settings.py b/selling/doctype/shopping_cart_settings/test_shopping_cart_settings.py new file mode 100644 index 0000000000..77c7e2379c --- /dev/null +++ b/selling/doctype/shopping_cart_settings/test_shopping_cart_settings.py @@ -0,0 +1,81 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. +# License: GNU General Public License v3. See license.txt + +# For license information, please see license.txt + +from __future__ import unicode_literals +import webnotes +import unittest +from selling.doctype.shopping_cart_settings.shopping_cart_settings import ShoppingCartSetupError + +class TestShoppingCartSettings(unittest.TestCase): + def setUp(self): + webnotes.conn.sql("""delete from `tabSingles` where doctype="Shipping Cart Settings" """) + webnotes.conn.sql("""delete from `tabShopping Cart Price List`""") + webnotes.conn.sql("""delete from `tabShopping Cart Taxes and Charges Master`""") + webnotes.conn.sql("""delete from `tabShopping Cart Shipping Rule`""") + + def get_cart_settings(self): + return webnotes.bean({"doctype": "Shopping Cart Settings", + "company": "_Test Company"}) + + def test_price_list_territory_overlap(self): + cart_settings = self.get_cart_settings() + + def _add_price_list(price_list): + cart_settings.doclist.append({ + "doctype": "Shopping Cart Price List", + "parentfield": "price_lists", + "selling_price_list": price_list + }) + + for price_list in ("_Test Price List Rest of the World", "_Test Price List India", + "_Test Price List"): + _add_price_list(price_list) + + controller = cart_settings.make_controller() + controller.validate_overlapping_territories("price_lists", "selling_price_list") + + _add_price_list("_Test Price List 2") + + controller = cart_settings.make_controller() + self.assertRaises(ShoppingCartSetupError, controller.validate_overlapping_territories, + "price_lists", "selling_price_list") + + return cart_settings + + def test_taxes_territory_overlap(self): + cart_settings = self.get_cart_settings() + + def _add_tax_master(tax_master): + cart_settings.doclist.append({ + "doctype": "Shopping Cart Taxes and Charges Master", + "parentfield": "sales_taxes_and_charges_masters", + "sales_taxes_and_charges_master": tax_master + }) + + for tax_master in ("_Test Sales Taxes and Charges Master", "_Test India Tax Master"): + _add_tax_master(tax_master) + + controller = cart_settings.make_controller() + controller.validate_overlapping_territories("sales_taxes_and_charges_masters", + "sales_taxes_and_charges_master") + + _add_tax_master("_Test Sales Taxes and Charges Master 2") + + controller = cart_settings.make_controller() + self.assertRaises(ShoppingCartSetupError, controller.validate_overlapping_territories, + "sales_taxes_and_charges_masters", "sales_taxes_and_charges_master") + + def test_exchange_rate_exists(self): + webnotes.conn.sql("""delete from `tabCurrency Exchange`""") + + cart_settings = self.test_price_list_territory_overlap() + controller = cart_settings.make_controller() + self.assertRaises(ShoppingCartSetupError, controller.validate_exchange_rates_exist) + + from setup.doctype.currency_exchange.test_currency_exchange import test_records as \ + currency_exchange_records + webnotes.bean(currency_exchange_records[0]).insert() + controller.validate_exchange_rates_exist() + diff --git a/selling/doctype/shopping_cart_shipping_rule/__init__.py b/selling/doctype/shopping_cart_shipping_rule/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/selling/doctype/shopping_cart_shipping_rule/shopping_cart_shipping_rule.py b/selling/doctype/shopping_cart_shipping_rule/shopping_cart_shipping_rule.py new file mode 100644 index 0000000000..784339de7d --- /dev/null +++ b/selling/doctype/shopping_cart_shipping_rule/shopping_cart_shipping_rule.py @@ -0,0 +1,11 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. +# License: GNU General Public License v3. See license.txt + +# For license information, please see license.txt + +from __future__ import unicode_literals +import webnotes + +class DocType: + def __init__(self, d, dl): + self.doc, self.doclist = d, dl \ No newline at end of file diff --git a/selling/doctype/shopping_cart_shipping_rule/shopping_cart_shipping_rule.txt b/selling/doctype/shopping_cart_shipping_rule/shopping_cart_shipping_rule.txt new file mode 100644 index 0000000000..8c9c34a079 --- /dev/null +++ b/selling/doctype/shopping_cart_shipping_rule/shopping_cart_shipping_rule.txt @@ -0,0 +1,36 @@ +[ + { + "creation": "2013-07-03 13:15:34", + "docstatus": 0, + "modified": "2013-07-10 14:54:25", + "modified_by": "Administrator", + "owner": "Administrator" + }, + { + "doctype": "DocType", + "istable": 1, + "module": "Selling", + "name": "__common__" + }, + { + "doctype": "DocField", + "fieldname": "shipping_rule", + "fieldtype": "Link", + "in_list_view": 1, + "label": "Shipping Rule", + "name": "__common__", + "options": "Shipping Rule", + "parent": "Shopping Cart Shipping Rule", + "parentfield": "fields", + "parenttype": "DocType", + "permlevel": 0, + "reqd": 1 + }, + { + "doctype": "DocType", + "name": "Shopping Cart Shipping Rule" + }, + { + "doctype": "DocField" + } +] \ No newline at end of file diff --git a/selling/doctype/shopping_cart_taxes_and_charges_master/__init__.py b/selling/doctype/shopping_cart_taxes_and_charges_master/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/selling/doctype/shopping_cart_taxes_and_charges_master/shopping_cart_taxes_and_charges_master.py b/selling/doctype/shopping_cart_taxes_and_charges_master/shopping_cart_taxes_and_charges_master.py new file mode 100644 index 0000000000..784339de7d --- /dev/null +++ b/selling/doctype/shopping_cart_taxes_and_charges_master/shopping_cart_taxes_and_charges_master.py @@ -0,0 +1,11 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. +# License: GNU General Public License v3. See license.txt + +# For license information, please see license.txt + +from __future__ import unicode_literals +import webnotes + +class DocType: + def __init__(self, d, dl): + self.doc, self.doclist = d, dl \ No newline at end of file diff --git a/selling/doctype/shopping_cart_taxes_and_charges_master/shopping_cart_taxes_and_charges_master.txt b/selling/doctype/shopping_cart_taxes_and_charges_master/shopping_cart_taxes_and_charges_master.txt new file mode 100644 index 0000000000..a61f8dbdf1 --- /dev/null +++ b/selling/doctype/shopping_cart_taxes_and_charges_master/shopping_cart_taxes_and_charges_master.txt @@ -0,0 +1,36 @@ +[ + { + "creation": "2013-06-20 16:57:03", + "docstatus": 0, + "modified": "2013-07-10 14:54:25", + "modified_by": "Administrator", + "owner": "Administrator" + }, + { + "doctype": "DocType", + "istable": 1, + "module": "Selling", + "name": "__common__" + }, + { + "doctype": "DocField", + "fieldname": "sales_taxes_and_charges_master", + "fieldtype": "Link", + "in_list_view": 1, + "label": "Tax Master", + "name": "__common__", + "options": "Sales Taxes and Charges Master", + "parent": "Shopping Cart Taxes and Charges Master", + "parentfield": "fields", + "parenttype": "DocType", + "permlevel": 0, + "reqd": 1 + }, + { + "doctype": "DocType", + "name": "Shopping Cart Taxes and Charges Master" + }, + { + "doctype": "DocField" + } +] \ No newline at end of file diff --git a/selling/page/selling_home/selling_home.js b/selling/page/selling_home/selling_home.js index 4860d42a38..9697ccf985 100644 --- a/selling/page/selling_home/selling_home.js +++ b/selling/page/selling_home/selling_home.js @@ -65,6 +65,12 @@ wn.module_page["Selling"] = [ "doctype":"Selling Settings", "description": "Settings for Selling Module" }, + { + "route":"Form/Shopping Cart Settings", + "label":wn._("Shopping Cart Settings"), + "description":wn._("Setup of Shopping Cart."), + doctype:"Shopping Cart Settings" + }, { label: wn._("Sales Taxes and Charges Master"), description: wn._("Sales taxes template."), diff --git a/startup/webutils.py b/startup/webutils.py index b427b40ae6..9f1d12c92b 100644 --- a/startup/webutils.py +++ b/startup/webutils.py @@ -1,34 +1,10 @@ # Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. # License: GNU General Public License v3. See license.txt -import webnotes, conf, os -from webnotes.utils import cint, cstr, encode +import webnotes +from webnotes.utils import cint def get_website_settings(): return { "shopping_cart_enabled": cint(webnotes.conn.get_default("shopping_cart_enabled")) - } - -@webnotes.whitelist() -def update_profile(fullname, password=None, company_name=None, mobile_no=None, phone=None): - from selling.utils.cart import update_party - update_party(fullname, company_name, mobile_no, phone) - - from core.doctype.profile import profile - return profile.update_profile(fullname, password) - -def get_profile_args(): - from selling.utils.cart import get_lead_or_customer - party = get_lead_or_customer() - if party.doctype == "Lead": - mobile_no = party.mobile_no - phone = party.phone - else: - mobile_no, phone = webnotes.conn.get_value("Contact", {"email_id": webnotes.session.user, - "customer": party.name}, ["mobile_no", "phone"]) - - return { - "company_name": cstr(party.customer_name if party.doctype == "Customer" else party.company_name), - "mobile_no": cstr(mobile_no), - "phone": cstr(phone) } \ No newline at end of file diff --git a/stock/doctype/delivery_note/delivery_note.py b/stock/doctype/delivery_note/delivery_note.py index eb39944fd4..042b197f13 100644 --- a/stock/doctype/delivery_note/delivery_note.py +++ b/stock/doctype/delivery_note/delivery_note.py @@ -43,6 +43,9 @@ class DocType(SellingController): if billed_qty: total_qty = sum((item.qty for item in self.doclist.get({"parentfield": "delivery_note_details"}))) self.doc.fields["__billing_complete"] = billed_qty[0][0] == total_qty + + def get_portal_page(self): + return "shipment" if self.doc.docstatus==1 else None def get_contact_details(self): return get_obj('Sales Common').get_contact_details(self,0) diff --git a/stock/doctype/delivery_note/templates/__init__.py b/stock/doctype/delivery_note/templates/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/stock/doctype/delivery_note/templates/pages/__init__.py b/stock/doctype/delivery_note/templates/pages/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/portal/templates/pages/shipment.html b/stock/doctype/delivery_note/templates/pages/shipment.html similarity index 100% rename from portal/templates/pages/shipment.html rename to stock/doctype/delivery_note/templates/pages/shipment.html diff --git a/portal/templates/pages/shipment.py b/stock/doctype/delivery_note/templates/pages/shipment.py similarity index 96% rename from portal/templates/pages/shipment.py rename to stock/doctype/delivery_note/templates/pages/shipment.py index 5d9d1d1435..60dc9d872a 100644 --- a/portal/templates/pages/shipment.py +++ b/stock/doctype/delivery_note/templates/pages/shipment.py @@ -4,6 +4,8 @@ from __future__ import unicode_literals import webnotes +no_cache = True + def get_context(): from portal.website_transactions import get_transaction_context context = get_transaction_context("Delivery Note", webnotes.form_dict.name) diff --git a/portal/templates/pages/shipments.html b/stock/doctype/delivery_note/templates/pages/shipments.html similarity index 100% rename from portal/templates/pages/shipments.html rename to stock/doctype/delivery_note/templates/pages/shipments.html diff --git a/portal/templates/pages/shipments.py b/stock/doctype/delivery_note/templates/pages/shipments.py similarity index 97% rename from portal/templates/pages/shipments.py rename to stock/doctype/delivery_note/templates/pages/shipments.py index 4847b9f2e3..48c636d8dc 100644 --- a/portal/templates/pages/shipments.py +++ b/stock/doctype/delivery_note/templates/pages/shipments.py @@ -4,6 +4,8 @@ from __future__ import unicode_literals import webnotes +no_cache = True + def get_context(): from portal.website_transactions import get_currency_context context = get_currency_context() diff --git a/stock/doctype/item/templates/pages/product_search.html b/stock/doctype/item/templates/pages/product_search.html index 37e50dc0a1..9c6eeab6b5 100644 --- a/stock/doctype/item/templates/pages/product_search.html +++ b/stock/doctype/item/templates/pages/product_search.html @@ -3,7 +3,7 @@ {% set title="Product Search" %} {% block javascript %} -{% include "app/website/templates/js/product_list.js" %} + {% endblock %} {% block content %} @@ -17,7 +17,7 @@ $(document).ready(function() { }); -{% include 'app/website/templates/html/product_search_box.html' %} +{% include "app/stock/doctype/item/templates/includes/product_search_box.html" %}

    Search Results

    diff --git a/stock/doctype/item/templates/pages/product_search.py b/stock/doctype/item/templates/pages/product_search.py new file mode 100644 index 0000000000..24b474a55c --- /dev/null +++ b/stock/doctype/item/templates/pages/product_search.py @@ -0,0 +1,6 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. +# License: GNU General Public License v3. See license.txt + +from __future__ import unicode_literals + +no_cache = True \ No newline at end of file diff --git a/support/doctype/support_ticket/support_ticket.py b/support/doctype/support_ticket/support_ticket.py index 2cbd65e744..bf2a9fbabe 100644 --- a/support/doctype/support_ticket/support_ticket.py +++ b/support/doctype/support_ticket/support_ticket.py @@ -24,6 +24,9 @@ class DocType(TransactionBase): if signature: content += '

    ' + signature + '

    ' return content + + def get_portal_page(self): + return "ticket" def validate(self): self.update_status() diff --git a/support/doctype/support_ticket/templates/pages/ticket.py b/support/doctype/support_ticket/templates/pages/ticket.py index 2227a6a5cb..999f69f8b9 100644 --- a/support/doctype/support_ticket/templates/pages/ticket.py +++ b/support/doctype/support_ticket/templates/pages/ticket.py @@ -4,6 +4,8 @@ from __future__ import unicode_literals import webnotes +no_cache = True + def get_context(): bean = webnotes.bean("Support Ticket", webnotes.form_dict.name) if bean.doc.raised_by != webnotes.session.user: diff --git a/support/doctype/support_ticket/templates/pages/tickets.py b/support/doctype/support_ticket/templates/pages/tickets.py index 21892a1cae..f434746b70 100644 --- a/support/doctype/support_ticket/templates/pages/tickets.py +++ b/support/doctype/support_ticket/templates/pages/tickets.py @@ -5,6 +5,8 @@ from __future__ import unicode_literals import webnotes from webnotes.utils import cint, formatdate +no_cache = True + def get_context(): return { "title": "My Tickets", diff --git a/utilities/doctype/address/templates/pages/address.py b/utilities/doctype/address/templates/pages/address.py index d87974d0d8..d968c92eda 100644 --- a/utilities/doctype/address/templates/pages/address.py +++ b/utilities/doctype/address/templates/pages/address.py @@ -5,6 +5,8 @@ from __future__ import unicode_literals import webnotes from webnotes.utils import cint +no_cache = True + def get_context(): def _get_fields(fieldnames): return [webnotes._dict(zip(["label", "fieldname", "fieldtype", "options"], diff --git a/utilities/doctype/address/templates/pages/addresses.py b/utilities/doctype/address/templates/pages/addresses.py new file mode 100644 index 0000000000..24b474a55c --- /dev/null +++ b/utilities/doctype/address/templates/pages/addresses.py @@ -0,0 +1,6 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. +# License: GNU General Public License v3. See license.txt + +from __future__ import unicode_literals + +no_cache = True \ No newline at end of file From db59ffb76d5650a888833e8c947abb777fde3d5b Mon Sep 17 00:00:00 2001 From: Akhilesh Darjee Date: Wed, 11 Sep 2013 13:05:24 +0530 Subject: [PATCH 13/37] [usability] item price moved to price list --- accounts/doctype/sales_invoice/pos.js | 2 +- accounts/doctype/sales_invoice/pos.py | 13 +++--- .../purchase_common/purchase_common.js | 12 +----- buying/utils.py | 13 +++--- controllers/accounts_controller.py | 6 +-- controllers/queries.py | 8 ---- manufacturing/doctype/bom/bom.py | 4 +- patches/january_2013/purchase_price_list.py | 12 ------ .../p03_buying_selling_for_price_list.py | 6 +-- patches/patch_list.py | 2 +- ...modify_item_price_include_in_price_list.py | 18 ++++++++ public/js/transaction.js | 5 +-- selling/doctype/sales_bom/sales_bom.py | 6 +-- .../doctype/sales_bom_item/sales_bom_item.txt | 11 ++--- selling/doctype/sales_common/sales_common.js | 10 ----- selling/utils.py | 13 +++--- .../currency_exchange/currency_exchange.js | 2 - {stock => setup}/doctype/item_price/README.md | 0 .../doctype/item_price/__init__.py | 0 .../doctype/item_price/item_price.py | 4 +- .../doctype/item_price/item_price.txt | 43 ++++--------------- setup/doctype/price_list/price_list.js | 38 ---------------- setup/doctype/price_list/price_list.py | 24 +++++++---- setup/doctype/price_list/price_list.txt | 27 ++---------- setup/doctype/price_list/test_price_list.py | 18 ++++++++ stock/doctype/item/item.js | 20 --------- stock/doctype/item/item.py | 23 ++-------- stock/doctype/item/item.txt | 21 +-------- stock/doctype/item/test_item.py | 23 +--------- stock/report/item_prices/item_prices.py | 25 +++++------ .../item_wise_price_list.txt | 4 +- website/helpers/product.py | 5 ++- 32 files changed, 129 insertions(+), 289 deletions(-) delete mode 100644 patches/january_2013/purchase_price_list.py create mode 100644 patches/september_2013/p03_modify_item_price_include_in_price_list.py rename {stock => setup}/doctype/item_price/README.md (100%) rename {stock => setup}/doctype/item_price/__init__.py (100%) rename {stock => setup}/doctype/item_price/item_price.py (69%) rename {stock => setup}/doctype/item_price/item_price.txt (53%) diff --git a/accounts/doctype/sales_invoice/pos.js b/accounts/doctype/sales_invoice/pos.js index f04328fd09..8837aed14b 100644 --- a/accounts/doctype/sales_invoice/pos.js +++ b/accounts/doctype/sales_invoice/pos.js @@ -193,7 +193,7 @@ erpnext.POS = Class.extend({
    ', { item_code: obj.name, - item_price: format_currency(obj.ref_rate, obj.ref_currency), + item_price: format_currency(obj.ref_rate, obj.currency), item_name: obj.name===obj.item_name ? "" : obj.item_name, item_image: image })).appendTo($wrap); diff --git a/accounts/doctype/sales_invoice/pos.py b/accounts/doctype/sales_invoice/pos.py index 1b867cb8db..08340f76c5 100644 --- a/accounts/doctype/sales_invoice/pos.py +++ b/accounts/doctype/sales_invoice/pos.py @@ -15,11 +15,14 @@ def get_items(price_list, item=None, item_group=None): if item: condition = "and i.name='%s'" % item - return webnotes.conn.sql("""select - i.name, i.item_name, i.image, ip.ref_rate, ip.ref_currency - from `tabItem` i LEFT JOIN `tabItem Price` ip - ON ip.parent=i.name - and ip.price_list=%s + return webnotes.conn.sql("""select i.name, i.item_name, i.image, + pl_items.ref_rate, pl_items.currency + from `tabItem` i LEFT JOIN + (select ip.item_code, ip.ref_rate, pl.currency from + `tabItem Price` ip, `tabPrice List` pl + where ip.parent=%s and ip.parent = pl.name) pl_items + ON + pl_items.item_code=i.name where i.is_sales_item='Yes'%s""" % ('%s', condition), (price_list), as_dict=1) diff --git a/buying/doctype/purchase_common/purchase_common.js b/buying/doctype/purchase_common/purchase_common.js index 5785b1a9d5..2dfe65515a 100644 --- a/buying/doctype/purchase_common/purchase_common.js +++ b/buying/doctype/purchase_common/purchase_common.js @@ -24,16 +24,6 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({ filters: { 'buying_or_selling': "Buying" } } }); - - this.frm.set_query("price_list_currency", function() { - return{ - query: "controllers.queries.get_price_list_currency", - filters: { - 'price_list': me.frm.doc.buying_price_list, - 'buying_or_selling': "Buying" - } - } - }); } $.each([["supplier", "supplier"], @@ -152,7 +142,7 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({ }, buying_price_list: function() { - this.get_price_list_currency("buying"); + this.get_price_list_currency("Buying"); }, import_ref_rate: function(doc, cdt, cdn) { diff --git a/buying/utils.py b/buying/utils.py index 33326d9e59..f4fb2f3ff8 100644 --- a/buying/utils.py +++ b/buying/utils.py @@ -89,12 +89,15 @@ def _get_price_list_rate(args, item_bean, meta): # try fetching from price list if args.buying_price_list and args.price_list_currency: - price_list_rate = item_bean.doclist.get({ - "parentfield": "ref_rate_details", - "price_list": args.buying_price_list, - "ref_currency": args.price_list_currency, - "buying_or_selling": "Buying"}) + price_list_rate = webnotes.conn.sql("""select ip.ref_rate from `tabItem Price` ip, + `tabPrice List` pl where ip.parent = pl.name and ip.parent=%s and + ip.item_code=%s and pl.buying_or_selling='Buying'""", + (args.buying_price_list, args.item_code), as_dict=1) + if price_list_rate: + from utilities.transaction_base import validate_currency + validate_currency(args, item_bean.doc, meta) + out.import_ref_rate = \ flt(price_list_rate[0].ref_rate * args.plc_conversion_rate / args.conversion_rate) diff --git a/controllers/accounts_controller.py b/controllers/accounts_controller.py index eb71f21ce7..1247e668c0 100644 --- a/controllers/accounts_controller.py +++ b/controllers/accounts_controller.py @@ -59,13 +59,13 @@ class AccountsController(TransactionBase): # TODO - change this, since price list now has only one currency allowed if self.meta.get_field(fieldname) and self.doc.fields.get(fieldname): - if not self.doc.price_list_currency: - self.doc.fields.update(get_price_list_currency(self.doc.fields.get(fieldname))) + self.doc.fields.update(get_price_list_currency(self.doc.fields.get(fieldname))) if self.doc.price_list_currency: if self.doc.price_list_currency == company_currency: self.doc.plc_conversion_rate = 1.0 - elif not self.doc.plc_conversion_rate: + elif not self.doc.plc_conversion_rate or \ + (flt(self.doc.plc_conversion_rate)==1 and company_currency!= self.doc.price_list_currency): exchange = self.doc.price_list_currency + "-" + company_currency self.doc.plc_conversion_rate = flt(webnotes.conn.get_value("Currency Exchange", exchange, "exchange_rate")) diff --git a/controllers/queries.py b/controllers/queries.py index 02c992b729..637d5e18cd 100644 --- a/controllers/queries.py +++ b/controllers/queries.py @@ -157,14 +157,6 @@ def get_project_name(doctype, txt, searchfield, start, page_len, filters): order by `tabProject`.name asc limit %(start)s, %(page_len)s """ % {'cond': cond,'txt': "%%%s%%" % txt, 'mcond':get_match_cond(doctype, searchfield),'start': start, 'page_len': page_len}) - -def get_price_list_currency(doctype, txt, searchfield, start, page_len, filters): - return webnotes.conn.sql("""select ref_currency from `tabItem Price` - where price_list = %s and buying_or_selling = %s - and `%s` like %s order by ref_currency asc limit %s, %s""" % - ("%s", "%s", searchfield, "%s", "%s", "%s"), - (filters["price_list"], filters['buying_or_selling'], "%%%s%%" % txt, - start, page_len)) def get_delivery_notes_to_be_billed(doctype, txt, searchfield, start, page_len, filters): return webnotes.conn.sql("""select `tabDelivery Note`.name, `tabDelivery Note`.customer_name diff --git a/manufacturing/doctype/bom/bom.py b/manufacturing/doctype/bom/bom.py index cb4b8c5236..9a566123c7 100644 --- a/manufacturing/doctype/bom/bom.py +++ b/manufacturing/doctype/bom/bom.py @@ -121,8 +121,8 @@ class DocType: elif self.doc.rm_cost_as_per == "Price List": if not self.doc.buying_price_list: webnotes.throw(_("Please select Price List")) - rate = webnotes.conn.get_value("Item Price", {"price_list": self.doc.buying_price_list, - "parent": arg["item_code"]}, "ref_rate") or 0 + rate = webnotes.conn.get_value("Item Price", {"parent": self.doc.buying_price_list, + "item_code": arg["item_code"]}, "ref_rate") or 0 elif self.doc.rm_cost_as_per == 'Standard Rate': rate = arg['standard_rate'] diff --git a/patches/january_2013/purchase_price_list.py b/patches/january_2013/purchase_price_list.py deleted file mode 100644 index 89509cf087..0000000000 --- a/patches/january_2013/purchase_price_list.py +++ /dev/null @@ -1,12 +0,0 @@ -# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. -# License: GNU General Public License v3. See license.txt - -import webnotes - -def execute(): - webnotes.reload_doc("stock", "doctype", "item_price") - - # check for selling - webnotes.conn.sql("""update `tabItem Price` set buying_or_selling = "Selling" - where ifnull(buying_or_selling, '')=''""") - \ No newline at end of file diff --git a/patches/june_2013/p03_buying_selling_for_price_list.py b/patches/june_2013/p03_buying_selling_for_price_list.py index c71646a8f5..1998d7ea62 100644 --- a/patches/june_2013/p03_buying_selling_for_price_list.py +++ b/patches/june_2013/p03_buying_selling_for_price_list.py @@ -6,7 +6,7 @@ from webnotes.utils import cint def execute(): webnotes.reload_doc("setup", "doctype", "price_list") - webnotes.reload_doc("stock", "doctype", "item_price") + webnotes.reload_doc("setup", "doctype", "item_price") for price_list in webnotes.conn.sql_list("""select name from `tabPrice List`"""): buying, selling = False, False @@ -15,7 +15,5 @@ def execute(): buying = buying or cint(b) selling = selling or cint(s) - buying_or_selling = "Selling" if selling else "Buying" + buying_or_selling = "Buying" if buying else "Selling" webnotes.conn.set_value("Price List", price_list, "buying_or_selling", buying_or_selling) - webnotes.conn.sql("""update `tabItem Price` set buying_or_selling=%s - where price_list_name=%s""", (buying_or_selling, price_list)) diff --git a/patches/patch_list.py b/patches/patch_list.py index 3c13e0eb47..7d9f839c2e 100644 --- a/patches/patch_list.py +++ b/patches/patch_list.py @@ -121,7 +121,6 @@ patch_list = [ "patches.january_2013.update_country_info", "patches.january_2013.remove_tds_entry_from_gl_mapper", "patches.january_2013.update_number_format", - "patches.january_2013.purchase_price_list", "execute:webnotes.reload_doc('core', 'doctype', 'print_format') #2013-01", "execute:webnotes.reload_doc('accounts','Print Format','Payment Receipt Voucher')", "patches.january_2013.update_fraction_for_usd", @@ -263,4 +262,5 @@ patch_list = [ "patches.september_2013.p01_update_communication", "execute:webnotes.reload_doc('setup', 'doctype', 'features_setup') # 2013-09-05", "patches.september_2013.p02_fix_serial_no_status", + "patches.september_2013.p03_modify_item_price_include_in_price_list", ] \ No newline at end of file diff --git a/patches/september_2013/p03_modify_item_price_include_in_price_list.py b/patches/september_2013/p03_modify_item_price_include_in_price_list.py new file mode 100644 index 0000000000..f29f8f5bf0 --- /dev/null +++ b/patches/september_2013/p03_modify_item_price_include_in_price_list.py @@ -0,0 +1,18 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. +# License: GNU General Public License v3. See license.txt + +from __future__ import unicode_literals +import webnotes + +def execute(): + webnotes.reload_doc("setup", "doctype", "price_list") + webnotes.reload_doc("setup", "doctype", "item_price") + webnotes.conn.sql("""update `tabItem Price` set parenttype='Price List', + parentfield='item_prices', item_code=parent""") + + # re-arranging idx of items + webnotes.conn.sql("""update `tabItem Price` set parent=price_list, idx=0""") + for pl in webnotes.conn.sql("""select name from `tabPrice List`"""): + webnotes.conn.sql("""set @name=0""") + webnotes.conn.sql("""update `tabItem Price` set idx = @name := IF(ISNULL( @name ), 0, @name + 1) + where idx=0 and parent=%s""", pl[0]) \ No newline at end of file diff --git a/public/js/transaction.js b/public/js/transaction.js index 0ff957a820..3f0f9e5a0d 100644 --- a/public/js/transaction.js +++ b/public/js/transaction.js @@ -149,6 +149,7 @@ erpnext.TransactionController = erpnext.stock.StockController.extend({ }, price_list_currency: function() { + var me=this; this.set_dynamic_labels(); var company_currency = this.get_company_currency(); @@ -156,7 +157,7 @@ erpnext.TransactionController = erpnext.stock.StockController.extend({ this.get_exchange_rate(this.frm.doc.price_list_currency, company_currency, function(exchange_rate) { if(exchange_rate) { - me.frm.set_value("price_list_currency", exchange_rate); + me.frm.set_value("plc_conversion_rate", exchange_rate); me.plc_conversion_rate(); } }); @@ -348,8 +349,6 @@ erpnext.TransactionController = erpnext.stock.StockController.extend({ } }); - console.log(distinct_items); - var rows = $.map(distinct_items, function(item) { var item_tax_record = item_tax[item.item_code || item.item_name]; if(!item_tax_record) { return null; } diff --git a/selling/doctype/sales_bom/sales_bom.py b/selling/doctype/sales_bom/sales_bom.py index 15d8fd1e5b..2e56f2a10f 100644 --- a/selling/doctype/sales_bom/sales_bom.py +++ b/selling/doctype/sales_bom/sales_bom.py @@ -31,13 +31,9 @@ class DocType: def get_item_details(self, name): det = webnotes.conn.sql("""select description, stock_uom from `tabItem` where name = %s""", name) - rate = webnotes.conn.sql("""select ref_rate from `tabItem Price` - where price_list = %s and parent = %s - and ref_currency = %s""", (self.doc.price_list, name, self.doc.currency)) return { 'description' : det and det[0][0] or '', - 'uom': det and det[0][1] or '', - 'rate': rate and flt(rate[0][0]) or 0.00 + 'uom': det and det[0][1] or '' } def check_duplicate(self, finder=0): diff --git a/selling/doctype/sales_bom_item/sales_bom_item.txt b/selling/doctype/sales_bom_item/sales_bom_item.txt index 1bd456b9e7..9e880bc8cd 100644 --- a/selling/doctype/sales_bom_item/sales_bom_item.txt +++ b/selling/doctype/sales_bom_item/sales_bom_item.txt @@ -2,7 +2,7 @@ { "creation": "2013-05-23 16:55:51", "docstatus": 0, - "modified": "2013-07-10 14:54:19", + "modified": "2013-09-09 15:47:56", "modified_by": "Administrator", "owner": "Administrator" }, @@ -53,17 +53,18 @@ "label": "Description", "oldfieldname": "description", "oldfieldtype": "Text", - "print_width": "300px", - "width": "300px" + "print_width": "300px" }, { "doctype": "DocField", "fieldname": "rate", "fieldtype": "Float", - "in_list_view": 1, + "hidden": 1, + "in_list_view": 0, "label": "Rate", "oldfieldname": "rate", - "oldfieldtype": "Currency" + "oldfieldtype": "Currency", + "print_hide": 1 }, { "doctype": "DocField", diff --git a/selling/doctype/sales_common/sales_common.js b/selling/doctype/sales_common/sales_common.js index 0308dfcd25..dc58377e4b 100644 --- a/selling/doctype/sales_common/sales_common.js +++ b/selling/doctype/sales_common/sales_common.js @@ -49,16 +49,6 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({ this.frm.set_query("selling_price_list", function() { return { filters: { buying_or_selling: "Selling" } }; }); - - this.frm.set_query("price_list_currency", function() { - return { - query: "controllers.queries.get_price_list_currency", - filters: { - price_list: me.frm.doc.selling_price_list, - buying_or_selling: "Selling" - } - }; - }); } if(!this.fname) { diff --git a/selling/utils.py b/selling/utils.py index ca995125d1..224944dd88 100644 --- a/selling/utils.py +++ b/selling/utils.py @@ -141,20 +141,19 @@ def _get_basic_details(args, item_bean, warehouse_fieldname): return out def _get_price_list_rate(args, item_bean, meta): - base_ref_rate = item_bean.doclist.get({ - "parentfield": "ref_rate_details", - "price_list": args.selling_price_list, - "ref_currency": args.price_list_currency, - "buying_or_selling": "Selling"}) + ref_rate = webnotes.conn.sql("""select ip.ref_rate from `tabItem Price` ip, + `tabPrice List` pl where ip.parent = pl.name and ip.parent=%s and + ip.item_code=%s and pl.buying_or_selling='Selling'""", + (args.selling_price_list, args.item_code), as_dict=1) - if not base_ref_rate: + if not ref_rate: return {} # found price list rate - now we can validate from utilities.transaction_base import validate_currency validate_currency(args, item_bean.doc, meta) - return {"ref_rate": flt(base_ref_rate[0].ref_rate) * flt(args.plc_conversion_rate) / flt(args.conversion_rate)} + return {"ref_rate": flt(ref_rate[0].ref_rate) * flt(args.plc_conversion_rate) / flt(args.conversion_rate)} def _get_item_discount(item_group, customer): parent_item_groups = [x[0] for x in webnotes.conn.sql("""SELECT parent.name diff --git a/setup/doctype/currency_exchange/currency_exchange.js b/setup/doctype/currency_exchange/currency_exchange.js index 5fd43050df..bf9c516367 100644 --- a/setup/doctype/currency_exchange/currency_exchange.js +++ b/setup/doctype/currency_exchange/currency_exchange.js @@ -23,8 +23,6 @@ $.extend(cur_frm.cscript, { set_exchange_rate_label: function() { if(cur_frm.doc.from_currency && cur_frm.doc.to_currency) { var default_label = wn._(wn.meta.docfield_map[cur_frm.doctype]["exchange_rate"].label); - console.log(default_label + - repl(" (1 %(from_currency)s = [?] %(to_currency)s)", cur_frm.doc)); cur_frm.fields_dict.exchange_rate.set_label(default_label + repl(" (1 %(from_currency)s = [?] %(to_currency)s)", cur_frm.doc)); } diff --git a/stock/doctype/item_price/README.md b/setup/doctype/item_price/README.md similarity index 100% rename from stock/doctype/item_price/README.md rename to setup/doctype/item_price/README.md diff --git a/stock/doctype/item_price/__init__.py b/setup/doctype/item_price/__init__.py similarity index 100% rename from stock/doctype/item_price/__init__.py rename to setup/doctype/item_price/__init__.py diff --git a/stock/doctype/item_price/item_price.py b/setup/doctype/item_price/item_price.py similarity index 69% rename from stock/doctype/item_price/item_price.py rename to setup/doctype/item_price/item_price.py index 26d0f76968..3256c80d42 100644 --- a/stock/doctype/item_price/item_price.py +++ b/setup/doctype/item_price/item_price.py @@ -1,5 +1,7 @@ # Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. -# License: GNU General Public License v3. See license.txt +# MIT License. See license.txt + +# For license information, please see license.txt from __future__ import unicode_literals import webnotes diff --git a/stock/doctype/item_price/item_price.txt b/setup/doctype/item_price/item_price.txt similarity index 53% rename from stock/doctype/item_price/item_price.txt rename to setup/doctype/item_price/item_price.txt index 3a73a00602..2964cd96f4 100644 --- a/stock/doctype/item_price/item_price.txt +++ b/setup/doctype/item_price/item_price.txt @@ -2,7 +2,7 @@ { "creation": "2013-05-02 16:29:48", "docstatus": 0, - "modified": "2013-08-09 14:46:58", + "modified": "2013-09-11 12:38:24", "modified_by": "Administrator", "owner": "Administrator" }, @@ -11,18 +11,20 @@ "doctype": "DocType", "in_create": 0, "istable": 1, - "module": "Stock", + "module": "Setup", "name": "__common__", "read_only": 0 }, { "doctype": "DocField", + "in_filter": 1, "in_list_view": 1, "name": "__common__", "parent": "Item Price", "parentfield": "fields", "parenttype": "DocType", - "permlevel": 0 + "permlevel": 0, + "reqd": 1 }, { "doctype": "DocType", @@ -30,49 +32,22 @@ }, { "doctype": "DocField", - "fieldname": "price_list", + "fieldname": "item_code", "fieldtype": "Link", - "in_filter": 1, - "label": "Price List Name", + "label": "Item Code", "oldfieldname": "price_list_name", "oldfieldtype": "Select", - "options": "Price List", - "reqd": 1, + "options": "Item", "search_index": 1 }, { "doctype": "DocField", "fieldname": "ref_rate", "fieldtype": "Currency", - "in_filter": 1, "label": "Ref Rate", "oldfieldname": "ref_rate", "oldfieldtype": "Currency", - "options": "ref_currency", - "reqd": 1, + "options": "currency", "search_index": 0 - }, - { - "doctype": "DocField", - "fieldname": "ref_currency", - "fieldtype": "Link", - "in_filter": 1, - "label": "Currency", - "oldfieldname": "ref_currency", - "oldfieldtype": "Select", - "options": "Currency", - "read_only": 1, - "reqd": 0, - "search_index": 1 - }, - { - "default": "Selling", - "doctype": "DocField", - "fieldname": "buying_or_selling", - "fieldtype": "Select", - "label": "Valid for Buying or Selling?", - "options": "Buying\nSelling", - "read_only": 1, - "reqd": 1 } ] \ No newline at end of file diff --git a/setup/doctype/price_list/price_list.js b/setup/doctype/price_list/price_list.js index 5de8da5585..f3adc72757 100644 --- a/setup/doctype/price_list/price_list.js +++ b/setup/doctype/price_list/price_list.js @@ -3,44 +3,6 @@ $.extend(cur_frm.cscript, { onload: function() { - cur_frm.cscript.show_item_prices(); erpnext.add_for_territory(); }, - - refresh: function(doc) { - cur_frm.set_intro(""); - if(doc.__islocal) { - cur_frm.toggle_display("item_prices_section", false); - cur_frm.set_intro("Save this list to begin."); - return; - } else { - cur_frm.cscript.show_item_prices(); - } - }, - - show_item_prices: function() { - var item_price = wn.model.get("Item Price", {price_list: cur_frm.doc.name}); - - var show = item_price && item_price.length; - - cur_frm.toggle_display("item_prices_section", show); - $(cur_frm.fields_dict.item_prices.wrapper).empty(); - if (!show) return; - - var out = '\ - \ - \ - \ - \ - ' - + $.map(item_price.sort(function(a, b) { return a.parent.localeCompare(b.parent); }), function(d) { - return '' - + '' - + '' - + '' - }).join("\n") - + '\ -
    ' + wn._("Item Code") + '' + wn._("Price") + '
    ' + d.parent + '' + format_currency(d.ref_rate, d.ref_currency) + '
    '; - $(out).appendTo($(cur_frm.fields_dict.item_prices.wrapper)); - } }); \ No newline at end of file diff --git a/setup/doctype/price_list/price_list.py b/setup/doctype/price_list/price_list.py index 112ce95e59..2fcaf218dc 100644 --- a/setup/doctype/price_list/price_list.py +++ b/setup/doctype/price_list/price_list.py @@ -8,11 +8,9 @@ from webnotes.utils import comma_or, cint from webnotes.model.controller import DocListController import webnotes.defaults +class PriceListDuplicateItem(Exception): pass + class DocType(DocListController): - def onload(self): - self.doclist.extend(webnotes.conn.sql("""select * from `tabItem Price` - where price_list=%s""", self.doc.name, as_dict=True, update={"doctype": "Item Price"})) - def validate(self): if self.doc.buying_or_selling not in ["Buying", "Selling"]: msgprint(_(self.meta.get_label("buying_or_selling")) + " " + _("must be one of") + " " + @@ -29,17 +27,24 @@ class DocType(DocListController): else: # at least one territory self.validate_table_has_rows("valid_for_territories") + + # check for duplicate items + self.check_duplicate_items() def on_update(self): self.set_default_if_missing() cart_settings = webnotes.get_obj("Shopping Cart Settings") if cint(cart_settings.doc.enabled): cart_settings.validate_price_lists() + + def check_duplicate_items(self): + item_codes = [] + for d in self.doclist.get({"parentfield": "item_prices"}): + if d.item_code not in item_codes: + item_codes.append(d.item_code) + else: + msgprint(_("Duplicate Item ") + ": " + d.item_code, raise_exception=PriceListDuplicateItem) - def on_trash(self): - webnotes.conn.sql("""delete from `tabItem Price` where price_list = %s""", - self.doc.name) - def set_default_if_missing(self): if self.doc.buying_or_selling=="Selling": if not webnotes.conn.get_value("Selling Settings", None, "selling_price_list"): @@ -47,4 +52,5 @@ class DocType(DocListController): elif self.doc.buying_or_selling=="Buying": if not webnotes.conn.get_value("Buying Settings", None, "buying_price_list"): - webnotes.set_value("Buying Settings", "Buying Settings", "buying_price_list", self.doc.name) \ No newline at end of file + webnotes.set_value("Buying Settings", "Buying Settings", "buying_price_list", self.doc.name) + diff --git a/setup/doctype/price_list/price_list.txt b/setup/doctype/price_list/price_list.txt index febf47180f..46905a6591 100644 --- a/setup/doctype/price_list/price_list.txt +++ b/setup/doctype/price_list/price_list.txt @@ -2,7 +2,7 @@ { "creation": "2013-01-25 11:35:09", "docstatus": 0, - "modified": "2013-07-26 11:19:06", + "modified": "2013-09-06 15:03:38", "modified_by": "Administrator", "owner": "Administrator" }, @@ -94,28 +94,9 @@ { "doctype": "DocField", "fieldname": "item_prices", - "fieldtype": "HTML", - "label": "Item Prices" - }, - { - "doctype": "DocField", - "fieldname": "column_break_10", - "fieldtype": "Column Break" - }, - { - "depends_on": "eval:!doc.__islocal", - "doctype": "DocField", - "fieldname": "section_break_1", - "fieldtype": "Section Break", - "label": "How to upload" - }, - { - "depends_on": "eval:!doc.__islocal", - "doctype": "DocField", - "fieldname": "how_to_upload", - "fieldtype": "HTML", - "label": "How to upload", - "options": "
    Use the Data Import Tool to upload, update Item Prices in bulk:\n
      \n
    1. Go to Data Import Tool.\n
    2. Select \"Item\"\n
    3. Check on \"With Data\"\n
    4. Download \"Item Price\" from Child Tables.\n
    5. Update the prices required and add new rows if required.\n
    6. Check on \"Overwrite\"\n
    7. Upload the modified sheet.\n
    \n" + "fieldtype": "Table", + "label": "Item Prices", + "options": "Item Price" }, { "amend": 0, diff --git a/setup/doctype/price_list/test_price_list.py b/setup/doctype/price_list/test_price_list.py index bfa64ec6d6..2310f51478 100644 --- a/setup/doctype/price_list/test_price_list.py +++ b/setup/doctype/price_list/test_price_list.py @@ -1,6 +1,18 @@ # Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. # License: GNU General Public License v3. See license.txt +from __future__ import unicode_literals +import unittest +import webnotes +from setup.doctype.price_list.price_list import PriceListDuplicateItem + +class TestItem(unittest.TestCase): + def test_duplicate_item(self): + price_list = webnotes.bean(copy=test_records[0]) + item_price = price_list.doclist.get({"doctype": "Item Price"})[0] + price_list.doclist.append(webnotes.doc(item_price.fields.copy())) + self.assertRaises(PriceListDuplicateItem, price_list.insert) + test_records = [ [ { @@ -13,6 +25,12 @@ test_records = [ "doctype": "For Territory", "parentfield": "valid_for_territories", "territory": "All Territories" + }, + { + "doctype": "Item Price", + "parentfield": "item_prices", + "item_code": "_Test Item", + "ref_rate": 100 } ], [ diff --git a/stock/doctype/item/item.js b/stock/doctype/item/item.js index abf1e9e658..a83032e8f2 100644 --- a/stock/doctype/item/item.js +++ b/stock/doctype/item/item.js @@ -1,26 +1,6 @@ // Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. // License: GNU General Public License v3. See license.txt -wn.provide("erpnext.stock"); - -erpnext.stock.Item = wn.ui.form.Controller.extend({ - onload: function() { - this.frm.add_fetch("price_list", "currency", "ref_currency"); - this.frm.add_fetch("price_list", "buying_or_selling", "buying_or_selling"); - }, - - ref_rate_details_add: function(doc, cdt, cdn) { - var row = wn.model.get_doc(cdt, cdn); - if(row.price_list && !row.ref_currency) { - // execute fetch - var df = wn.meta.get_docfield(row.doctype, "price_list", row.parent); - this.frm.script_manager.validate_link_and_fetch(df, row.name, row.price_list); - } - } -}); - -cur_frm.script_manager.make(erpnext.stock.Item); - cur_frm.cscript.refresh = function(doc) { // make sensitive fields(has_serial_no, is_stock_item, valuation_method) // read only if any stock ledger entry exists diff --git a/stock/doctype/item/item.py b/stock/doctype/item/item.py index e6c277ee08..7219ade7f1 100644 --- a/stock/doctype/item/item.py +++ b/stock/doctype/item/item.py @@ -11,7 +11,6 @@ from webnotes import msgprint, _ from webnotes.model.controller import DocListController -class PriceListCurrencyMismatch(Exception): pass class WarehouseNotSet(Exception): pass class DocType(DocListController): @@ -32,9 +31,8 @@ class DocType(DocListController): self.check_stock_uom_with_bin() self.validate_conversion_factor() self.add_default_uom_in_conversion_factor_table() - self.valiadte_item_type() + self.validate_item_type() self.check_for_active_boms() - self.validate_price_lists() self.fill_customer_code() self.check_item_tax() self.validate_barcode() @@ -87,7 +85,7 @@ class DocType(DocListController): As UOM: %s is not Stock UOM of Item: %s""" % (d.uom, d.uom, self.doc.name)), raise_exception=1) - def valiadte_item_type(self): + def validate_item_type(self): if cstr(self.doc.is_manufactured_item) == "No": self.doc.is_pro_applicable = "No" @@ -125,22 +123,7 @@ class DocType(DocListController): 'is_pro_applicable' :'Allow Production Order'} for d in fl: if cstr(self.doc.fields.get(d)) != 'Yes': - _check_for_active_boms(fl[d]) - - def validate_price_lists(self): - price_lists=[] - for d in getlist(self.doclist,'ref_rate_details'): - if d.price_list in price_lists: - msgprint(_("Cannot have two prices for same Price List") + ": " + d.price_list, - raise_exception= webnotes.DuplicateEntryError) - else: - price_list_currency = webnotes.conn.get_value("Price List", d.price_list, "currency") - if price_list_currency and d.ref_currency != price_list_currency: - msgprint(_("Currency does not match Price List Currency for Price List") \ - + ": " + d.price_list, raise_exception=PriceListCurrencyMismatch) - - price_lists.append(d.price_list) - + _check_for_active_boms(fl[d]) def fill_customer_code(self): """ Append all the customer codes and insert into "customer_code" field of item table """ diff --git a/stock/doctype/item/item.txt b/stock/doctype/item/item.txt index eb05503b32..c70b9911db 100644 --- a/stock/doctype/item/item.txt +++ b/stock/doctype/item/item.txt @@ -2,7 +2,7 @@ { "creation": "2013-05-03 10:45:46", "docstatus": 0, - "modified": "2013-08-30 16:21:38", + "modified": "2013-09-11 11:50:10", "modified_by": "Administrator", "owner": "Administrator" }, @@ -625,25 +625,6 @@ "options": "Item Tax", "read_only": 0 }, - { - "doctype": "DocField", - "fieldname": "price_list_section", - "fieldtype": "Section Break", - "label": "Price Lists and Rates", - "options": "icon-money", - "read_only": 0 - }, - { - "description": "Create a price list from Price List master and enter standard ref rates against each of them. On selection of a price list in Quotation, Sales Order or Delivery Note, corresponding ref rate will be fetched for this item.", - "doctype": "DocField", - "fieldname": "ref_rate_details", - "fieldtype": "Table", - "label": "Item Prices", - "oldfieldname": "ref_rate_details", - "oldfieldtype": "Table", - "options": "Item Price", - "read_only": 0 - }, { "doctype": "DocField", "fieldname": "inspection_criteria", diff --git a/stock/doctype/item/test_item.py b/stock/doctype/item/test_item.py index 7be6ea56ed..12bb4e0578 100644 --- a/stock/doctype/item/test_item.py +++ b/stock/doctype/item/test_item.py @@ -9,20 +9,6 @@ test_ignore = ["BOM"] test_dependencies = ["Warehouse"] class TestItem(unittest.TestCase): - def test_duplicate_price_list(self): - item = webnotes.bean(copy=test_records[0]) - item.doc.item_code = "_Test Item 10" - item_price = item.doclist.get({"doctype": "Item Price"})[0] - item.doclist.append(webnotes.doc(item_price.fields.copy())) - self.assertRaises(webnotes.DuplicateEntryError, item.insert) - - def test_price_list_mismatch(self): - from stock.doctype.item.item import PriceListCurrencyMismatch - item = webnotes.bean(copy=test_records[0]) - item.doc.item_code = "_Test Item 11" - item_price = item.doclist.get({"doctype": "Item Price"})[0].ref_currency="USD" - self.assertRaises(PriceListCurrencyMismatch, item.insert) - def test_default_warehouse(self): from stock.doctype.item.item import WarehouseNotSet item = webnotes.bean(copy=test_records[0]) @@ -57,14 +43,7 @@ test_records = [ "warehouse_reorder_level": 20, "warehouse_reorder_qty": 20, "material_request_type": "Purchase" - }, { - "doctype": "Item Price", - "parentfield": "ref_rate_details", - "price_list": "_Test Price List", - "ref_rate": 100, - "ref_currency": "INR", - "buying_or_selling": "Selling" - } + }, ], [{ "doctype": "Item", diff --git a/stock/report/item_prices/item_prices.py b/stock/report/item_prices/item_prices.py index 0a6b29a723..70c0677986 100644 --- a/stock/report/item_prices/item_prices.py +++ b/stock/report/item_prices/item_prices.py @@ -23,8 +23,8 @@ def execute(filters=None): item_map[item]["description"], item_map[item]["stock_uom"], flt(last_purchase_rate.get(item, 0), precision), flt(val_rate_map.get(item, 0), precision), - pl.get(item, {}).get("selling"), - pl.get(item, {}).get("buying"), + pl.get(item, {}).get("Selling"), + pl.get(item, {}).get("Buying"), flt(bom_rate.get(item, 0), precision), flt(item_map[item]["standard_rate"], precision) ]) @@ -56,24 +56,21 @@ def get_price_list(): """Get selling & buying price list of every item""" rate = {} - - price_list = webnotes.conn.sql("""select parent, selling, buying, - concat(price_list, " - ", ref_currency, " ", ref_rate) as price - from `tabItem Price` where docstatus<2""", as_dict=1) + + price_list = webnotes.conn.sql("""select ip.item_code, pl.buying_or_selling, + concat(pl.name, " - ", pl.currency, " ", ip.ref_rate) as price + from `tabItem Price` ip, `tabPrice List` pl where + ip.parent = pl.name and pl.docstatus<2""", as_dict=1) for j in price_list: if j.price: - if j.selling: - rate.setdefault(j.parent, {}).setdefault("selling", []).append(j.price) - if j.buying: - rate.setdefault(j.parent, {}).setdefault("buying", []).append(j.price) - + rate.setdefault(j.item_code, {}).setdefault(j.buying_or_selling, []).append(j.price) item_rate_map = {} for item in rate: - item_rate_map.setdefault(item, {}).setdefault("selling", - ", ".join(rate[item].get("selling", []))) - item_rate_map[item]["buying"] = ", ".join(rate[item].get("buying", [])) + for buying_or_selling in rate[item]: + item_rate_map.setdefault(item, {}).setdefault(buying_or_selling, + ", ".join(rate[item].get(buying_or_selling, []))) return item_rate_map diff --git a/stock/report/item_wise_price_list/item_wise_price_list.txt b/stock/report/item_wise_price_list/item_wise_price_list.txt index 2d5996a92e..b3d5717a41 100644 --- a/stock/report/item_wise_price_list/item_wise_price_list.txt +++ b/stock/report/item_wise_price_list/item_wise_price_list.txt @@ -2,7 +2,7 @@ { "creation": "2013-02-22 18:01:55", "docstatus": 0, - "modified": "2013-05-07 11:52:00", + "modified": "2013-09-10 15:50:26", "modified_by": "Administrator", "owner": "Administrator" }, @@ -10,7 +10,7 @@ "doctype": "Report", "is_standard": "Yes", "name": "__common__", - "query": "select\n item.name as \"ID:Link/Item:120\", \n item.item_name as \"Item Name::120\", \n item_price.price_list as \"Price List::80\",\n item_price.ref_currency as \"Currency::40\", \n item_price.ref_rate as \"Rate:Float:80\",\n item.description as \"Description::160\",\n item.item_group as \"Item Group:Link/Item Group:100\",\n item.brand as \"Brand::100\"\nfrom `tabItem` item, `tabItem Price` item_price\nwhere\n item_price.parent = item.name", + "query": "select\n item.name as \"ID:Link/Item:120\", \n item.item_name as \"Item Name::120\", \n item_price.parent as \"Price List::80\",\n price_list.currency as \"Currency::40\", \n item_price.ref_rate as \"Rate:Float:80\",\n item.description as \"Description::160\",\n item.item_group as \"Item Group:Link/Item Group:100\",\n item.brand as \"Brand::100\"\nfrom `tabItem` item, `tabItem Price` item_price, `tabPrice List` price_list\nwhere\n item_price.item_code = item.name and\n item_price.parent = price_list.name", "ref_doctype": "Item", "report_name": "Item-Wise Price List", "report_type": "Query Report" diff --git a/website/helpers/product.py b/website/helpers/product.py index 8d817d07cf..d8da05aa0c 100644 --- a/website/helpers/product.py +++ b/website/helpers/product.py @@ -27,8 +27,9 @@ def get_product_info(item_code): else: in_stock = -1 - price = price_list and webnotes.conn.sql("""select ref_rate, ref_currency from - `tabItem Price` where parent=%s and price_list=%s""", + price = price_list and webnotes.conn.sql("""select ip.ref_rate, pl.ref_currency from + `tabItem Price` ip, `tabPrice List` pl where ip.parent = pl.name and + ip.item_code=%s and ip.parent=%s""", (item_code, price_list), as_dict=1) or [] price = price and price[0] or None From 0748cb7d181f19dbc3336eeb1361779c8249daaa Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Wed, 11 Sep 2013 15:31:58 +0530 Subject: [PATCH 14/37] [website] [minor] moving to framework --- portal/templates/base.html | 20 -- portal/templates/includes/cart.js | 47 ++-- portal/templates/includes/footer.html | 6 +- portal/templates/includes/transactions.html | 1 - portal/templates/pages/account.html | 27 --- portal/templates/pages/account.py | 6 - portal/templates/pages/cart.html | 4 +- portal/templates/pages/profile.html | 1 - portal/templates/sale.html | 1 - public/js/website_utils.js | 217 ++---------------- startup/webutils.py | 24 +- .../item/templates/includes/product_page.js | 4 +- .../support_ticket/templates/ticket.html | 66 ++++++ .../address/templates/pages/address.html | 1 - .../address/templates/pages/addresses.html | 1 - 15 files changed, 136 insertions(+), 290 deletions(-) delete mode 100644 portal/templates/pages/account.html delete mode 100644 portal/templates/pages/account.py create mode 100644 support/doctype/support_ticket/templates/ticket.html diff --git a/portal/templates/base.html b/portal/templates/base.html index cdbc045848..bc6fb9755c 100644 --- a/portal/templates/base.html +++ b/portal/templates/base.html @@ -1,23 +1,3 @@ {% extends "lib/website/templates/base.html" %} -{% block toolbar %} -
    -
    - {% if shopping_cart_enabled -%} - - | - {%- endif %} - Login -
    -
    - | - {% if shopping_cart_enabled -%} - - | - {%- endif %} - -
    -
    -{% endblock %} - {% block footer %}{% include "app/portal/templates/includes/footer.html" %}{% endblock %} \ No newline at end of file diff --git a/portal/templates/includes/cart.js b/portal/templates/includes/cart.js index 84d49f33c4..5ff6e3fb72 100644 --- a/portal/templates/includes/cart.js +++ b/portal/templates/includes/cart.js @@ -4,7 +4,7 @@ // js inside blog page $(document).ready(function() { - wn.cart.bind_events(); + erpnext.cart.bind_events(); return wn.call({ type: "POST", method: "selling.utils.cart.get_cart_quotation", @@ -14,23 +14,23 @@ $(document).ready(function() { $(".progress").remove(); if(r.exc) { if(r.exc.indexOf("WebsitePriceListMissingError")!==-1) { - wn.cart.show_error("Oops!", "Price List not configured."); + erpnext.cart.show_error("Oops!", "Price List not configured."); } else if(r["403"]) { - wn.cart.show_error("Hey!", "You need to be logged in to view your cart."); + erpnext.cart.show_error("Hey!", "You need to be logged in to view your cart."); } else { - wn.cart.show_error("Oops!", "Something went wrong."); + erpnext.cart.show_error("Oops!", "Something went wrong."); } } else { - wn.cart.set_cart_count(); - wn.cart.render(r.message); + erpnext.cart.set_cart_count(); + erpnext.cart.render(r.message); } } }); }); // shopping cart -if(!wn.cart) wn.cart = {}; -$.extend(wn.cart, { +if(!erpnext.cart) erpnext.cart = {}; +$.extend(erpnext.cart, { show_error: function(title, text) { $("#cart-container").html('

    ' + title + '

    ' + text + '
    '); }, @@ -39,14 +39,14 @@ $.extend(wn.cart, { // bind update button $(document).on("click", ".item-update-cart button", function() { var item_code = $(this).attr("data-item-code"); - wn.cart.update_cart({ + erpnext.cart.update_cart({ item_code: item_code, qty: $('input[data-item-code="'+item_code+'"]').val(), with_doclist: 1, btn: this, callback: function(r) { if(!r.exc) { - wn.cart.render(r.message); + erpnext.cart.render(r.message); var $button = $('button[data-item-code="'+item_code+'"]').addClass("btn-success"); setTimeout(function() { $button.removeClass("btn-success"); }, 1000); } @@ -63,7 +63,7 @@ $.extend(wn.cart, { }); $(".btn-place-order").on("click", function() { - wn.cart.place_order(); + erpnext.cart.place_order(this); }); }, @@ -79,7 +79,7 @@ $.extend(wn.cart, { var no_items = $.map(doclist, function(d) { return d.item_code || null;}).length===0; if(no_items) { - wn.cart.show_error("Empty :-(", "Go ahead and add something to your cart."); + erpnext.cart.show_error("Empty :-(", "Go ahead and add something to your cart."); $("#cart-addresses").toggle(false); return; } @@ -89,14 +89,14 @@ $.extend(wn.cart, { var shipping_rule_labels = $.map(out.shipping_rules || [], function(rule) { return rule[1]; }); $.each(doclist, function(i, doc) { if(doc.doctype === "Quotation Item") { - wn.cart.render_item_row($cart_items, doc); + erpnext.cart.render_item_row($cart_items, doc); } else if (doc.doctype === "Sales Taxes and Charges") { if(out.shipping_rules && out.shipping_rules.length && shipping_rule_labels.indexOf(doc.description)!==-1) { shipping_rule_added = true; - wn.cart.render_tax_row($cart_taxes, doc, out.shipping_rules); + erpnext.cart.render_tax_row($cart_taxes, doc, out.shipping_rules); } else { - wn.cart.render_tax_row($cart_taxes, doc); + erpnext.cart.render_tax_row($cart_taxes, doc); } taxes_exist = true; @@ -104,7 +104,7 @@ $.extend(wn.cart, { }); if(out.shipping_rules && out.shipping_rules.length && !shipping_rule_added) { - wn.cart.render_tax_row($cart_taxes, {description: "", formatted_tax_amount: ""}, + erpnext.cart.render_tax_row($cart_taxes, {description: "", formatted_tax_amount: ""}, out.shipping_rules); taxes_exist = true; } @@ -112,7 +112,7 @@ $.extend(wn.cart, { if(taxes_exist) $('
    ').appendTo($cart_taxes); - wn.cart.render_tax_row($cart_totals, { + erpnext.cart.render_tax_row($cart_totals, { description: "Total", formatted_tax_amount: "" + doclist[0].formatted_grand_total_export + "" }); @@ -120,8 +120,8 @@ $.extend(wn.cart, { if(!(addresses && addresses.length)) { $cart_shipping_address.html('
    Hey! Go ahead and add an address
    '); } else { - wn.cart.render_address($cart_shipping_address, addresses, doclist[0].shipping_address_name); - wn.cart.render_address($cart_billing_address, addresses, doclist[0].customer_address); + erpnext.cart.render_address($cart_shipping_address, addresses, doclist[0].shipping_address_name); + erpnext.cart.render_address($cart_billing_address, addresses, doclist[0].customer_address); } }, @@ -185,7 +185,7 @@ $.extend(wn.cart, { } }); $tax_row.find('select').on("change", function() { - wn.cart.apply_shipping_rule($(this).val(), this); + erpnext.cart.apply_shipping_rule($(this).val(), this); }); } }, @@ -198,7 +198,7 @@ $.extend(wn.cart, { args: { shipping_rule: rule }, callback: function(r) { if(!r.exc) { - wn.cart.render(r.message); + erpnext.cart.render(r.message); } } }); @@ -249,7 +249,7 @@ $.extend(wn.cart, { }, callback: function(r) { if(!r.exc) { - wn.cart.render(r.message); + erpnext.cart.render(r.message); } } }); @@ -270,10 +270,11 @@ $.extend(wn.cart, { .collapse("show"); }, - place_order: function() { + place_order: function(btn) { return wn.call({ type: "POST", method: "selling.utils.cart.place_order", + btn: btn, callback: function(r) { if(r.exc) { var msg = ""; diff --git a/portal/templates/includes/footer.html b/portal/templates/includes/footer.html index 1e8dd76142..6963175d91 100644 --- a/portal/templates/includes/footer.html +++ b/portal/templates/includes/footer.html @@ -1,10 +1,6 @@ {% extends "lib/website/templates/includes/footer.html" %} -{% block powered %} -

    - ERPNext Powered -

    -{% endblock %} +{% block powered %}ERPNext Powered{% endblock %} {% block extension %}
    diff --git a/portal/templates/includes/transactions.html b/portal/templates/includes/transactions.html index 23d5f812ea..65651ca5c5 100644 --- a/portal/templates/includes/transactions.html +++ b/portal/templates/includes/transactions.html @@ -4,7 +4,6 @@
    diff --git a/portal/templates/pages/account.html b/portal/templates/pages/account.html deleted file mode 100644 index da43dd24fa..0000000000 --- a/portal/templates/pages/account.html +++ /dev/null @@ -1,27 +0,0 @@ -{% extends base_template %} - -{% set title="My Account" %} - -{% block content %} - -{% endblock %} \ No newline at end of file diff --git a/portal/templates/pages/account.py b/portal/templates/pages/account.py deleted file mode 100644 index 24b474a55c..0000000000 --- a/portal/templates/pages/account.py +++ /dev/null @@ -1,6 +0,0 @@ -# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. -# License: GNU General Public License v3. See license.txt - -from __future__ import unicode_literals - -no_cache = True \ No newline at end of file diff --git a/portal/templates/pages/cart.html b/portal/templates/pages/cart.html index f210772831..8b648e5cca 100644 --- a/portal/templates/pages/cart.html +++ b/portal/templates/pages/cart.html @@ -13,7 +13,7 @@
    - +


    @@ -51,7 +51,7 @@

    - +

    {% endblock %} \ No newline at end of file diff --git a/portal/templates/pages/profile.html b/portal/templates/pages/profile.html index 65f3e37988..697190953b 100644 --- a/portal/templates/pages/profile.html +++ b/portal/templates/pages/profile.html @@ -6,7 +6,6 @@
    diff --git a/portal/templates/sale.html b/portal/templates/sale.html index 3a49684863..41ba297d3a 100644 --- a/portal/templates/sale.html +++ b/portal/templates/sale.html @@ -6,7 +6,6 @@
    diff --git a/public/js/website_utils.js b/public/js/website_utils.js index b5fea13bbe..b42a986e2b 100644 --- a/public/js/website_utils.js +++ b/public/js/website_utils.js @@ -2,7 +2,6 @@ // License: GNU General Public License v3. See license.txt if(!window.erpnext) erpnext = {}; -if(!window.wn) wn = {}; // Add / update a new Lead / Communication // subject, sender, description @@ -15,187 +14,20 @@ erpnext.send_message = function(opts) { }); } -wn.call = function(opts) { - if(opts.btn) { - $(opts.btn).prop("disabled", true); - } - - if(opts.msg) { - $(opts.msg).toggle(false); - } - - if(!opts.args) opts.args = {}; - - // get or post? - if(!opts.args._type) { - opts.args._type = opts.type || "GET"; - } - - // method - if(opts.method) { - opts.args.cmd = opts.method; - } - - // stringify - $.each(opts.args, function(key, val) { - if(typeof val != "string") { - opts.args[key] = JSON.stringify(val); - } - }); - - $.ajax({ - type: "POST", - url: "server.py", - data: opts.args, - dataType: "json", - success: function(data) { - if(opts.btn) { - $(opts.btn).prop("disabled", false); - } - if(data.exc) { - if(opts.btn) { - $(opts.btn).addClass("btn-danger"); - setTimeout(function() { $(opts.btn).removeClass("btn-danger"); }, 1000); - } - try { - var err = JSON.parse(data.exc); - if($.isArray(err)) { - err = err.join("\n"); - } - console.error ? console.error(err) : console.log(err); - } catch(e) { - console.log(data.exc); - } - } else{ - if(opts.btn) { - $(opts.btn).addClass("btn-success"); - setTimeout(function() { $(opts.btn).removeClass("btn-success"); }, 1000); - } - } - if(opts.msg && data.message) { - $(opts.msg).html(data.message).toggle(true); - } - if(opts.callback) - opts.callback(data); - }, - error: function(response) { - console.error ? console.error(response) : console.log(response); - } - }); - - return false; -} - // Setup the user tools // $(document).ready(function() { // update login - var full_name = getCookie("full_name"); - if(full_name) { - $("#user-tools").addClass("hide"); - $("#user-tools-post-login").removeClass("hide"); - $("#user-full-name").text(full_name); - } - - wn.cart.set_cart_count(); + erpnext.cart.set_cart_count(); $("#user-tools a").tooltip({"placement":"bottom"}); $("#user-tools-post-login a").tooltip({"placement":"bottom"}); }); -// Utility functions - -function valid_email(id) { - if(id.toLowerCase().search("[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?")==-1) - return 0; else return 1; } - -var validate_email = valid_email; - -function get_url_arg(name) { - name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]"); - var regexS = "[\\?&]"+name+"=([^&#]*)"; - var regex = new RegExp( regexS ); - var results = regex.exec( window.location.href ); - if(results == null) - return ""; - else - return decodeURIComponent(results[1]); -} - -function make_query_string(obj) { - var query_params = []; - $.each(obj, function(k, v) { query_params.push(encodeURIComponent(k) + "=" + encodeURIComponent(v)); }); - return "?" + query_params.join("&"); -} - -function repl(s, dict) { - if(s==null)return ''; - for(key in dict) { - s = s.split("%("+key+")s").join(dict[key]); - } - return s; -} - -function replace_all(s, t1, t2) { - return s.split(t1).join(t2); -} - -function getCookie(name) { - return getCookies()[name]; -} - -function getCookies() { - var c = document.cookie, v = 0, cookies = {}; - if (document.cookie.match(/^\s*\$Version=(?:"1"|1);\s*(.*)/)) { - c = RegExp.$1; - v = 1; - } - if (v === 0) { - c.split(/[,;]/).map(function(cookie) { - var parts = cookie.split(/=/, 2), - name = decodeURIComponent(parts[0].trimLeft()), - value = parts.length > 1 ? decodeURIComponent(parts[1].trimRight()) : null; - if(value && value.charAt(0)==='"') { - value = value.substr(1, value.length-2); - } - cookies[name] = value; - }); - } else { - c.match(/(?:^|\s+)([!#$%&'*+\-.0-9A-Z^`a-z|~]+)=([!#$%&'*+\-.0-9A-Z^`a-z|~]*|"(?:[\x20-\x7E\x80\xFF]|\\[\x00-\x7F])*")(?=\s*[,;]|$)/g).map(function($0, $1) { - var name = $0, - value = $1.charAt(0) === '"' - ? $1.substr(1, -1).replace(/\\(.)/g, "$1") - : $1; - cookies[name] = value; - }); - } - return cookies; -} - -if (typeof String.prototype.trimLeft !== "function") { - String.prototype.trimLeft = function() { - return this.replace(/^\s+/, ""); - }; -} -if (typeof String.prototype.trimRight !== "function") { - String.prototype.trimRight = function() { - return this.replace(/\s+$/, ""); - }; -} -if (typeof Array.prototype.map !== "function") { - Array.prototype.map = function(callback, thisArg) { - for (var i=0, n=this.length, a=[]; i")===-1 && txt.indexOf("