Skip to content
Snippets Groups Projects
Commit 013f62a3 authored by tux091's avatar tux091
Browse files

Introduce a mechanism to download report in different formats using iframe.

parent 7fa30b1d
No related branches found
No related tags found
No related merge requests found
......@@ -20,10 +20,25 @@ def report_2():
"""Return the url arguments
"""
s = ""
print request.post_vars
for k in request.post_vars:
s += "<br>%s: %s" % (k, request.post_vars[k])
return '<h3>report_2</h3>'+s
\ No newline at end of file
vars = request.vars
# user request a file with a specific format (latex,...)
# return to the browser na iframe balise with a new URL
# the browser will request the file locate at the url
if vars.Foo1My_format and vars.Foo1My_format == 'latex':
# remove the field use to select the file format
# in order to avoid circular loop
del vars.Foo1My_format
s = IFRAME(_id='MyId',
_frameborder=0,
_width=0,
_height=0,
_css='display:none;visibility:hidden;height:0px;',
_src=URL('reports', 'report_2.latex', vars=vars)).xml()
return s
# standart reponse
return dict(test=vars)
\ No newline at end of file
......@@ -27,6 +27,7 @@
'Last Page': 'Dernière Page',
'Max Records': 'Max Records',
'My Date': 'My Date',
'My Format': 'My Format',
'My Int': 'My Int',
'My List': 'My List',
'My String': 'My String',
......
......@@ -16,4 +16,4 @@ dummy.define_table("foo1",
Field('my_string', 'string'),
Field('my_int', 'integer', requires=IS_INT_IN_RANGE(0, 100)),
Field('my_date', 'date'),
Field('my_list', requires=IS_IN_SET(['a', 'b', 'c'])))
Field('my_format', default='html', requires=IS_IN_SET(['html', 'latex', 'pdf'])))
......@@ -192,7 +192,7 @@ configurator = lambda tablename: dbui.to_gridPanel(db[tablename])
gridNode.add_children(db.tables, func=configurator)
reportNode = dbui.Node(T('Reports'))
node = dbui.Panel(html='salut ma poule')
node = dbui.Panel(html="salut ma poule")
reportNode.add_child(T('report_1'), node)
fields = dbui.to_fields(dummy.foo1)
......
<h3>Report_2</h3>
{{for k in test:}}
<br>{{=k}}: {{=test[k]}}{{pass}}
\documentclass[english]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\begin{document}
\section*{Test}
\begin{enumerate}
{{for k in test:}}
\item {{=k}}: {{=test[k]}}{{pass}}
\end{enumerate}
\end{document}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment