From 557abdebe09af858b21d2473af51bf113b0876cd Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Thu, 23 Jan 2014 13:25:26 +0530 Subject: [PATCH] order preview through customer login --- portal/templates/sale.html | 4 ++-- portal/utils.py | 12 +++++++----- selling/doctype/sales_order/templates/pages/order.py | 11 ++++++----- selling/utils/cart.py | 5 +++-- 4 files changed, 18 insertions(+), 14 deletions(-) diff --git a/portal/templates/sale.html b/portal/templates/sale.html index 5dc72c793b..c0996cc4f1 100644 --- a/portal/templates/sale.html +++ b/portal/templates/sale.html @@ -10,9 +10,9 @@
  • {{ doc.name }}
  • {{ doc.name }}

    - {% if doc.name == "Not Allowed" -%} + {% if session_user == "Guest" -%} - {% else %} + {% elif doc.name != "Not Allowed"%}
    diff --git a/portal/utils.py b/portal/utils.py index 89800f3e1d..e210f1a020 100644 --- a/portal/utils.py +++ b/portal/utils.py @@ -41,21 +41,23 @@ def get_currency_context(): } def get_transaction_context(doctype, name): + context = {"session_user": webnotes.session.user} + 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"} - } + context.update({"doc": {"name": "Not Allowed"}}) else: - return { + context.update({ "doc": bean.doc, "doclist": bean.doclist, "webnotes": webnotes, "utils": webnotes.utils - } + }) + + return context @webnotes.whitelist(allow_guest=True) def send_message(subject="Website Query", message="", sender="", status="Open"): diff --git a/selling/doctype/sales_order/templates/pages/order.py b/selling/doctype/sales_order/templates/pages/order.py index d53a8b0f6f..9b4a83ce21 100644 --- a/selling/doctype/sales_order/templates/pages/order.py +++ b/selling/doctype/sales_order/templates/pages/order.py @@ -10,11 +10,12 @@ no_cache = True def get_context(): from portal.utils import get_transaction_context context = get_transaction_context("Sales Order", webnotes.form_dict.name) - modify_status(context.get("doc")) - context.update({ - "parent_link": "orders", - "parent_title": "My Orders" - }) + if context.get("doc").get("name") != "Not Allowed": + modify_status(context.get("doc")) + context.update({ + "parent_link": "orders", + "parent_title": "My Orders" + }) return context def modify_status(doc): diff --git a/selling/utils/cart.py b/selling/utils/cart.py index 3cd7b3c9f1..79046270a9 100644 --- a/selling/utils/cart.py +++ b/selling/utils/cart.py @@ -282,7 +282,7 @@ def apply_cart_settings(party=None, quotation=None): party = get_lead_or_customer() if not quotation: quotation = _get_cart_quotation(party) - + cart_settings = webnotes.get_obj("Shopping Cart Settings") billing_territory = get_address_territory(quotation.doc.customer_address) or \ @@ -310,7 +310,8 @@ def set_price_list_and_rate(quotation, cart_settings, billing_territory): quotation.run_method("set_price_list_and_item_details") # set it in cookies for using in product page - webnotes.local._response.set_cookie("selling_price_list", quotation.doc.selling_price_list) + if quotation.doc.selling_price_list: + webnotes.local._response.set_cookie("selling_price_list", quotation.doc.selling_price_list) def set_taxes(quotation, cart_settings, billing_territory): """set taxes based on billing territory"""