2015-09-11 18:49:59 +05:30
|
|
|
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
|
|
|
# License: GNU General Public License v3. See license.txt
|
|
|
|
|
|
|
|
from __future__ import unicode_literals
|
|
|
|
import frappe
|
|
|
|
|
|
|
|
from frappe import _
|
2017-05-19 12:34:10 +02:00
|
|
|
from erpnext.shopping_cart.doctype.shopping_cart_settings.shopping_cart_settings import show_attachments
|
2015-09-11 18:49:59 +05:30
|
|
|
|
|
|
|
def get_context(context):
|
|
|
|
context.no_cache = 1
|
2016-04-20 16:20:49 +05:30
|
|
|
context.show_sidebar = True
|
2015-09-11 18:49:59 +05:30
|
|
|
context.doc = frappe.get_doc(frappe.form_dict.doctype, frappe.form_dict.name)
|
2015-09-16 18:52:52 +05:30
|
|
|
if hasattr(context.doc, "set_indicator"):
|
|
|
|
context.doc.set_indicator()
|
|
|
|
|
2017-05-19 12:34:10 +02:00
|
|
|
if show_attachments():
|
|
|
|
context.attachments = get_attachments(frappe.form_dict.doctype, frappe.form_dict.name)
|
|
|
|
|
2015-09-11 18:49:59 +05:30
|
|
|
context.parents = frappe.form_dict.parents
|
2016-10-12 10:31:08 +05:30
|
|
|
context.payment_ref = frappe.db.get_value("Payment Request",
|
2016-01-04 17:37:54 +05:30
|
|
|
{"reference_name": frappe.form_dict.name}, "name")
|
2016-09-21 16:49:58 +05:30
|
|
|
|
2016-01-21 15:43:07 +05:30
|
|
|
context.enabled_checkout = frappe.get_doc("Shopping Cart Settings").enable_checkout
|
2016-09-21 16:49:58 +05:30
|
|
|
|
2016-10-12 10:31:08 +05:30
|
|
|
if not frappe.has_website_permission(context.doc):
|
2015-09-11 18:49:59 +05:30
|
|
|
frappe.throw(_("Not Permitted"), frappe.PermissionError)
|
2017-05-19 12:34:10 +02:00
|
|
|
|
|
|
|
def get_attachments(dt, dn):
|
|
|
|
return frappe.get_all("File", fields=["name", "file_name", "file_url", "is_private"],
|
|
|
|
filters = {"attached_to_name": dn, "attached_to_doctype": dt, "is_private":0})
|