blob: 41eb82c1af56c484f68af08ef6e7d682f6481d04 [file] [log] [blame]
Rushabh Mehta43fbc9d2013-03-19 12:05:10 +05301# Copyright (c) 2012 Web Notes Technologies Pvt Ltd.
2# License: GNU General Public License (v3). For more information see license.txt
3
4from __future__ import unicode_literals
5import webnotes
6from webnotes import _
7
8def get_args():
9 if not webnotes.form_dict.doctype or not webnotes.form_dict.name \
10 or not webnotes.form_dict.format:
11 return {
12 "body": """<h1>Error</h1>
13 <p>Parameters doctype, name and format required</p>
14 <pre>%s</pre>""" % repr(webnotes.form_dict)
15 }
16
17 obj = webnotes.get_obj(webnotes.form_dict.doctype, webnotes.form_dict.name)
18 return {
19 "body": get_html(obj.doc, obj.doclist)
20 }
21
22def get_html(doc, doclist):
23 from jinja2 import Environment
24 from core.doctype.print_style.print_style import get_print_style
25 from core.doctype.print_format.print_format import get_print_format
26
27 template = Environment().from_string(get_print_format(webnotes.form_dict.format))
28
29 args = {
30 "doc": doc,
31 "doclist": doclist,
32 "print_style": get_print_style()
33 }
34 html = template.render(args)
35 return html