This is a widget for date/time fields on **Geraldo Reports**.
When you use Geraldo to write reports, date/time fields must be formatted using **get_value** lambda attribute, because ObjectValue doesn't know what mask you want to use.
With this widget, you just copy it into a common use Python file, import into your reports file and use it replacing ObjectValue on elements for fields you must be formatted as date/time format.
**Example:**
from geraldo import Report, ReportBand, ObjectValue, landscape
from utils.reports import DateTimeObjectValue
class ReportPhoneList(Report):
title = u'Phone List'
page_size = landscape(A4)
class band_detail(ReportBand):
height = 0.5*cm
elements = [
ObjectValue(attribute_name='id', top=0.1*cm),
DateTimeObjectValue(attribute_name='birth_date',
left=26.2*cm, top=0.1*cm, format='%m/%d/%Y'),
]
This is a widget for decimal/money/currency fields on **Geraldo Reports**.
When you use Geraldo to write reports, decimal fields must be formatted using **get_value** lambda attribute, because ObjectValue doesn't know what mask you want to use.
With this widget, you just copy it into a common use Python file, import into your reports file and use it replacing ObjectValue on elements for fields you must be formatted as money format.
**Example:**
from geraldo import Report, ReportBand, ObjectValue
from utils.reports import DecimalObjectValue
class ReportCustomers(Report):
title = u'Customers List'
page_size = A4
class band_detail(ReportBand):
height = 0.5*cm
elements = [
ObjectValue(attribute_name='id', top=0.1*cm),
DecimalObjectValue(attribute_name='salary',
left=26.2*cm, top=0.1*cm, format='%0.03f'),
]
If you would like to see the latest queries you have done when running a unittest, this is not so easy. You have to initialize the queries list and set DEBUG to True manually. Then you have to figure out a way to print the queries you want to see just now and format them. I.e., monitoring queries when doing TDD is a bit of a hassle, and this should help.
This little helper does all this for you; your UnitTest only needs to import django.db.connection and store the current length (offset) of the queries list. Then, using Python's coroutine functionality, all you have to do is send that offset to the QueryPrinter coroutine (which you can, for example, initialize as a global variable or a class variable of your UnitTest) and you get the latest SQL printed as a simple table.
- queries
- unittest
- debugging
- printing
- for
- connection