Browse files

Merging model-report

commit 662213177eb52b8ccefed009b7354330a5118635
Author: Alex <aragsdale@schipul.com>
Date:   Mon Nov 26 11:43:27 2012 -0600

    Add pisa and html5lib to setup for django-model-report.

commit c9a169464273e96b69f92684d4c7158679f74dc2
Merge: 51728bb 27d7a13
Author: Alex <aragsdale@schipul.com>
Date:   Mon Nov 26 09:36:07 2012 -0600

    Merge branch 'refs/heads/master' into model-report

commit 51728bbf34fe84de28d6de4226bf8dc91c4694bd
Author: Alex <aragsdale@schipul.com>
Date:   Fri Nov 16 11:43:46 2012 -0600

    Add report totals.

commit aa8fad3e8dce0aeffb581d6bc304330c96f41360
Author: Alex <aragsdale@schipul.com>
Date:   Fri Nov 16 11:29:40 2012 -0600

    Up django-model-report version.

commit 7d5278dabd6733ed6871484b11303bfea2568d81
Author: Alex <aragsdale@schipul.com>
Date:   Fri Nov 16 10:54:38 2012 -0600

    Move some formatting functions into the model report utils and out of the invoice report file.

commit 401283987e324d2c0579d4048ed811c50a274000
Author: Alex <aragsdale@schipul.com>
Date:   Fri Nov 16 10:31:24 2012 -0600

    Update format functions to work with latest version. Add group totals.

commit 4abc5d16a985a118a0bc95ec05d75c70ea590321
Author: Alex <aragsdale@schipul.com>
Date:   Wed Nov 14 16:04:58 2012 -0600

    Remove report totals for now.

commit 43ab8d3d06725aff303432dc963137127ea56c85
Author: Alex <aragsdale@schipul.com>
Date:   Wed Nov 14 14:29:37 2012 -0600

    Change list order by.

commit 2d7cb19f05d02c4d51e7714b196f0662ee541f37
Author: Alex <aragsdale@schipul.com>
Date:   Wed Nov 14 12:35:43 2012 -0600

    Change the object type format and add more total columns.

commit 5575108b1604a95186ca3145647d3bd76ccc759f
Author: Alex <aragsdale@schipul.com>
Date:   Tue Nov 13 16:54:05 2012 -0600

    Format dates and currency better.

commit 2a2b41be4841b5ec8382a67ba84fb90c1f2ff32d
Author: Alex <aragsdale@schipul.com>
Date:   Tue Nov 13 16:00:57 2012 -0600

    Remove title and add id. Format object type and id nicely.

commit a55df817fa7781e76de1aec8ecc3601ad62dcf3c
Author: Alex <aragsdale@schipul.com>
Date:   Tue Nov 13 10:36:12 2012 -0600

    Update to title comment.

commit 7642e40038d514ffcbcd147de520b17e612690a8
Author: Alex <aragsdale@schipul.com>
Date:   Tue Nov 13 10:35:35 2012 -0600

    Added more options to invoices report with comments.

commit a69a16eeb5759c32237bf1cbab1b457f6dd8ae9b
Author: Alex <aragsdale@schipul.com>
Date:   Mon Nov 12 17:12:26 2012 -0600

    Create basic invoices/reports.py.

commit bd35b7876b9124e0c8ac6fd416187e9070d1e428
Author: Alex <aragsdale@schipul.com>
Date:   Mon Nov 12 17:12:12 2012 -0600

    Add model report to settings and urls.

commit c92ce5b97a880992762ef8a56e6bde1f356e3d62
Author: Alex <aragsdale@schipul.com>
Date:   Mon Nov 12 17:11:54 2012 -0600

    Add tendenci fork of django-model-report to setup.py.
  • Loading branch information...
1 parent 6b2b2eb commit 813572f64d718e99ce7076bb815fae576887b74e @eloyz eloyz committed Dec 4, 2012
Showing with 97 additions and 0 deletions.
  1. +4 −0 setup.py
  2. +83 −0 tendenci/apps/invoices/reports.py
  3. +1 −0 tendenci/settings.py
  4. +9 −0 tendenci/urls.py
View
4 setup.py
@@ -129,6 +129,7 @@ def find_package_data(where=".", package="", exclude=standard_exclude,
include_package_data=True,
dependency_links=[
# "http://github.com/tendenci/geraldo/tarball/master#egg=Geraldo-0.4.14",
+ "https://github.com/tendenci/django-model-report/tarball/master#egg=django-model-report-0.0.9",
"http://a.pypi.python.org/",
"http://g.pypi.python.org/",
],
@@ -137,7 +138,9 @@ def find_package_data(where=".", package="", exclude=standard_exclude,
],
install_requires=[
"Django==1.4.2",
+ "pisa",
"Reportlab==2.5",
+ "html5lib",
"PIL==1.1.7",
"South==0.7.3",
"anyjson>=0.2.4",
@@ -181,5 +184,6 @@ def find_package_data(where=".", package="", exclude=standard_exclude,
"django-tastypie",
"johnny-cache==1.4",
"docutils==0.9.1",
+ "django-model-report==0.0.9",
],
)
View
83 tendenci/apps/invoices/reports.py
@@ -0,0 +1,83 @@
+from django.utils.translation import ugettext_lazy as _
+from django.utils.html import mark_safe
+
+from model_report.report import reports, ReportAdmin
+from model_report.utils import (sum_column, us_date_format, date_label, obj_type_format)
+
+from tendenci.apps.invoices.models import Invoice
+from tendenci.core.site_settings.utils import get_setting
+
+
+def id_format(value, instance):
+ invoice = Invoice.objects.get(id=value)
+ link = invoice.get_absolute_url()
+ html = "<a href=\"%s\">%s</a>" % (link, value)
+ return mark_safe(html)
+
+def currency_format(value, instance):
+ currencysymbol = get_setting("site", "global", "currencysymbol")
+ return "%s%s" % (currencysymbol, value)
+
+class InvoiceReport(ReportAdmin):
+ # choose a title for your report for h1, title tag and report list
+ title = _('Invoice Report')
+
+ # specify your model
+ model = Invoice
+
+ # fields in the specified model to display in the report table
+ fields = [
+ 'id',
+ 'bill_to',
+ 'create_dt',
+ 'status_detail',
+ 'object_type',
+ 'payments_credits',
+ 'balance',
+ 'total'
+ ]
+
+ # fields in the model to show filters for
+ list_filter = ('status_detail', 'create_dt',)
+
+ # fields in the model to order results by
+ list_order_by = ('create_dt', 'status_detail')
+
+ # fields to group results by
+ list_group_by = ('object_type',)
+
+ # allowed export formats. default is excel and pdf
+ exports = ('excel', 'pdf',)
+
+ # type = report for report only, type = chart for report and charts. default is report.
+ type = 'report'
+
+ # override field formats by referencing a function
+ override_field_formats = {
+ 'create_dt': us_date_format,
+ 'object_type': obj_type_format,
+ 'id': id_format,
+ 'balance': currency_format,
+ 'total': currency_format,
+ 'payments_credits': currency_format
+ }
+
+ # override the label for a field by referencing a function
+ override_field_labels = {
+ 'create_dt': date_label
+ }
+
+ group_totals = {
+ 'balance': sum_column,
+ 'total': sum_column,
+ 'payments_credits': sum_column
+ }
+
+ report_totals = {
+ 'balance': sum_column,
+ 'total': sum_column,
+ 'payments_credits': sum_column
+ }
+
+# register your report with the slug and name
+reports.register('invoices', InvoiceReport)
View
1 tendenci/settings.py
@@ -179,6 +179,7 @@
'captcha',
'south',
'tastypie',
+ 'model_report',
'tendenci.apps.entities',
'tendenci.core.base',
View
9 tendenci/urls.py
@@ -3,6 +3,7 @@
from django.conf import settings
from django.views.generic.simple import direct_to_template, redirect_to
from django.contrib import admin
+from model_report import report
from tendenci.core.registry import autodiscover as reg_autodiscover
from tendenci.core.newsletters.views import NewsletterGeneratorView
@@ -13,12 +14,20 @@
# load the app_registry
reg_autodiscover()
+# django model report
+report.autodiscover()
+
# Admin Patterns
urlpatterns = patterns('',
(r'^admin/doc/', include('django.contrib.admindocs.urls')),
(r'^admin/', include(admin.site.urls)),
)
+#report patterns
+urlpatterns += patterns('',
+ (r'^model-report/', include('model_report.urls')),
+)
+
# Tendenci Patterns
urlpatterns += patterns('',
url(r'^$', 'tendenci.core.base.views.homepage', name="home"),

0 comments on commit 813572f

Please sign in to comment.