Skip to content
Browse files

updated lib appreport to version v0.1.0, refactored helpers and examp…

…les, moved especific web2py modules and classes of lib appreport for this project and created new helpers REPORTPISA and REPORTPYFPDF
  • Loading branch information...
1 parent 23c0287 commit 14ee249e098d23f79ce97b7ef2fe4cf5e646090f Lucas D'Avila committed Jun 26, 2011
View
1 .gitignore
@@ -7,3 +7,4 @@
/sessions
.project
.pydevproject
+*.class
View
21 controllers/default.py
@@ -53,3 +53,24 @@ def call():
return service()
+def report():
+ session.forget()
+ return service()
+
+import xmlrpclib
+
+@service.xmlrpc
+def pdf(view_name, username = '', args = {}, *_args, **kargs):
+
+ if not view_name:
+ raise Exception('Invalid view_name')
+ if not isinstance(view_name, str):
+ raise Exception('View_name must be string')
+ if not isinstance(username, str):
+ raise Exception('Username must be string')
+ elif not isinstance(args, dict):
+ raise Exception('Invalid args')
+
+ report = xmlrpclib.Binary(plugin_appreport.REPORTJASPER(view_name = view_name, args = args))
+
+ return dict(report_name = '%s_%s.pdf'%(view_name, username), report = report)
View
21 controllers/person.py
@@ -10,27 +10,32 @@ def create():
def simple_report():
-
+ #generates a html form to filter the data to be displayed in the 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))
+ #build a report based on table fields (aka auto generates html) and filters informed in form
+ return plugin_appreport.REPORTPISA(table = person, title = 'List of persons', args = dict(form.vars))
return dict(form = form)
+
def report_persons():
-
return dict(persons = db(person.id > 0).select())
def complex_report():
-
+ #generates a html form to filter the data to be displayed in the report
form = plugin_appreport.REPORTFORM(table=person)
if form.accepts(request.vars, session):
+
+ #select a set of persons based on informed filters
persons = db(form.prep_filter(filter = dict(form.vars))).select()
+
+ #build a report based on dynamic html of view 'person/report_persons.html'
html = response.render('person/report_persons.html', dict(persons = persons))
- return plugin_appreport.REPORT(html = html)
+ return plugin_appreport.REPORTPISA(html = html)
return dict(form = form)
@@ -43,7 +48,7 @@ def custom_report():
<meta charset="utf-8" />
</head>
<body>
- <h2>Report of persons</h2>
+ <h2>my custom report using the plugin_appreport</h2>
<table>
<thead>
<tr>
@@ -63,4 +68,6 @@ def custom_report():
</body>
</html>
"""
- return plugin_appreport.REPORT(html = html, title = 'my custom report using the plugin appreport')
+ #build a report based on static html
+ return plugin_appreport.REPORTPISA(html = html)
+ #or return plugin_appreport.REPORTPYFPDF(html = html, title = 'my custom report using the plugin appreport')
View
1 cron/crontab
@@ -0,0 +1 @@
+#crontab
View
2 languages/pt-br.py
@@ -81,6 +81,7 @@
'Register': 'Registre-se',
'Registration key': 'Registration key',
'Repors': 'Repors',
+'Reports': 'Reports',
'Repositorie': 'Repositorie',
'Repositories': 'Repositories',
'Repository': 'Repository',
@@ -133,6 +134,7 @@
'documentation': 'documentation',
'done!': 'concluído!',
'edit profile': 'editar perfil',
+'enter an integer between %(min)g and %(max)g': 'enter an integer between %(min)g and %(max)g',
'export as csv file': 'exportar como um arquivo csv',
'insert new': 'inserir novo',
'insert new %s': 'inserir novo %s',
View
85 models/db.py
@@ -1,80 +1,20 @@
# -*- coding: utf-8 -*-
-# this file is released under public domain and you can use without limitations
-#########################################################################
-## This scaffolding model makes your app work on Google App Engine too
-#########################################################################
+import sys
-if request.env.web2py_runtime_gae: # if running on Google App Engine
- db = DAL('gae://mynamespace') # connect to Google BigTable
- session.connect(request, response, db = db) # and store sessions and tickets there
- ### or use the following lines to store sessions in Memcache
- # from gluon.contrib.memdb import MEMDB
- # from google.appengine.api.memcache import Client
- # session.connect(request, response, db = MEMDB(Client()))
-else: # else use a normal relational database
- db = DAL('sqlite://storage.sqlite') # if not, use SQLite or other DB
-## if no need for session
-# session.forget()
+if request.env.web2py_runtime_gae:
+ db = DAL('gae://mynamespace')
+ session.connect(request, response, db = db)
+elif 'java' in sys.platform:
+ #TODO REPORT ERROR JDBC SQLITE AND POSTGRESX
+ db = DAL('jdbc:sqlite://storage.sqlite') # or DAL('jdbc:postgres://postgres:postgres@localhost:5432/plugin_appreport')
+else:
+ db = DAL('sqlite://storage.sqlite') # or DAL('postgres://postgres:postgres@localhost:5432/plugin_appreport')
-#########################################################################
-## Here is sample code if you need for
-## - email capabilities
-## - authentication (registration, login, logout, ... )
-## - authorization (role based authorization)
-## - services (xml, csv, json, xmlrpc, jsonrpc, amf, rss)
-## - crud actions
-## (more options discussed in gluon/tools.py)
-#########################################################################
-
-from gluon.tools import *
-mail = Mail() # mailer
-auth = Auth(globals(),db) # authentication/authorization
-crud = Crud(globals(),db) # for CRUD helpers using auth
-service = Service(globals()) # for json, xml, jsonrpc, xmlrpc, amfrpc
+from gluon.tools import PluginManager, Service, Crud
plugins = PluginManager()
-
-mail.settings.server = 'logging' or 'smtp.gmail.com:587' # your SMTP server
-mail.settings.sender = 'you@gmail.com' # your email
-mail.settings.login = 'username:password' # your credentials or None
-
-auth.settings.hmac_key = 'sha512:d72f56b3-ca0d-4239-993d-c5f18cdea8c4' # before define_tables()
-auth.define_tables() # creates all needed tables
-auth.settings.mailer = mail # for user email verification
-auth.settings.registration_requires_verification = False
-auth.settings.registration_requires_approval = False
-auth.messages.verify_email = 'Click on the link http://'+request.env.http_host+URL(r=request,c='default',f='user',args=['verify_email'])+'/%(key)s to verify your email'
-auth.settings.reset_password_requires_verification = True
-auth.messages.reset_password = 'Click on the link http://'+request.env.http_host+URL(r=request,c='default',f='user',args=['reset_password'])+'/%(key)s to reset your password'
-
-#########################################################################
-## If you need to use OpenID, Facebook, MySpace, Twitter, Linkedin, etc.
-## register with janrain.com, uncomment and customize following
-# from gluon.contrib.login_methods.rpx_account import RPXAccount
-# auth.settings.actions_disabled=['register','change_password','request_reset_password']
-# auth.settings.login_form = RPXAccount(request, api_key='...',domain='...',
-# url = "http://localhost:8000/%s/default/user/login" % request.application)
-## other login methods are in gluon/contrib/login_methods
-#########################################################################
-
-crud.settings.auth = None # =auth to enforce authorization on crud
-
-#########################################################################
-## Define your tables below (or better in another model file) for example
-##
-## >>> db.define_table('mytable',Field('myfield','string'))
-##
-## Fields can be 'string','text','password','integer','double','boolean'
-## 'date','time','datetime','blob','upload', 'reference TABLENAME'
-## There is an implicit 'id integer autoincrement' field
-## Consult manual for more options, validators, etc.
-##
-## More API examples for controllers:
-##
-## >>> db.mytable.insert(myfield='value')
-## >>> rows=db(db.mytable.myfield=='value').select(db.mytable.ALL)
-## >>> for row in rows: print row.id, row.myfield
-#########################################################################
+service = Service()
+crud = Crud(db)
person = db.define_table('person',
Field('name'),
@@ -84,7 +24,6 @@
person.name.requires = IS_NOT_EMPTY()
person.email.requires = IS_NULL_OR(IS_EMAIL())
-
favorite_music = db.define_table('favorite_music',
Field('person', person),
Field('title'),
View
10 models/menu.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-response.title = 'Plugin appreport'
+response.title = 'web2py-appreport'
response.subtitle = T('customize me!')
#http://dev.w3.org/html5/markup/meta.name.html
@@ -21,10 +21,10 @@
]
response.menu+=[
- (T('Repors'), False, URL(request.application,'default','index'), [
- ('Simple', False, URL(r=request, c='person', f='simple_report')),
- ('Custon', False, URL(r=request, c='person', f='custom_report')),
- ('Complex', False, URL(r=request, c='person', f='complex_report')),
+ (T('Reports'), False, URL(request.application,'default','index'), [
+ ('Simple - automatically generates html', False, URL(r=request, c='person', f='simple_report')),
+ ('Custon - static html', False, URL(r=request, c='person', f='custom_report')),
+ ('Complex - dynamic html (using views)', False, URL(r=request, c='person', f='complex_report')),
])
]
View
143 models/plugin_appreport.py
@@ -1,82 +1,107 @@
# coding: utf8
+import sys
import os.path
-#to start using plugin_appreport in a controller define the following action:
-#para começar a usar o plugin_appreport em um controlador defina o seguinte action:
+if request.folder not in sys.path:
+ sys.path.append(request.folder)
+
+#to start using plugin_appreport in a controller define the following action:
+#def custom_report():
+# return plugin_appreport.REPORTPISA(html = 'your html and css')
#
#def report():
+# #generates a html form to filter the data to be displayed in the report
# form = plugin_appreport.REPORTFORM(db.table_name)
#
# if form.accepts(request.vars, session):
-# return plugin_appreport.REPORT(table = db.table_name, filter = dict(form.vars))
+# #build a report based on table fields (aka auto generates html) and filters informed in form
+# return plugin_appreport.REPORTPISA(table = db.table_name, filter = dict(form.vars))
#
# return dict(form = form)
-#reference to appreport module
-plugin_appreport_appreport = local_import('plugin_appreport.appreport', reload = False)
+import modules.plugin_appreport as plugin_appreport_module
class PluginAppreport:
+ _path_reports = os.path.join(request.folder, 'private/plugin_appreport/reports')
+
def REPORTFORM(self, table):
- """wrapper to module >> appreport.form_report_web2py / class >> FormReportWeb2py / method >> get_form
- """
- dir(plugin_appreport_appreport)
- return plugin_appreport_appreport.form_report.FormReportWeb2py(table = table).get_form()
-
- #TODO add parametro html, se != None chamar classe html ?
- def REPORT(self, table = None, filter = '', html = '', engine = 'pisa', charset = 'utf-8', title = 'Report', orientation = 'P', unit = 'mm', format = 'A4'):
- """wrapper to module >> appreport.report_html_db_web2py / class >> ReportHtmlDbWeb2py / method >> dumps
-
- Note: arg "title, orientation, unit and format" are used only by engine pyfpdf
-
- table = db.table
- filter = dict(form.vars) or {'table_name.field_name':'value', 'table_name.field2_name':'value2'}
- title = 'title of report'
- html = html custom if given the report will be generated as html passed, ignoring the table definition, example:
- <html>
- <body>
- <table>
- <thead>
- <tr>
- <th>Id</th>
- <th>Name</th>
- <th>Phone</th>
- <th>Email</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td>1</td>
- <td>lucas davila</td>
- <td>123455</td>
- <td>lucassdvl@gmail.com</td>
- </tr>
- </tbody>
- </table>
- </body>
- </html>
+ return plugin_appreport_module.form_report_web2py.FormReportWeb2py(table = table).get_form()
-
- Orientation: 'P' for portrait (retrato) or 'L' for landscape (paisagem)
-
- """
-
- user_name = auth.user.first_name if auth.user is not None else ''
- path_reports = os.path.join(request.folder, 'private/plugin_appreport/reports')
-
- if html.strip() != '':
- report = plugin_appreport_appreport.report.ReportHtml(user_name = user_name,
- title = title, html = html, orientation = orientation, unit = unit, format = format, charset = charset)
- else:
- report = plugin_appreport_appreport.report.ReportHtmlDbWeb2py(table = table, filter = filter, user_name = user_name, title = title, orientation = orientation, unit = unit, format = format, charset = charset)
+# def REPORT(self, table = None, filter = '', html = '', engine = 'pisa', charset = 'utf-8', title = 'Report', orientation = 'P', unit = 'mm', format = 'A4'):
+ def REPORT(self, **kargs):
+
+ engine = kargs.get('engine', 'pyfpdf')
if engine == 'pisa':
- pdf_builder = plugin_appreport_appreport.pdf_builder.PdfBuilderPisa(report = report)
+ return REPORTPISA(**kargs)
+ elif engine == 'pyfpdf':
+ return REPORTPYFPDF(**kargs)
else:
- pdf_builder = plugin_appreport_appreport.pdf_builder.PdfBuilderPyfpdf(report = report)
-
- return plugin_appreport_appreport.report_factory.ReportFactoryWeb2py(response = response, request = request, path_reports = path_reports, pdf_builder = pdf_builder).dumps(report = report)
+ raise NotImplementedError("Invalid engine: '%s', try use 'pisa' or 'pyfpdf'"%engine)
+
+
+ def _fix_kargs(self, kargs):
+ if not kargs.get('user_name'):
+ kargs.update({'user_name' : auth.user.first_name if 'auth' in globals() and auth.user is not None else ''})
+ return kargs
+
+
+ def _get_report_instance(self, kargs):
+ if kargs.get('html', '').strip() != '':
+ return plugin_appreport_module.libs.appreport.report.ReportHtml(**kargs)
+ else:
+ return plugin_appreport_module.report_web2py.ReportHtmlDbWeb2py(**kargs)
+
+
+ def REPORTPISA(self, **kargs):
+ """
+
+ You can pass the html manually *or* pass a table and a filter to automatically generate the html (based on table field and filtered using the filter :P )
+
+ Argument types:
+ - filter (or args): dict(form.vars) or {'table_name.field_name':'value', 'table_name.field2_name':'value2'}
+ - table: db.your_table
+ - html: string containing html and css
+
+ Note:
+ -if you pass the html (aka != '') the report will be generated manually using html *ignoring* the table and filter
+
+ """
+ kargs = self._fix_kargs(kargs)
+ pdf_builder = plugin_appreport_module.libs.appreport.pdf_builder.PdfBuilderPisa(report = self._get_report_instance(kargs))
+ return self.__build_report(self._path_reports, pdf_builder)
+
+
+ def REPORTPYFPDF(self, **kargs):
+ """
+
+ You can pass the html manually *or* pass a table and a filter to automatically generate the html (based on table field and filtered using the filter :P )
+
+ Argument types:
+ - filter (or args): dict(form.vars) or {'table_name.field_name':'value', 'table_name.field2_name':'value2'}
+ - table: db.your_table
+ - html: string containing html
+
+ Arguments supported by pyfpdf:
+ - charset = 'utf-8'
+ - title = 'title of report'
+ - orientation = 'P' (for portrait (retrato)) or ('L' for landscape (paisagem))
+ - unit = 'mm'
+ - format = 'A4'
+
+ Notes:
+ - if you pass the html (aka != '') the report will be generated manually using html *ignoring* the table and filters
+ - css are not supported in pyfpdf, to customize the report, see the arguments explanation below
+ """
+ kargs = self._fix_kargs(kargs)
+ pdf_builder = plugin_appreport_module.libs.appreport.pdf_builder.PdfBuilderPyfpdf(report = self._get_report_instance(kargs))
+ return self.__build_report(self._path_reports, pdf_builder)
+
+
+ def __build_report(self, path_reports, pdf_builder):
+ return plugin_appreport_module.report_factory_web2py.ReportFactoryWeb2py(response = response, request = request, path_reports = path_reports, pdf_builder = pdf_builder).dumps()
plugin_appreport = PluginAppreport()
View
3 modules/plugin_appreport/__init__.py
@@ -0,0 +1,3 @@
+import form_report_web2py
+import report_web2py
+import report_factory_web2py
View
85 modules/plugin_appreport/form_report_web2py.py
@@ -0,0 +1,85 @@
+# -*- coding: utf-8 -*-
+
+"""
+Copyright (c) 2010, 2011 Lucas D'Avila - email lucassdvl@gmail.com / twitter @lucadavila
+
+This file is part of appreport.
+
+appreport is free software: you can redistribute it and/or modify
+it under the terms of the GNU Lesser General Public License (LGPL v3) as published by
+the Free Software Foundation, on version 3 of the License.
+
+appreport is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with appreport. If not, see <http://www.gnu.org/licenses/>.
+"""
+
+from gluon.html import *
+from gluon.http import *
+from gluon.validators import *
+from gluon.sqlhtml import *
+import utils_web2py
+
+#TODO overwrite class FORM() ?
+class FormReportWeb2py():
+
+ def __init__(self, table, ignore_r = False):
+
+ self.table = table
+ self.ignore_r = ignore_r
+
+ def _get_default_validation(self, field_type):
+
+ default_validations = (dict(field_type = 'date', validation = IS_EMPTY_OR(IS_DATE())),
+ dict(field_type = 'time', validation = IS_EMPTY_OR(IS_TIME())),
+ dict(field_type = 'datetime', validation = IS_EMPTY_OR(IS_DATETIME())),
+ )
+ return [v['validation'] for v in default_validations if v['field_type'] == field_type]
+
+ def get_form(self):
+
+ fields = [f.name for f in self.table if (self.ignore_r or f.readable)]
+ form = FORM(TABLE(), INPUT(_type = 'submit', _value = 'Exibir'))
+
+ list_fields = []
+ for field_name in fields:
+ field = self.table[field_name]
+
+# list_fields.append([LABEL('%s:'%field.label), XML(SQLFORM.widgets.integer.widget(field, ''))])
+ list_fields.append([LABEL('%s:'%field.label), SQLFORM.widgets.string.widget(field, '',
+ _name = '%s.%s'%(self.table._tablename, field_name), requires = self._get_default_validation(field.type))])
+
+ for f in list_fields:
+ #insert rows in table
+ form[0].append(TR(
+ TD(f[0]),
+ TD(f[1])
+ ))
+
+ form.prep_filter = self.prep_filter
+
+ return form
+
+ def prep_filter(self, filter):
+
+ """
+
+ Example use:
+
+ #in a controller define the following action:
+ def complex_report():
+ form = FormReportWeb2py(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 ReportHtml(html = html)
+
+ return dict(form = form)
+ """
+
+ return utils_web2py.UtilsWeb2py().prep_filter(vars = filter, table = self.table)
View
0 modules/plugin_appreport/libs/__init__.py
No changes.
1 modules/plugin_appreport/libs/appreport
@@ -0,0 +1 @@
+Subproject commit f8a59e5958c5341cc78687eb6515f02cc157e161
View
64 modules/plugin_appreport/report_factory_web2py.py
@@ -0,0 +1,64 @@
+# -*- coding: utf-8 -*-
+
+"""
+Copyright (c) 2010, 2011 Lucas D'Avila - email lucassdvl@gmail.com / twitter @lucadavila
+
+This file is part of appreport.
+
+appreport is free software: you can redistribute it and/or modify
+it under the terms of the GNU Lesser General Public License (LGPL v3) as published by
+the Free Software Foundation, on version 3 of the License.
+
+appreport is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with appreport. If not, see <http://www.gnu.org/licenses/>.
+"""
+
+import os.path
+import datetime
+from libs.appreport.report_factory import ReportFactory
+
+class ReportFactoryWeb2py(ReportFactory):
+
+ def __init__(self, response, **kargs):
+ """
+ pdf_builder: instance of PdfBuilder* class
+ """
+
+ self.response = response
+ ReportFactory.__init__(self, **kargs)
+
+
+ def _get_path_report(self, report):
+ t = datetime.datetime.now().strftime('%Y%m%d-%H%M%S')
+ return os.path.join(self.path_reports, 'report_%s_%s_%s.pdf'%(report.get('table', report.get('view_name','')), report.get('user_name', ''), t))
+
+
+ def dumps(self, report = None):
+ """
+ report: instance of ReportHtml class
+ """
+
+ if not report:
+ report = self.pdf_builder.report
+
+ if not os.path.exists(self.path_reports):
+ os.makedirs(self.path_reports)
+
+ path_report = self._get_path_report(report = report)
+
+ self.pdf_builder.output(path_report, 'F')
+
+ file_report = open(path_report,"rb").read()
+
+ if path_report.endswith('.pdf'):
+ os.unlink(path_report)
+
+ self.response.headers['Content-Type']='application/pdf'
+ self.response.headers['Content-Disposition'] = 'attachment; filename=%s'%os.path.basename(path_report)
+
+ return file_report #return response.stream(path_report)
View
26 modules/plugin_appreport/report_web2py.py
@@ -0,0 +1,26 @@
+# coding: utf8
+
+from gluon.html import *
+from gluon.http import *
+from gluon.validators import *
+from gluon.sqlhtml import *
+
+import utils_web2py
+from libs.appreport.report import ReportHtmlDb
+
+class ReportHtmlDbWeb2py(ReportHtmlDb):
+
+ def __init__(self, table, **kargs):
+ ReportHtmlDb.__init__(self, db = table._db, table = table, **kargs)
+
+
+ def _get_args(self):
+ return utils_web2py.UtilsWeb2py().prep_filter(vars = self.get('args', {}), table = self.get('table'))
+
+
+ def get_html(self):
+ #TODO: se records < 1 então exibir mensagem sem dados para exibir ?
+ records = self.db(self._get_args()).select()
+ return '<html><head><meta charset="%s" /></head>%s</html>'%(self.get('charset', 'utf-8'), BODY(H2(self.get('title', 'Report')),SQLTABLE(records, headers='fieldname:capitalize')))
+
+
View
64 modules/plugin_appreport/utils_web2py.py
@@ -0,0 +1,64 @@
+# -*- coding: utf-8 -*-
+
+"""
+Copyright (c) 2010, 2011 Lucas D'Avila - email lucassdvl@gmail.com / twitter @lucadavila
+
+This file is part of appreport.
+
+appreport is free software: you can redistribute it and/or modify
+it under the terms of the GNU Lesser General Public License (LGPL v3) as published by
+the Free Software Foundation, on version 3 of the License.
+
+appreport is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with appreport. If not, see <http://www.gnu.org/licenses/>.
+"""
+
+class UtilsWeb2py:
+
+ def __get_name_field(self, filter):
+ #caso possua '.' (no caso de tabela.field) desconsidera o valor anterior ao '.'
+ return filter.split('.')[1] if filter.find('.') > -1 else filter
+
+ def __get_type_field(self, name, table):
+ return table[name].type
+
+ def prep_filter(self, table, vars = {}):
+ """ Prepara um filtro (where) para seleção no banco de dados, conforme vars de um form.
+
+ Exemplo form com campo Id e valor 1,
+ prepara o filtro <table>.id == 1
+
+ vars: dict(form.vars)
+ table: db.mytaable
+
+
+ """
+ db = table._db
+ s = ''
+ i = 0
+ for f in vars:
+ v = vars[f]
+
+ #if value not empty
+ if (isinstance(v, str) and v.strip() != '') or (not isinstance(v, str) and v is not None):
+
+ #add quotes
+ if self.__get_type_field(name = self.__get_name_field(filter = f), table = table) in \
+ ('string', 'text', 'date', 'datetime'):
+ v = '"%s"'%v
+
+ and_ = ' & ' if s.strip() != '' and len(vars) > 1 and i <= len(vars) -1 else ''
+ s += '%s(db.%s == %s)'%(and_, f, v)
+ i += 1
+
+ if s.strip() != '':
+ exec('f = %s'%s)
+ else:
+ #if empty set default filter
+ f = table.id > 0
+ return f
View
BIN static/web2py.plugin.appreport.w2p
Binary file not shown.
View
4 views/default/about.html
@@ -1,13 +1,13 @@
{{extend 'layout.html'}}
<h2>{{=T('About this app')}}</h2>
-<div>The 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.</div>
+<div>The web2py-appreport (old 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.</div>
<br />
<h2>{{=T('Repositories')}}</h2>
<div>appreport <a href="https://github.com/lucasdavila/appreport">on github</a><br />
-plugin appreport for web2py <a href="https://github.com/lucasdavila/plugin-appreport">on github</a></div>
+web2py-appreport for web2py <a href="https://github.com/lucasdavila/web2py-appreport">on github</a></div>
<br />
View
99 views/default/index.html
@@ -1,97 +1,16 @@
{{extend 'layout.html'}}
-<h2>Download</h2>
-<ul>
- <li>Download the local version of plugin <a href={{=URL('static', 'web2py.plugin.appreport.w2p')}}>here</a>.</li>
- <li>Or download the latest version <a href="https://github.com/downloads/lucasdavila/plugin-appreport/web2py.plugin.appreport.w2p">here</a>.</li>
-</ul>
+<h2>Discover</h2>
+<iframe src="http://player.vimeo.com/video/18601633?byline=0&amp;portrait=0" width="640" height="320" frameborder="0"></iframe>
-<h2>Demo</h2>
+<h2>Start</h2>
<ul>
- <li>Screencast <a href="">#TODO add link screencast</a>.</li>
- </li>
+ <li>Download the latest version <a href="https://github.com/downloads/lucasdavila/web2py-appreport/web2py.plugin.appreport.w2p">here</a></li>
+ <li>Or pack the plugin contained in this application <a href="{{='http://127.0.0.1:8000/admin/default/pack_plugin/%s/appreport'%request.application}}">admin</a>.</li>
</ul>
-<h2>Docs</h2>
+<h2>Documentation</h2>
<ul>
- <li>You can access the menus above to verify the functioning of the plugin in conjunction with the sources files, available in this app.</li>
- <li>Or read the instructions below:</li>
-</ul>
- <br />
-
-The plugin appreport, has two helpers, one called REPORTFORM, and another called REPORT.
- <ul>
- <li>The REPORTFORM helper generates an HTML form for emission of the report, based on the definition of the database table, passed in the argument.</li>
-
- <li>The helper REPORT generates a PDF report based on the table from the database and the variables of the form of emission (filter) passed in the arguments, but the helper REPORT, can also generate reports more complex PDF without the need to set a table, based in the custom html code passed in the arguments (in cases where it is past the table and html, the report will be issued based on html, ignoring the definition of the table.).
- </li>
-
- </ul>
- </p>
-
- <h3>Helper REPORTFORM and REPORT for simple reports</h3>
- <ol>
- <li>Download the plugin appreport</li>
- <li>Create a new app called reports</li>
- <li>Import the plugin in your app appreport</li>
- <li>Set the following table in models / db.py:
- <pre>
- person = db.define_table('person',
- Field('name'),
- Field('phone'),
- Field('email'))
- </pre>
- </li>
-
- <li>Define the following action in controllers / default.py (remember of indentations, absents in the example):
- <pre>
- def report():
- form = plugin_appreport.REPORTFORM(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)
- </pre>
- </li>
-
- <li>Visit the link <a href="http://127.0.0.1:8000\reports\default\report">127.0.0.1:8000\reports\default\report</a></li>
- </ol>
-
- <br />
- <h3>HREPORT Helper for reports customized or complex</h3>
- <ol>
- <li>Repeat steps 1, 2, 3 and 4 of the above example.</li>
-
- <li>Define the following action in controllers / default.py (remember of indentations, absents in the example):
- <pre>
-def custom_report():
-
- html = """
-&lthtml&gt
- &ltbody&gt
- &lttable&gt
- &ltthead&gt
- &lttr&gt
- &ltth&gtAuthor&lt/th&gt
- &ltth&gtEmail&lt/th&gt
- &ltth&gtTwitter&lt/th&gt
- &lt/tr&gt
- &lt/thead&gt
- &lttbody&gt
- &lttr&gt
- &lttd&gtLucas Davila&lt/td&gt
- &lttd&gtlucassdvl@gmail.com&lt/td&gt
- &lttd&gt@lucadavila&lt/td&gt
- &lt/tr&gt
- &lt/tbody&gt
- &lt/table&gt
- &lt/body&gt
- &lt/html&gt
- """
- return plugin_appreport.REPORT(html = html, title = 'my custom report using the plugin appreport')
- </pre>
- </li>
-
- <li>Visit the link <a href="http://127.0.0.1:8000\reports\default\custom_report">127.0.0.1:8000\reports\default\custom_report</a></li>
- </ol>
+ <li><a href="https://github.com/lucasdavila/web2py-appreport/wiki/Docs-and-examples">Wiki</a> on github</li>
+ <li>#todo more docs</li>
+</ul>
View
4 views/person/report_persons.html
@@ -6,7 +6,7 @@
</head>
<body>
- <h2>Report of persons relatório</h2>
+ <h2>Report of persons</h2>
<table border="0">
<thead>
@@ -37,7 +37,7 @@
<td>{{=m.artist}}</td>
</tr>
- {{pass}}
+ {{pass}}
{{pass}}
</tbody>
</table>
View
BIN views/reports/jasper/portabilis_relacao_alunos_por_turma.jasper
Binary file not shown.
View
BIN views/reports/jasper/report_teste.jasper
Binary file not shown.
View
53 views/reports/jasper/report_teste.jrxml
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="report_teste" language="groovy" pageWidth="842" pageHeight="595" orientation="Landscape" whenNoDataType="AllSectionsNoDetail" columnWidth="802" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20">
+ <property name="ireport.zoom" value="1.0"/>
+ <property name="ireport.x" value="0"/>
+ <property name="ireport.y" value="0"/>
+ <queryString>
+ <![CDATA[select * from pmieducar.aluno limit 10]]>
+ </queryString>
+ <field name="cod_aluno" class="java.lang.Integer"/>
+ <field name="ref_cod_aluno_beneficio" class="java.lang.Integer"/>
+ <field name="ref_cod_religiao" class="java.lang.Integer"/>
+ <field name="ref_usuario_exc" class="java.lang.Integer"/>
+ <field name="ref_usuario_cad" class="java.lang.Integer"/>
+ <field name="ref_idpes" class="java.lang.Integer"/>
+ <field name="data_cadastro" class="java.sql.Timestamp"/>
+ <field name="data_exclusao" class="java.sql.Timestamp"/>
+ <field name="ativo" class="java.lang.Integer"/>
+ <field name="caminho_foto" class="java.lang.String"/>
+ <field name="analfabeto" class="java.lang.Integer"/>
+ <field name="nm_pai" class="java.lang.String"/>
+ <field name="nm_mae" class="java.lang.String"/>
+ <field name="tipo_responsavel" class="java.lang.String"/>
+ <background>
+ <band splitType="Stretch"/>
+ </background>
+ <title>
+ <band height="51" splitType="Stretch"/>
+ </title>
+ <pageHeader>
+ <band height="35" splitType="Stretch"/>
+ </pageHeader>
+ <columnHeader>
+ <band height="23" splitType="Stretch"/>
+ </columnHeader>
+ <detail>
+ <band height="41" splitType="Stretch">
+ <textField>
+ <reportElement x="68" y="10" width="100" height="20"/>
+ <textElement/>
+ <textFieldExpression class="java.lang.Integer"><![CDATA[$F{cod_aluno}]]></textFieldExpression>
+ </textField>
+ </band>
+ </detail>
+ <columnFooter>
+ <band height="45" splitType="Stretch"/>
+ </columnFooter>
+ <pageFooter>
+ <band height="54" splitType="Stretch"/>
+ </pageFooter>
+ <summary>
+ <band height="42" splitType="Stretch"/>
+ </summary>
+</jasperReport>

0 comments on commit 14ee249

Please sign in to comment.
Something went wrong with that request. Please try again.