Rushabh Mehta | 43fbc9d | 2013-03-19 12:05:10 +0530 | [diff] [blame^] | 1 | # Copyright (c) 2012 Web Notes Technologies Pvt Ltd. |
| 2 | # License: GNU General Public License (v3). For more information see license.txt |
| 3 | |
| 4 | from __future__ import unicode_literals |
| 5 | import webnotes |
| 6 | from webnotes import _ |
| 7 | |
| 8 | def 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 | |
| 22 | def 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 |