From c59c4e069932849edb1cd6e1fa1aefe847d1525c Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Mon, 9 Sep 2013 12:17:45 +0530 Subject: [PATCH] [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