Commit 576bd9ec authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Graph can be export as pdf or png file.

parent a34aaa3d
......@@ -57,4 +57,5 @@ def index():
ax = do_linechart(db.publications, selector)
# delegate the rendering to the view
return dict(data=savefig(ax, "svg"))
fmt = "svg" if selector.format == "html" else selector.format
return dict(data=savefig(ax, fmt))
......@@ -14,13 +14,16 @@ virtdb.define_table('graph_selector',
Field('id_projects', 'reference projects', label='Project'),
Field('id_authors_roles', 'reference authors_roles', label='Role'),
Field('id_graphs', 'reference graphs', label='Graph'),
Field('cumulative', 'boolean', default=True))
Field('cumulative', 'boolean', default=True),
Field('format', 'string', default='html', label='Format'))
virtdb.graph_selector.id_authors_roles.requires = IS_IN_DB(db, 'authors_roles.role')
virtdb.graph_selector.id_graphs.requires = IS_IN_DB(db, 'graphs.graph')
virtdb.graph_selector.id_projects.requires = IS_IN_DB(db, 'projects.project')
virtdb.graph_selector.id_teams.requires = IS_IN_DB(db, 'teams.team')
virtdb.graph_selector.format.requires = IS_IN_SET(['html', 'pdf', 'png'])
#-------------------------------------------------------------------------------
#
# FIELDS CONFIGURATiON
......
......@@ -196,7 +196,8 @@ dashBoardLeaf = Panel(loader=loader,
autoScroll=True)
graphLeaf = PanelWithUrlSelector(virtdb.graph_selector,
baseUrl=URL('graphs', 'index'))
baseUrl=URL('graphs', 'index'),
extField='format')
listLeaf = PanelWithUrlSelector(virtdb.list_selector,
baseUrl=URL('lists', 'index'),
......
{{
import cStringIO
response.body = cStringIO.StringIO()
response.headers['Content-Type']='application/pdf'
response.write(data, escape=False)
}}
\ No newline at end of file
{{
import cStringIO
response.body = cStringIO.StringIO()
response.headers['Content-Type']='application/png'
response.write(data, escape=False)
}}
\ 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