Commit 0751cb66 authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Remove obsolete views/report.* files.

parent 1f54a388
{{=H1(header)}}
<br>
<br>
{{include '%s/%s.cfg' % (request.controller, request.function)}}
{{
table = SQLTABLE(rows,
columns=columns,
headers=headers,
extracolumns=extracolumns,
renderstyle=True)
response.write(CENTER(table))
}}
{{=footer}}
{{extend 'report.tex'}}
{{
import cStringIO
import os
from subprocess import call
from tempfile import TemporaryFile
from uuid import uuid4
#
# Get the latex string generate by the latex view
# and remove it from the response object
#
latex = response.body.getvalue()
response.body = cStringIO.StringIO()
#
# go to the private directory and create a latex file
#
cwd = os.getcwd()
os.chdir(os.path.join(request.folder, 'private'))
fn = str(uuid4())
fi = open('%s.tex' % fn, 'wb')
fi.write(latex)
fi.close()
#
# Launch a subprocess to convert the latex file into pdf
#
cmd = ['pdflatex', '-interaction', 'nonstopmode', '%s.tex' % fn]
call(cmd, stdout=TemporaryFile())
#
# copy the pdf in the new response
#
fi = open('%s.pdf' % fn, 'rb')
response.headers['Content-Type']='application/pdf'
response.write(fi.read(), escape=False)
#
# clean files
#
for ext in ('aux', 'log', 'pdf', 'tex'):
f = '%s.%s' % (fn, ext)
if os.path.exists(f):
os.remove(f)
pass
pass
#
# go back to the web2py main directory
#
os.chdir(cwd)
}}
\ No newline at end of file
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[landscape,a4paper]{geometry}
\usepackage{longtable}
\geometry{verbose,tmargin=2cm,bmargin=2cm,lmargin=1.85cm,rmargin=1.85cm}
\pagestyle{empty}
\setcounter{LTchunksize}{500}
\begin{document}
{{include '%s/%s.cfg' % (request.controller, request.function)}}
{{
# page title
response.write('\section*{%s} \n' % header)
# number of columns in the table
ncols = len(columns) + len(extracolumns)
li = ['l']*ncols
response.write('\\begin{longtable}{|%s|} \n' % '|'.join(li))
# table header including extra columns
response.write('\hline \n')
li = []
for el in columns:
if headers == 'labels':
tablename, columname = el.split('.')
name = db[tablename][columname].label
elif isinstance(headers, dict) and el in headers:
name = headers[el]
else:
name = el
pass
li.append(name)
pass
for el in extracolumns:
li.append(el['label'])
pass
response.write('%s \\\ \n' % ' & '.join(li), escape=False)
response.write('\hline \hline \n')
# table content
for row in rows.records:
li = []
for el in columns:
value = row[el]
# use the field representation
# similar to representation to the one in SQLTABLE
# NOTE: be careful this code is not generic
if '.' in el:
tablename, columname = el.split('.')
if tablename in db.tables:
f = db[tablename][columname].represent
if f:
if f.func_code.co_argcount == 1:
value = f(value)
elif f.func_code.co_argcount == 2:
value = f(value, row)
pass
pass
pass
pass
li.append(str(value))
pass
for el in extracolumns:
value = el['content'](row, '')
li.append(str(value))
pass
response.write('%s \\\ \n \hline \n' % ' & '.join(li), escape=False)
pass
response.write('\hline \n')
response.write('\end{longtable} \n')
}}
\end{document}
{{include}}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment