Skip to content

Commit

Permalink
Updated appreport module, Changed de helper REPORT and Included a exa…
Browse files Browse the repository at this point in the history
…mple to create complex reports, rendering a web2py views
  • Loading branch information
Lucas committed Jan 27, 2011
1 parent 72f0fbd commit c6ed5dc
Show file tree
Hide file tree
Showing 647 changed files with 194,969 additions and 76 deletions.
8 changes: 6 additions & 2 deletions COPYING
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,10 @@ Library.
# Licenses for third party contributed software

plugin appreport contains third party software under the libs folder.
Each file/module in libs is distributed with <programa> under its original license.
Each file/module in libs is distributed with plugin appreport under its original license.

#pyfpdf - Copyright (C) 2010 Mariano Reingart <[email protected]> - licensed of LGPL v3
#pyfpdf - Copyright (C) 2010 Mariano Reingart <[email protected]> - licensed under LGPL v3
#Pisa - Copyright (C) 2010 Dirk Holtwick, <holtwick.it> licenced under Apache License Version 2.0, January 2004
#pyPdf - Copyright (c) 2006, Mathieu Fenniak
Copyright (c) 2007, Ashish Kulkarni <[email protected]>
#reportlab - Copyright (c) 2000-2010, ReportLab Inc
11 changes: 8 additions & 3 deletions README
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
plugin appreport, is an implementation of the module appreport, for the framework web2py, through the helpers, is possible generate PDF reports and html forms for emission of the reports, based only on the definition of the table data model.
Plugin appreport, is an implementation of the module appreport, for the framework web2py, using helpers is possible generate PDF reports and forms html for emission of the reports.

- The form is generated based on table fields.
- The report can be generated based on the fields of the table or rendered by html code,

created by Lucas D'Avila - email <[email protected]> / twitter @lucadavila

################################
CHANGE LOG

0.0.?
-?
0.0.2
- Updated appreport module, because was included a new engine (called Pisa) to build the PDF documents, for more information visit: http://www.xhtml2pdf.com/
- Changed de helper REPORT to set default Pisa as engine to build PDF documents.
- Included a example to create complex reports, rendering a web2py views in PDF document, using the appreport plugin.

Binary file added __init__.pyc
Binary file not shown.
Empty file added cache/cache.lock
Empty file.
Binary file added cache/cache.shelve
Binary file not shown.
34 changes: 29 additions & 5 deletions controllers/person.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,47 @@
def create():

form = crud.create(person)
persons = crud.select(person, person.id > 0)
form_favs = crud.create(favorite_music)
persons = db().select(db.person.ALL, db.favorite_music.ALL, left=favorite_music.on(person.id == favorite_music.person))

return dict(form = form, persons = persons)
return dict(form = form, form_favs = form_favs, persons = persons)

def report():

form = plugin_appreport.REPORTFORM(person)
def simple_report():

form = plugin_appreport.REPORTFORM(table=person)

if form.accepts(request.vars, session):
return plugin_appreport.REPORT(table = person, title = 'List of persons', filter = dict(form.vars))

return dict(form = form)

def report_persons():

return dict(persons = db(person.id > 0).select())


def complex_report():

form = plugin_appreport.REPORTFORM(table=person)

if form.accepts(request.vars, session):
persons = db(form.prep_filter(filter = dict(form.vars))).select()
html = response.render('person/report_persons.html', dict(persons = persons))
return plugin_appreport.REPORT(html = html)

return dict(form = form)



def custom_report():

html = """<html>
<head>
<meta charset="utf-8" />
</head>
<body>
<h2>Report of persons</h2>
<table>
<thead>
<tr>
Expand All @@ -30,7 +54,7 @@ def custom_report():
</thead>
<tbody>
<tr>
<td>Lucas Davila</td>
<td>Lucas D'Avila</td>
<td>[email protected]</td>
<td>@lucadavila</td>
</tr>
Expand Down
41 changes: 41 additions & 0 deletions controllers/person.py.1
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# coding: utf8

def create():
form = crud.create(person)
persons = crud.select(person, person.id > 0)
return dict(form = form, persons = persons)

def report():
form = plugin_appreport.REPORTFORM(person)

if form.accepts(request.vars, session):
return plugin_appreport.REPORT(table = pessoa, title = 'List of persons', filter = dict(form.vars))

return dict(form = form)

def custom_report():

html = """<html>
<body>
<table>
<thead>
<tr>
<th>Author</th>
<th>Name</th>
<th>Phone</th>
<th>Email</th>
</tr>
</thead>
<tbody>
<tr>
<td>15</td>
<td>lucas davila</td>
<td>123455</td>
<td>[email protected]</td>
</tr>
</tbody>
</table>
</body>
</html>
"""
return plugin_appreport.REPORT(html = html, title = 'my custom report')
66 changes: 66 additions & 0 deletions controllers/person.py.bak
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# coding: utf8

def create():

form = crud.create(person)
form_favs = crud.create(favorite_music)
persons = db().select(db.person.ALL, db.favorite_music.ALL, left=favorite_music.on(person.id == favorite_music.person))

return dict(form = form, form_favs = form_favs, persons = persons)


def simple_report():

form = plugin_appreport.REPORTFORM(table=person)

if form.accepts(request.vars, session):
return plugin_appreport.REPORT(table = person, title = 'List of persons', filter = dict(form.vars))

return dict(form = form)

def report_persons():

return dict(persons = db(person.id > 0).select())


def complex_report():

form = plugin_appreport.REPORTFORM(table=person)

if form.accepts(request.vars, session):
persons = db(form.prep_filter(filter = dict(form.vars))).select()
html = response.render('person/report_persons.html', dict(persons = persons))
return plugin_appreport.REPORT(html = html, title = 'List of persons')

return dict(form = form)



def custom_report():

html = """<html>
<head>
<meta charset="utf-8" />
</head>
<body>
<h2>Report of persons</h2>
<table>
<thead>
<tr>
<th>Author</th>
<th>Email</th>
<th>Twitter</th>
</tr>
</thead>
<tbody>
<tr>
<td>Lucas D'Avila</td>
<td>[email protected]</td>
<td>@lucadavila</td>
</tr>
</tbody>
</table>
</body>
</html>
"""
return plugin_appreport.REPORT(html = html, title = 'my custom report using the plugin appreport')
1 change: 1 addition & 0 deletions databases/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*
26 changes: 26 additions & 0 deletions databases/c8b669d15150d7109e5f7ab36744a5b7_auth_event.table
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
(dp1
S'origin'
p2
S'CHAR(512)'
p3
sS'client_ip'
p4
S'CHAR(512)'
p5
sS'user_id'
p6
S'INTEGER REFERENCES auth_user(id) ON DELETE CASCADE'
p7
sS'description'
p8
S'TEXT'
p9
sS'time_stamp'
p10
S'TIMESTAMP'
p11
sS'id'
p12
S'INTEGER PRIMARY KEY AUTOINCREMENT'
p13
s.
14 changes: 14 additions & 0 deletions databases/c8b669d15150d7109e5f7ab36744a5b7_auth_group.table
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
(dp1
S'role'
p2
S'CHAR(512)'
p3
sS'id'
p4
S'INTEGER PRIMARY KEY AUTOINCREMENT'
p5
sS'description'
p6
S'TEXT'
p7
s.
14 changes: 14 additions & 0 deletions databases/c8b669d15150d7109e5f7ab36744a5b7_auth_membership.table
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
(dp1
S'group_id'
p2
S'INTEGER REFERENCES auth_group(id) ON DELETE CASCADE'
p3
sS'user_id'
p4
S'INTEGER REFERENCES auth_user(id) ON DELETE CASCADE'
p5
sS'id'
p6
S'INTEGER PRIMARY KEY AUTOINCREMENT'
p7
s.
22 changes: 22 additions & 0 deletions databases/c8b669d15150d7109e5f7ab36744a5b7_auth_permission.table
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
(dp1
S'record_id'
p2
S'INTEGER'
p3
sS'group_id'
p4
S'INTEGER REFERENCES auth_group(id) ON DELETE CASCADE'
p5
sS'table_name'
p6
S'CHAR(512)'
p7
sS'id'
p8
S'INTEGER PRIMARY KEY AUTOINCREMENT'
p9
sS'name'
p10
S'CHAR(512)'
p11
s.
30 changes: 30 additions & 0 deletions databases/c8b669d15150d7109e5f7ab36744a5b7_auth_user.table
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
(dp1
S'first_name'
p2
S'CHAR(128)'
p3
sS'last_name'
p4
S'CHAR(128)'
p5
sS'email'
p6
S'CHAR(512)'
p7
sS'reset_password_key'
p8
S'CHAR(512)'
p9
sS'password'
p10
S'CHAR(512)'
p11
sS'registration_key'
p12
S'CHAR(512)'
p13
sS'id'
p14
S'INTEGER PRIMARY KEY AUTOINCREMENT'
p15
s.
18 changes: 18 additions & 0 deletions databases/c8b669d15150d7109e5f7ab36744a5b7_favorite_music.table
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
(dp1
S'person'
p2
S'INTEGER REFERENCES person(id) ON DELETE CASCADE'
p3
sS'artist'
p4
S'CHAR(512)'
p5
sS'id'
p6
S'INTEGER PRIMARY KEY AUTOINCREMENT'
p7
sS'title'
p8
S'CHAR(512)'
p9
s.
18 changes: 18 additions & 0 deletions databases/c8b669d15150d7109e5f7ab36744a5b7_person.table
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
(dp1
S'phone'
p2
S'CHAR(512)'
p3
sS'email'
p4
S'CHAR(512)'
p5
sS'id'
p6
S'INTEGER PRIMARY KEY AUTOINCREMENT'
p7
sS'name'
p8
S'CHAR(512)'
p9
s.
14 changes: 14 additions & 0 deletions databases/c8b669d15150d7109e5f7ab36744a5b7_pessoa.table
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
(dp1
S'id'
p2
S'INTEGER PRIMARY KEY AUTOINCREMENT'
p3
sS'telefone'
p4
S'CHAR(512)'
p5
sS'nome'
p6
S'CHAR(512)'
p7
s.
Loading

0 comments on commit c6ed5dc

Please sign in to comment.