Ignore:
Timestamp:
17 Sep 2019, 07:30:51 (5 years ago)
Author:
Henrik Bettermann
Message:

Do not print picture on application slip if application is without passport picture.

File:
1 edited

Legend:

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

    r14849 r15587  
    140140        data.append(Spacer(1, 5))
    141141
    142         # create three-column header table
    143         # append photograph to the left
    144         img_path = getattr(
    145             getUtility(IExtFileStore).getFileByContext(self.context),
    146             'name', DEFAULT_PASSPORT_IMAGE_PATH)
    147         data_left = [[creator.getImage(img_path)]]
    148         table_left = Table(data_left,style=SLIP_STYLE)
    149 
    150         # append base data table to the middle
    151         fields = [
    152             field for field in self.form_fields
    153                 if field.__name__ in self.column_two_fields]
    154         table_middle = creator.getWidgetsTable(
    155             fields, self.context, None, lang=portal_language,
    156             separators=None, colWidths=[5*cm, 4.5*cm])
    157 
    158         # append QR code to the right
    159         if view is not None:
    160             url = view.url(self.context, 'application_slip.pdf')
    161             data_right = [[get_qrcode(url, width=70.0)]]
    162             table_right = Table(data_right,style=SLIP_STYLE)
     142        if self.context.__parent__.with_picture:
     143
     144            # create three-column header table
     145            # append photograph to the left
     146            img_path = getattr(
     147                getUtility(IExtFileStore).getFileByContext(self.context),
     148                'name', DEFAULT_PASSPORT_IMAGE_PATH)
     149            data_left = [[creator.getImage(img_path)]]
     150            table_left = Table(data_left,style=SLIP_STYLE)
     151
     152            # append base data table to the middle
     153            fields = [
     154                field for field in self.form_fields
     155                    if field.__name__ in self.column_two_fields]
     156            table_middle = creator.getWidgetsTable(
     157                fields, self.context, None, lang=portal_language,
     158                separators=None, colWidths=[5*cm, 4.5*cm])
     159
     160            # append QR code to the right
     161            if view is not None:
     162                url = view.url(self.context, 'application_slip.pdf')
     163                data_right = [[get_qrcode(url, width=70.0)]]
     164                table_right = Table(data_right,style=SLIP_STYLE)
     165            else:
     166                table_right = None
     167
     168            header_table = Table(
     169                [[table_left, table_middle, table_right],],style=SLIP_STYLE)
     170            data.append(header_table)
     171
    163172        else:
    164             table_right = None
    165 
    166         header_table = Table(
    167             [[table_left, table_middle, table_right],],style=SLIP_STYLE)
    168         data.append(header_table)
     173            fields = [
     174                field for field in self.form_fields
     175                    if field.__name__ in self.column_two_fields]
     176            data.append(creator.getWidgetsTable(
     177                fields, self.context, None, lang=portal_language,
     178                separators=None, colWidths=[7*cm, 10*cm]))
    169179
    170180        # append widgets except those already added in column two
     
    195205                    twoDataCols=True))
    196206
     207        # append QR Code if without picture
     208        if not self.context.__parent__.with_picture and view is not None:
     209            data.append(Spacer(1, 5))
     210            url = view.url(self.context, 'application_slip.pdf')
     211            data_right = [[get_qrcode(url, width=70.0)]]
     212            table_right = Table(data_right,style=SLIP_STYLE)
     213            data.append(get_qrcode(url, width=70.0))
     214
    197215        # append login information
    198216        note = None
Note: See TracChangeset for help on using the changeset viewer.