Esempio n. 1
0
def get_print(doctype=None,
              name=None,
              print_format=None,
              style=None,
              html=None,
              as_pdf=False,
              doc=None,
              output=None):
    """Get Print Format for given document.

	:param doctype: DocType of document.
	:param name: Name of document.
	:param print_format: Print Format name. Default 'Standard',
	:param style: Print Format style.
	:param as_pdf: Return as PDF. Default False."""
    from frappe.website.render import build_page
    from frappe.utils.pdf import get_pdf

    local.form_dict.doctype = doctype
    local.form_dict.name = name
    local.form_dict.format = print_format
    local.form_dict.style = style
    local.form_dict.doc = doc

    if not html:
        html = build_page("printview")

    if as_pdf:
        return get_pdf(html, output=output)
    else:
        return html
Esempio n. 2
0
def get_print(doctype=None, name=None, print_format=None, style=None, html=None, as_pdf=False, doc=None, output = None, no_letterhead = 0):
	"""Get Print Format for given document.

	:param doctype: DocType of document.
	:param name: Name of document.
	:param print_format: Print Format name. Default 'Standard',
	:param style: Print Format style.
	:param as_pdf: Return as PDF. Default False."""
	from frappe.website.render import build_page
	from frappe.utils.pdf import get_pdf

	local.form_dict.doctype = doctype
	local.form_dict.name = name
	local.form_dict.format = print_format
	local.form_dict.style = style
	local.form_dict.doc = doc
	local.form_dict.no_letterhead = no_letterhead

	if not html:
		html = build_page("printview")

	if as_pdf:
		return get_pdf(html, output = output)
	else:
		return html
Esempio n. 3
0
def get_print(doctype=None, name=None, print_format=None, style=None, html=None, as_pdf=False, doc=None, output = None, no_letterhead = 0, password=None):
	"""Get Print Format for given document.

	:param doctype: DocType of document.
	:param name: Name of document.
	:param print_format: Print Format name. Default 'Standard',
	:param style: Print Format style.
	:param as_pdf: Return as PDF. Default False.
	:param password: Password to encrypt the pdf with. Default None"""
	from frappe.website.render import build_page
	from frappe.utils.pdf import get_pdf

	local.form_dict.doctype = doctype
	local.form_dict.name = name
	local.form_dict.format = print_format
	local.form_dict.style = style
	local.form_dict.doc = doc
	local.form_dict.no_letterhead = no_letterhead

	options = None
	if password:
		options = {'password': password}

	if not html:
		html = build_page("printview")

	if as_pdf:
		return get_pdf(html, output = output, options = options)
	else:
		return html
Esempio n. 4
0
def get_print_format(doctype, name, print_format=None, style=None, as_pdf=False):
	from frappe.website.render import build_page
	from frappe.utils.pdf import get_pdf

	local.form_dict.doctype = doctype
	local.form_dict.name = name
	local.form_dict.format = print_format
	local.form_dict.style = style

	html = build_page("print")

	if as_pdf:
		return get_pdf(html)
	else:
		return html
Esempio n. 5
0
def get_print_format(doctype, name, print_format=None, style=None, as_pdf=False):
	from frappe.website.render import build_page
	local.form_dict.doctype = doctype
	local.form_dict.name = name
	local.form_dict.format = print_format
	local.form_dict.style = style

	html = build_page("print")

	if as_pdf:
		print_settings = db.get_singles_dict("Print Settings")
		if int(print_settings.send_print_as_pdf or 0):
			from utils.pdf import get_pdf
			return get_pdf(html, {"page-size": print_settings.pdf_page_size})
		else:
			return html
	else:
		return html
Esempio n. 6
0
def get_print_format(doctype,
                     name,
                     print_format=None,
                     style=None,
                     as_pdf=False):
    from frappe.website.render import build_page
    local.form_dict.doctype = doctype
    local.form_dict.name = name
    local.form_dict.format = print_format
    local.form_dict.style = style

    html = build_page("print")

    if as_pdf:
        print_settings = db.get_singles_dict("Print Settings")
        if int(print_settings.send_print_as_pdf or 0):
            from utils.pdf import get_pdf
            return get_pdf(html, {"page-size": print_settings.pdf_page_size})
        else:
            return html
    else:
        return html
Esempio n. 7
0
	def test_new(self):
		frappe.set_user("Administrator")
		frappe.local.form_dict.new = 1
		html = build_page("manage-events")
		self.assertTrue('name="subject"' in html)
Esempio n. 8
0
	def test_logged_in(self):
		frappe.set_user("Administrator")
		html = build_page("manage-events")
		self.assertFalse("Please login to create a new Event" in html)
		self.assertTrue('"/manage-events?new=1"' in html)
Esempio n. 9
0
	def test_basic(self):
		frappe.set_user("Guest")
		html = build_page("manage-events")
		self.assertTrue("Please login to create a new Event" in html)
	def test_new(self):
		frappe.set_user("Administrator")
		frappe.local.form_dict.new = 1
		html = build_page("manage-events")
		self.assertTrue('name="subject"' in html)
	def test_logged_in(self):
		frappe.set_user("Administrator")
		html = build_page("manage-events")
		self.assertFalse("Please login to create a new Event" in html)
		self.assertTrue('"/manage-events?new=1"' in html)
	def test_basic(self):
		frappe.set_user("Guest")
		html = build_page("manage-events")
		self.assertTrue("Please login to create a new Event" in html)
Esempio n. 13
0
 def test_logged_in(self):
     frappe.set_user("Administrator")
     html = build_page("manage-events")
     self.assertFalse('<div class="login-required">' in html)
     self.assertTrue('"/manage-events?new=1"' in html)
Esempio n. 14
0
 def test_basic(self):
     frappe.set_user("Guest")
     html = build_page("manage-events")
     self.assertTrue('<div class="login-required">' in html)
Esempio n. 15
0
	def test_logged_in(self):
		frappe.set_user("Administrator")
		html = build_page("manage-events")
		self.assertFalse('<div class="login-required">' in html)
		self.assertTrue('"/manage-events?new=1"' in html)
Esempio n. 16
0
	def test_basic(self):
		frappe.set_user("Guest")
		html = build_page("manage-events")
		self.assertTrue('<div class="login-required">' in html)