Ignore:
Timestamp:
19 Feb 2013, 12:11:33 (12 years ago)
Author:
Henrik Bettermann
Message:

Use get_signature_tables instead of the old function get_signature_table. Code is not yet functionally tested.

File:
1 edited

Legend:

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

    r9957 r9965  
    3535from waeup.kofa.students.interfaces import IStudentsUtils
    3636from waeup.kofa.browser.pdf import (
    37     ENTRY1_STYLE, format_html, NOTE_STYLE, HEADING_STYLE)
     37    ENTRY1_STYLE, format_html, NOTE_STYLE, HEADING_STYLE,
     38    get_signature_tables)
    3839from waeup.kofa.browser.interfaces import IPDFCreator
    3940
     
    201202    table = Table(data,colWidths=[
    202203        element[2]*cm for element in tableheader], style=CONTENT_STYLE)
    203     return table
    204 
    205 def get_signature_table(signatures, lang='en'):
    206     """Return a list of one or more reportlab tables with signature fields.
    207 
    208     Each signature will get a date field.
    209 
    210     If more than three signatures have to be rendered, instead of a
    211     list with one table a list of tables with one signature field each
    212     will be returned.
    213     """
    214     style = getSampleStyleSheet()
    215     space_width = 0.4  # width in cm of space between signatures
    216     table_width = 16.0 # supposed width of signature table in cms
    217     # width of signature cells in cm...
    218     sig_col_width = table_width - ((len(signatures) - 1) * space_width)
    219     sig_col_width = sig_col_width / len(signatures)
    220     data = []
    221     col_widths = [] # widths of columns
    222 
    223     sig_style = [
    224         ('VALIGN',(0,-1),(-1,-1),'TOP'),
    225         #('FONT', (0,0), (-1,-1), 'Helvetica-BoldOblique', 12),
    226         ('BOTTOMPADDING', (0,0), (-1,0), 36),
    227         ('TOPPADDING', (0,-1), (-1,-1), 0),
    228         ]
    229 
    230     col_widths = [sig_col_width*cm, space_width*cm] * len(signatures)
    231     if len(signatures) == 1 or len(signatures) > 3:
    232         col_widths = [table_width*0.66*cm, table_width*0.34*cm]
    233 
    234     row = []
    235     if len(signatures) < 4:
    236         # draw several signature fields in a row
    237         for num, signature in enumerate(signatures):
    238             # draw a line above each signature cell (not: empty cells
    239             # in between)
    240             sig_style.append(
    241                 ('LINEABOVE', (num*2,-1), (num*2, -1), 1, colors.black))
    242             row.append(Paragraph(trans(_('Date:'), lang), ENTRY1_STYLE))
    243             row.append('') # space col
    244         data.append(row[:-1])
    245         data.extend(([''],)*2) # insert 2 empty rows...
    246         row = []
    247         for signature in signatures:
    248             row.append(Paragraph(trans(signature, lang), ENTRY1_STYLE))
    249             row.append('')
    250         data.append(row[:-1])
    251     else:
    252         # Draw each signature field one under another (vertically)
    253         for num, signature in enumerate(signatures):
    254             line = len(data)
    255             sig_style.extend((
    256                 ('TOPPADDING', (0, line), (-1, line), 32),
    257                 ('BOTTOMPADDING', (0, line), (-1, line), 2),
    258                 ('LINEABOVE', (0, line+1), (0, line+1), 1, colors.black),
    259                 ('SPAN', (0, line+1), (1, line+1)),
    260                 ))
    261             data.append(['', ''])
    262             row.append(Paragraph(trans(signature, lang), ENTRY1_STYLE))
    263             data.append(row)
    264             row = []
    265     table = Table(data, style=sig_style, repeatRows=len(data),
    266                   colWidths=col_widths)
    267204    return table
    268205
     
    673610
    674611        # Insert signatures
     612        # XXX: We are using only sigs_in_footer in waeup.kofa, so we
     613        # do not have a test for the following lines.
    675614        if signatures and not sigs_in_footer:
    676615            data.append(Spacer(1, 20))
    677             signaturetable = get_signature_table(signatures)
    678             data.append(signaturetable)
     616            signaturetables = get_signature_tables(signatures)
     617            for table in signaturetables:
     618                data.append(table)
    679619
    680620        view.response.setHeader(
Note: See TracChangeset for help on using the changeset viewer.