Changeset 10596 for main


Ignore:
Timestamp:
7 Sep 2013, 04:19:27 (11 years ago)
Author:
Henrik Bettermann
Message:

Add QR code on application slip (experimental).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/applicants/pdf.py

    r10333 r10596  
    2727from waeup.kofa.browser import DEFAULT_PASSPORT_IMAGE_PATH
    2828from waeup.kofa.browser.interfaces import IPDFCreator
    29 from waeup.kofa.browser.pdf import SMALL_PARA_STYLE, ENTRY1_STYLE
     29from waeup.kofa.browser.pdf import SMALL_PARA_STYLE, ENTRY1_STYLE, get_qrcode
    3030from waeup.kofa.interfaces import IExtFileStore, IPDF, IKofaUtils
    3131from waeup.kofa.interfaces import MessageFactory as _
     
    131131        data.append(Spacer(1, 5))
    132132
    133         # create two-column header table
     133        # create three-column header table
    134134        # append photograph to the left
    135135        img_path = getattr(
     
    139139        table_left = Table(data_left,style=SLIP_STYLE)
    140140
    141         # append column-two fields to the right
     141        # append base data table to the middle
    142142        fields = [
    143143            field for field in self.form_fields
    144144                if field.__name__ in self.column_two_fields]
    145         table_right = creator.getWidgetsTable(
     145        table_middle = creator.getWidgetsTable(
    146146            fields, self.context, None, lang=portal_language,
    147             separators=None, colWidths=[5*cm, 6*cm])
    148         header_table = Table([[table_left, table_right],],style=SLIP_STYLE)
     147            separators=None, colWidths=[5*cm, 4.5*cm])
     148
     149        # append QR code to the right
     150        if view is not None:
     151            url = view.url(self.context, 'application_slip.pdf')
     152            data_right = [[get_qrcode(url, width=70.0)]]
     153            table_right = Table(data_right,style=SLIP_STYLE)
     154        else:
     155            table_right = None
     156
     157        header_table = Table(
     158            [[table_left, table_middle, table_right],],style=SLIP_STYLE)
    149159        data.append(header_table)
    150160
Note: See TracChangeset for help on using the changeset viewer.