added server side print format
This commit is contained in:
parent
c8580930eb
commit
43fbc9d1b9
35
website/helpers/print.py
Normal file
35
website/helpers/print.py
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
# Copyright (c) 2012 Web Notes Technologies Pvt Ltd.
|
||||||
|
# License: GNU General Public License (v3). For more information see license.txt
|
||||||
|
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
import webnotes
|
||||||
|
from webnotes import _
|
||||||
|
|
||||||
|
def get_args():
|
||||||
|
if not webnotes.form_dict.doctype or not webnotes.form_dict.name \
|
||||||
|
or not webnotes.form_dict.format:
|
||||||
|
return {
|
||||||
|
"body": """<h1>Error</h1>
|
||||||
|
<p>Parameters doctype, name and format required</p>
|
||||||
|
<pre>%s</pre>""" % repr(webnotes.form_dict)
|
||||||
|
}
|
||||||
|
|
||||||
|
obj = webnotes.get_obj(webnotes.form_dict.doctype, webnotes.form_dict.name)
|
||||||
|
return {
|
||||||
|
"body": get_html(obj.doc, obj.doclist)
|
||||||
|
}
|
||||||
|
|
||||||
|
def get_html(doc, doclist):
|
||||||
|
from jinja2 import Environment
|
||||||
|
from core.doctype.print_style.print_style import get_print_style
|
||||||
|
from core.doctype.print_format.print_format import get_print_format
|
||||||
|
|
||||||
|
template = Environment().from_string(get_print_format(webnotes.form_dict.format))
|
||||||
|
|
||||||
|
args = {
|
||||||
|
"doc": doc,
|
||||||
|
"doclist": doclist,
|
||||||
|
"print_style": get_print_style()
|
||||||
|
}
|
||||||
|
html = template.render(args)
|
||||||
|
return html
|
||||||
@ -1,8 +1,6 @@
|
|||||||
{% extends "html/base.html" %}
|
{% extends "html/base.html" %}
|
||||||
|
|
||||||
{% block body %}
|
{% block body %}
|
||||||
<header>
|
|
||||||
</header>
|
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="pull-right" style="margin:4px;" id="user-tools">
|
<div class="pull-right" style="margin:4px;" id="user-tools">
|
||||||
<a id="login-link" href="login">Login</a>
|
<a id="login-link" href="login">Login</a>
|
||||||
|
|||||||
12
website/templates/pages/print.html
Normal file
12
website/templates/pages/print.html
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>{{ doc and (doc.name + " - " + doc.doctype) or "Error" }}</title>
|
||||||
|
<meta name="generator" content="wnframework">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
{{ body }}
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@ -43,10 +43,11 @@ page_settings_map = {
|
|||||||
"about": "website.doctype.about_us_settings.about_us_settings.get_args",
|
"about": "website.doctype.about_us_settings.about_us_settings.get_args",
|
||||||
"contact": "Contact Us Settings",
|
"contact": "Contact Us Settings",
|
||||||
"blog": "website.helpers.blog.get_blog_template_args",
|
"blog": "website.helpers.blog.get_blog_template_args",
|
||||||
"writers": "website.helpers.blog.get_writers_args"
|
"writers": "website.helpers.blog.get_writers_args",
|
||||||
|
"print": "website.helpers.print.get_args"
|
||||||
}
|
}
|
||||||
|
|
||||||
no_cache = "message"
|
no_cache = ["message", "print"]
|
||||||
|
|
||||||
def render(page_name):
|
def render(page_name):
|
||||||
"""render html page"""
|
"""render html page"""
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user