Changeset 9916 for main/waeup.kofa/trunk


Ignore:
Timestamp:
27 Jan 2013, 15:08:16 (12 years ago)
Author:
uli
Message:

Render signatures below each other if there are more than three of it.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/students/utils.py

    r9913 r9916  
    203203
    204204def get_signature_table(signatures, lang='en'):
    205     """Return a reportlab table containing signature fields (with date).
     205    """Return a list of one or more reportlab tables with signature fields.
     206
     207    Each signature will get a date field.
     208
     209    If more than three signatures have to be rendered, instead of a
     210    list with one table a list of tables with one signature field each
     211    will be returned.
    206212    """
    207213    style = getSampleStyleSheet()
     
    220226        ('TOPPADDING', (0,-1), (-1,-1), 0),
    221227        ]
    222     for num, elem in enumerate(signatures):
    223         # draw a line above each signature cell (not: empty cells in between)
    224         sig_style.append(
    225             ('LINEABOVE', (num*2,-1), (num*2, -1), 1, colors.black))
     228
     229    col_widths = [sig_col_width*cm, space_width*cm] * len(signatures)
     230    if len(signatures) == 1 or len(signatures) > 3:
     231        col_widths = [table_width*0.66*cm, table_width*0.34*cm]
    226232
    227233    row = []
    228     for signature in signatures:
    229         row.append(Paragraph(trans(_('Date:'), lang), ENTRY1_STYLE))
    230         row.append('')
    231         if len(signatures) > 1:
    232             col_widths.extend([sig_col_width*cm, space_width*cm])
    233         else:
    234             col_widths.extend([sig_col_width/2*cm, sig_col_width/2*cm])
    235             row.append('') # empty spaceholder on right
    236     data.append(row[:-1])
    237     data.extend(([''],)*2) # insert 2 empty rows...
    238     row = []
    239     for signature in signatures:
    240         row.append(Paragraph(trans(signature, lang), ENTRY1_STYLE))
    241         row.append('')
    242     data.append(row[:-1])
     234    if len(signatures) < 4:
     235        # draw several signature fields in a row
     236        for num, signature in enumerate(signatures):
     237            # draw a line above each signature cell (not: empty cells
     238            # in between)
     239            sig_style.append(
     240                ('LINEABOVE', (num*2,-1), (num*2, -1), 1, colors.black))
     241            row.append(Paragraph(trans(_('Date:'), lang), ENTRY1_STYLE))
     242            row.append('') # space col
     243        data.append(row[:-1])
     244        data.extend(([''],)*2) # insert 2 empty rows...
     245        row = []
     246        for signature in signatures:
     247            row.append(Paragraph(trans(signature, lang), ENTRY1_STYLE))
     248            row.append('')
     249        data.append(row[:-1])
     250    else:
     251        # Draw each signature field one under another (vertically)
     252        for num, signature in enumerate(signatures):
     253            line = (num - 1) * 2
     254            sig_style.extend((
     255                ('TOPPADDING', (0, line), (-1, line), 32),
     256                ('BOTTOMPADDING', (0, line), (-1, line), 2),
     257                ('LINEABOVE', (0, line+1), (0, line+1), 1, colors.black),
     258                ('SPAN', (0, line+1), (1, line+1)),
     259                ))
     260            data.append(['', ''])
     261            row.append(Paragraph(trans(signature, lang), ENTRY1_STYLE))
     262            data.append(row)
     263            row = []
    243264    table = Table(data, style=sig_style, repeatRows=len(data),
    244265                  colWidths=col_widths)
     
    355376                return _('Study course data are incomplete.'), None
    356377            if previous_session:
    357                 # Students can pay for previous sessions in all workflow states.
    358                 # Fresh students are excluded by the update method of the
    359                 # PreviousPaymentAddFormPage.
     378                # Students can pay for previous sessions in all
     379                # workflow states.  Fresh students are excluded by the
     380                # update method of the PreviousPaymentAddFormPage.
    360381                if previous_level == 100:
    361382                    amount = getattr(certificate, 'school_fee_1', 0.0)
     
    366387                    amount = getattr(certificate, 'school_fee_1', 0.0)
    367388                elif student.state == RETURNING:
    368                     # In case of returning school fee payment the payment session
    369                     # and level contain the values of the session the student
    370                     # has paid for. Payment session is always next session.
     389                    # In case of returning school fee payment the
     390                    # payment session and level contain the values of
     391                    # the session the student has paid for. Payment
     392                    # session is always next session.
    371393                    p_session, p_level = self.getReturningData(student)
    372394                    academic_session = self._getSessionConfiguration(p_session)
    373395                    if academic_session == None:
    374                         return _(u'Session configuration object is not available.'), None
     396                        return _(
     397                            u'Session configuration object is not available.'
     398                            ), None
    375399                    amount = getattr(certificate, 'school_fee_2', 0.0)
    376400                elif student.is_postgrad and student.state == PAID:
    377                     # Returning postgraduate students also pay for the next session
    378                     # but their level always remains the same.
     401                    # Returning postgraduate students also pay for the
     402                    # next session but their level always remains the
     403                    # same.
    379404                    p_session += 1
    380405                    academic_session = self._getSessionConfiguration(p_session)
    381406                    if academic_session == None:
    382                         return _(u'Session configuration object is not available.'), None
     407                        return _(
     408                            u'Session configuration object is not available.'
     409                            ), None
    383410                    amount = getattr(certificate, 'school_fee_2', 0.0)
    384411        elif category == 'clearance':
     
    554581        """Render pdf slips for various pages.
    555582        """
     583        # XXX: tell what the different parameters mean
    556584        style = getSampleStyleSheet()
    557585        creator = getUtility(IPDFCreator)
Note: See TracChangeset for help on using the changeset viewer.