Changeset 9014 for main/waeup.kofa/trunk
- Timestamp:
- 18 Jul 2012, 07:03:42 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/students/utils.py
r9010 r9014 165 165 return table 166 166 167 def render_signatures(signatures, lang='en'): 167 def get_signature_table(signatures, lang='en'): 168 """Return a reportlab table containing signature fields (with date). 169 """ 168 170 style = getSampleStyleSheet() 171 space_width = 0.4 # width in cm of space between signatures 172 table_width = 16.0 # supposed width of signature table in cms 173 # width of signature cells in cm... 174 sig_col_width = table_width - ((len(signatures) - 1) * space_width) 175 sig_col_width = sig_col_width / len(signatures) 169 176 data = [] 170 datetitle = Paragraph(trans(_('Date:'), lang), style["Normal"]) 171 line = [] 177 col_widths = [] # widths of columns 178 179 sig_style = [ 180 ('VALIGN',(0,-1),(-1,-1),'TOP'), 181 ('FONT', (0,0), (-1,-1), 'Helvetica-BoldOblique', 12), 182 ('BOTTOMPADDING', (0,0), (-1,0), 36), 183 ('TOPPADDING', (0,-1), (-1,-1), 0), 184 ] 185 for num, elem in enumerate(signatures): 186 # draw a line above each signature cell (not: empty cells in between) 187 sig_style.append( 188 ('LINEABOVE', (num*2,-1), (num*2, -1), 1, colors.black)) 189 190 row = [] 172 191 for signature in signatures: 173 line.append(datetitle) 174 data.append(line) 175 line = [] 192 row.append(trans(_('Date:'), lang)) 193 row.append('') 194 if len(signatures) > 1: 195 col_widths.extend([sig_col_width*cm, space_width*cm]) 196 else: 197 col_widths.extend([sig_col_width/2*cm, sig_col_width/2*cm]) 198 row.append('') # empty spaceholder on right 199 data.append(row[:-1]) 200 data.extend(([''],)*3) # insert 3 empty rows... 201 row = [] 176 202 for signature in signatures: 177 signature = Paragraph(trans(signature, lang), style["Normal"]) 178 line.append(signature) 179 data.append(line) 180 table = Table(data, style=SLIP_STYLE) 203 row.append(Paragraph(trans(signature, lang), style["Normal"])) 204 row.append('') 205 data.append(row[:-1]) 206 table = Table(data, style=sig_style, repeatRows=len(data), 207 colWidths=col_widths) 181 208 return table 182 209 … … 399 426 400 427 # Insert signatures 401 if signatures is not None:428 if signatures: 402 429 data.append(Spacer(1, 20)) 403 signaturetable = render_signatures(signatures)430 signaturetable = get_signature_table(signatures) 404 431 data.append(signaturetable) 405 432
Note: See TracChangeset for help on using the changeset viewer.