Exemplo n.º 1
0
def get_context(context):
	context.no_cache = 1
	context.show_sidebar = True
	context.doc = frappe.get_doc(frappe.form_dict.doctype, frappe.form_dict.name)
	if hasattr(context.doc, "set_indicator"):
		context.doc.set_indicator()

	if show_attachments():
		context.attachments = get_attachments(frappe.form_dict.doctype, frappe.form_dict.name)

	context.parents = frappe.form_dict.parents
	context.title = frappe.form_dict.name
	context.payment_ref = frappe.db.get_value("Payment Request",
		{"reference_name": frappe.form_dict.name}, "name")

	context.enabled_checkout = frappe.get_doc("Shopping Cart Settings").enable_checkout

	default_print_format = frappe.db.get_value('Property Setter', dict(property='default_print_format', doc_type=frappe.form_dict.doctype), "value")
	if default_print_format:
		context.print_format = default_print_format
	else:
		context.print_format = "Standard"

	if not frappe.has_website_permission(context.doc):
		frappe.throw(_("Not Permitted"), frappe.PermissionError)
	
	# check for the loyalty program of the customer
	customer_loyalty_program = frappe.db.get_value("Customer", context.doc.customer, "loyalty_program")	
	if customer_loyalty_program:
		from erpnext.accounts.doctype.loyalty_program.loyalty_program import get_loyalty_program_details_with_points
		loyalty_program_details = get_loyalty_program_details_with_points(context.doc.customer, customer_loyalty_program)
		context.available_loyalty_points = int(loyalty_program_details.get("loyalty_points"))
Exemplo n.º 2
0
def get_context(context):
    context.no_cache = 1
    context.show_sidebar = True
    context.doc = frappe.get_doc(frappe.form_dict.doctype,
                                 frappe.form_dict.name)
    if hasattr(context.doc, "set_indicator"):
        context.doc.set_indicator()

    if show_attachments():
        context.attachments = get_attachments(frappe.form_dict.doctype,
                                              frappe.form_dict.name)

    context.parents = frappe.form_dict.parents
    context.title = frappe.form_dict.name
    context.payment_ref = frappe.db.get_value(
        "Payment Request", {"reference_name": frappe.form_dict.name}, "name")

    context.enabled_checkout = frappe.get_doc(
        "Shopping Cart Settings").enable_checkout

    default_print_format = frappe.db.get_value(
        'Property Setter',
        dict(property='default_print_format',
             doc_type=frappe.form_dict.doctype), "value")
    if default_print_format:
        context.print_format = default_print_format
    else:
        context.print_format = "Standard"

    if not frappe.has_website_permission(context.doc):
        frappe.throw(_("Not Permitted"), frappe.PermissionError)
Exemplo n.º 3
0
def get_context(context):
	context.no_cache = 1
	context.show_sidebar = True
	context.doc = frappe.get_doc(frappe.form_dict.doctype, frappe.form_dict.name)
	if hasattr(context.doc, "set_indicator"):
		context.doc.set_indicator()

	if show_attachments():
		context.attachments = get_attachments(frappe.form_dict.doctype, frappe.form_dict.name)

	context.parents = frappe.form_dict.parents
	context.title = frappe.form_dict.name
	context.payment_ref = frappe.db.get_value("Payment Request",
		{"reference_name": frappe.form_dict.name}, "name")

	context.enabled_checkout = frappe.get_doc("Shopping Cart Settings").enable_checkout

	default_print_format = frappe.db.get_value('Property Setter', dict(property='default_print_format', doc_type=frappe.form_dict.doctype), "value")
	if default_print_format:
		context.print_format = default_print_format
	else:
		context.print_format = "Standard"

	if not frappe.has_website_permission(context.doc):
		frappe.throw(_("Not Permitted"), frappe.PermissionError)
Exemplo n.º 4
0
def validate_print_permission(doc):
	if frappe.form_dict.get("key"):
		if frappe.form_dict.key == doc.get_signature():
			return

	for ptype in ("read", "print"):
		if not frappe.has_permission(doc.doctype, ptype, doc) and not frappe.has_website_permission(doc):
			raise frappe.PermissionError(_("No {0} permission").format(ptype))
Exemplo n.º 5
0
def validate_print_permission(doc):
	if frappe.form_dict.get("key"):
		if frappe.form_dict.key == doc.get_signature():
			return

	for ptype in ("read", "print"):
		if (not frappe.has_permission(doc.doctype, ptype, doc)
			and not frappe.has_website_permission(doc)):
			raise frappe.PermissionError(_("No {0} permission").format(ptype))
	def has_website_permission(self, permtype="read", verbose=False):
		"""Call `frappe.has_website_permission` if `self.flags.ignore_permissions`
		is not set.

		:param permtype: one of `read`, `write`, `submit`, `cancel`, `delete`"""
		if self.flags.ignore_permissions:
			return True

		return (frappe.has_website_permission(self.doctype, permtype, self, verbose=verbose)
			or self.has_permission(permtype, verbose=verbose))
Exemplo n.º 7
0
	def has_website_permission(self, permtype="read", verbose=False):
		"""Call `frappe.has_website_permission` if `self.flags.ignore_permissions`
		is not set.

		:param permtype: one of `read`, `write`, `submit`, `cancel`, `delete`"""
		if self.flags.ignore_permissions:
			return True

		return (frappe.has_website_permission(self.doctype, permtype, self, verbose=verbose)
			or self.has_permission(permtype, verbose=verbose))
Exemplo n.º 8
0
def has_web_form_permission(doctype, name, ptype='read'):
	if frappe.session.user=="Guest":
		return False

	# owner matches
	elif frappe.db.get_value(doctype, name, "owner")==frappe.session.user:
		return True

	elif frappe.has_website_permission(doctype, ptype=ptype, doc=name):
		return True

	else:
		return False
Exemplo n.º 9
0
def has_web_form_permission(doctype, name, ptype='read'):
	if frappe.session.user=="Guest":
		return False

	# owner matches
	elif frappe.db.get_value(doctype, name, "owner")==frappe.session.user:
		return True

	elif frappe.has_website_permission(doctype, ptype=ptype, doc=name):
		return True

	else:
		return False
Exemplo n.º 10
0
def get_context(context):
	context.no_cache = 1
	context.show_sidebar = True
	context.doc = frappe.get_doc(frappe.form_dict.doctype, frappe.form_dict.name)
	if hasattr(context.doc, "set_indicator"):
		context.doc.set_indicator()

	context.parents = frappe.form_dict.parents
	context.payment_ref = frappe.db.get_value("Payment Request",
		{"reference_name": frappe.form_dict.name}, "name")

	context.enabled_checkout = frappe.get_doc("Shopping Cart Settings").enable_checkout

	if not frappe.has_website_permission(context.doc):
		frappe.throw(_("Not Permitted"), frappe.PermissionError)
Exemplo n.º 11
0
def has_web_form_permission(doctype, name, ptype='read'):
	user = frappe.session.user
	if user == "Guest":
		return False

	# owner matches
	elif user == frappe.get_cached_value(doctype, name, "owner"):
		return True

	elif frappe.has_website_permission(name, ptype=ptype, doctype=doctype):
		return True

	elif check_webform_perm(doctype, name):
		return True

	else:
		return False
Exemplo n.º 12
0
def get_context(context):
    context.no_cache = 1
    context.show_sidebar = True

    # setup cart context
    shopping_cart_settings = get_shopping_cart_settings()
    context.payment_gateway_list = shopping_cart_settings.gateways
    context.enabled_checkout = shopping_cart_settings.enable_checkout

    # setup document context
    context.doc = frappe.get_doc(frappe.form_dict.doctype,
                                 frappe.form_dict.name)

    if not frappe.has_website_permission(context.doc):
        frappe.throw(_("Not Permitted"), frappe.PermissionError)

    context.parents = frappe.form_dict.parents
    context.title = frappe.form_dict.name
    context.payment_ref = frappe.db.get_value(
        "Payment Request", {"reference_name": frappe.form_dict.name}, "name")

    default_print_format = frappe.db.get_value(
        'Property Setter',
        dict(property='default_print_format',
             doc_type=frappe.form_dict.doctype), "value")

    context.print_format = default_print_format or "Standard"

    if hasattr(context.doc, "set_indicator"):
        context.doc.set_indicator()

    if show_attachments():
        context.attachments = get_attachments(frappe.form_dict.doctype,
                                              frappe.form_dict.name)

    # setup loyalty program for the customer, if available
    customer_loyalty_program = frappe.db.get_value("Customer",
                                                   context.doc.customer,
                                                   "loyalty_program")
    if customer_loyalty_program:
        from erpnext.accounts.doctype.loyalty_program.loyalty_program import get_loyalty_program_details_with_points

        loyalty_program_details = get_loyalty_program_details_with_points(
            context.doc.customer, customer_loyalty_program)
        context.available_loyalty_points = int(
            loyalty_program_details.get("loyalty_points"))
Exemplo n.º 13
0
def get_context(context):
	context.no_cache = 1
	context.show_sidebar = True
	context.doc = frappe.get_doc(frappe.form_dict.doctype, frappe.form_dict.name)
	if hasattr(context.doc, "set_indicator"):
		context.doc.set_indicator()

	if show_attachments():
		context.attachments = get_attachments(frappe.form_dict.doctype, frappe.form_dict.name)

	context.parents = frappe.form_dict.parents
	context.title = frappe.form_dict.name
	context.payment_ref = frappe.db.get_value(
		"Payment Request", {"reference_name": frappe.form_dict.name}, "name"
	)

	context.enabled_checkout = frappe.get_doc("E Commerce Settings").enable_checkout

	default_print_format = frappe.db.get_value(
		"Property Setter",
		dict(property="default_print_format", doc_type=frappe.form_dict.doctype),
		"value",
	)
	if default_print_format:
		context.print_format = default_print_format
	else:
		context.print_format = "Standard"

	if not frappe.has_website_permission(context.doc):
		frappe.throw(_("Not Permitted"), frappe.PermissionError)

	# check for the loyalty program of the customer
	customer_loyalty_program = frappe.db.get_value(
		"Customer", context.doc.customer, "loyalty_program"
	)
	if customer_loyalty_program:
		from erpnext.accounts.doctype.loyalty_program.loyalty_program import (
			get_loyalty_program_details_with_points,
		)

		loyalty_program_details = get_loyalty_program_details_with_points(
			context.doc.customer, customer_loyalty_program
		)
		context.available_loyalty_points = int(loyalty_program_details.get("loyalty_points"))
Exemplo n.º 14
0
    def has_web_form_permission(self, doctype, name, ptype='read'):
        if frappe.session.user == "Guest":
            return False

        if self.apply_document_permissions:
            return frappe.get_doc(doctype, name).has_permission()

        # owner matches
        elif frappe.db.get_value(doctype, name,
                                 "owner") == frappe.session.user:
            return True

        elif frappe.has_website_permission(name, ptype=ptype, doctype=doctype):
            return True

        elif check_webform_perm(doctype, name):
            return True

        else:
            return False
def get_context(context):
    doctype = frappe.local.request.args.get('doctype')
    name = frappe.local.request.args.get("name")

    if not doctype or not name:
        context.error = "Provided Payment URL is invalid."

    # setup cart context
    shopping_cart_settings = get_shopping_cart_settings()
    context.payment_gateway_list = shopping_cart_settings.gateways
    context.enabled_checkout = shopping_cart_settings.enable_checkout

    if not context.enabled_checkout:
        context.error = "Please enable checkout to continue."

    # setup document context
    context.doc = frappe.get_doc(doctype, name)

    if not frappe.has_website_permission(context.doc):
        frappe.throw(_("Not Permitted"), frappe.PermissionError)
Exemplo n.º 16
0
def get_context(context):
	context.no_cache = 1
	context.show_sidebar = True
	context.doc = frappe.get_doc(frappe.form_dict.doctype, frappe.form_dict.name)
	if hasattr(context.doc, "set_indicator"):
		context.doc.set_indicator()

	context.parents = frappe.form_dict.parents
	context.title = frappe.form_dict.name

	if not frappe.has_website_permission(context.doc):
		frappe.throw(_("Not Permitted"), frappe.PermissionError)

	default_print_format = frappe.db.get_value(
		"Property Setter",
		dict(property="default_print_format", doc_type=frappe.form_dict.doctype),
		"value",
	)
	if default_print_format:
		context.print_format = default_print_format
	else:
		context.print_format = "Standard"
	context.doc.items = get_more_items_info(context.doc.items, context.doc.name)