Login

Widget for DateTime values on Geraldo Reports

Author:
marinho
Posted:
April 18, 2009
Language:
Python
Version:
1.0
Tags:
geraldo
Score:
0 (after 0 ratings)

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'),
            ]
1
2
3
4
5
6
7
8
9
class DateTimeObjectValue(ObjectValue):
    format = '%m/%d/%Y %H:%M'
    def get_object_value(self, instance=None):
        value = super(DateTimeObjectValue, self).get_object_value(instance)

        if not value:
            return ''

        return value.strftime(self.format)

More like this

  1. Widget for Money values on Geraldo Reports by marinho 5 years, 11 months ago
  2. Creating custom time entries in Django Date widget by adiq 10 months ago
  3. SelectTimeWidget by bradmontgomery 6 years, 4 months ago
  4. CSV to JSON Fixture by briangershon 5 years, 7 months ago
  5. db_dump.py - for dumpping and loading data from database by limodou 8 years, 1 month ago

Comments

Surabhi (on July 12, 2012):

Hi All, Can anyone suggest how to rounded off a number to a near integer value in Geraldo reports. I am unable to do this and could not find any snippets as well. I am using Django with Geraldo report to print PDF reports.

If anyone provide quick response on this appreciated.

Thanks, Surabhi

#

Please login first before commenting.