Changeset 9010
- Timestamp:
- 17 Jul 2012, 08:38:17 (12 years ago)
- Location:
- main/waeup.kofa/trunk/src/waeup/kofa/students
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/students/browser.py
r8983 r9010 470 470 + ' %s' % self.context.display_fullname 471 471 472 def _signatures(self): 473 if self.context.state == CLEARED: 474 return (_('Student Signature'), _('Clearance Officer Signature')) 475 return 476 472 477 def render(self): 473 478 studentview = StudentBaseDisplayFormPage(self.context.student, … … 476 481 return students_utils.renderPDF( 477 482 self, 'clearance.pdf', 478 self.context.student, studentview )483 self.context.student, studentview, signatures=self._signatures()) 479 484 480 485 class StudentClearanceManageFormPage(KofaEditFormPage): -
main/waeup.kofa/trunk/src/waeup/kofa/students/utils.py
r9005 r9010 165 165 return table 166 166 167 def render_signatures(signatures, lang='en'): 168 style = getSampleStyleSheet() 169 data = [] 170 datetitle = Paragraph(trans(_('Date:'), lang), style["Normal"]) 171 line = [] 172 for signature in signatures: 173 line.append(datetitle) 174 data.append(line) 175 line = [] 176 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) 181 return table 182 167 183 def docs_as_flowables(view, lang='en'): 168 184 """Create reportlab flowables out of scanned docs. … … 201 217 data.append(Table(table_data, style=SLIP_STYLE)) 202 218 return data 203 204 def insert_footer(pdf,width,style,text=None, number_of_pages=1):205 """Render the whole footer frame.206 """207 story = []208 frame_footer = Frame(1*cm,0,width-(2*cm),1*cm)209 tz = getUtility(IKofaUtils).tzinfo210 timestamp = now(tz).strftime("%d/%m/%Y %H:%M:%S %Z")211 left_text = '<font size=10>%s</font>' % timestamp212 story.append(Paragraph(left_text, style["Normal"]))213 frame_footer.addFromList(story,pdf)214 story = []215 frame_footer = Frame(1*cm,0,width-(2*cm),1*cm)216 portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE217 right_text = translate(_('<font size=10>${a} Page ${b} of ${c}</font>',218 mapping = {'a':text, 'b':pdf.getPageNumber(), 'c':number_of_pages}),219 'waeup.kofa', target_language=portal_language)220 story.append(Paragraph(right_text, style["Right"]))221 frame_footer.addFromList(story,pdf)222 219 223 220 class StudentsUtils(grok.GlobalUtility): … … 355 352 def renderPDF(self, view, filename='slip.pdf', student=None, 356 353 studentview=None, tableheader=None, tabledata=None, 357 note=None ):354 note=None, signatures=None): 358 355 """Render pdf slips for various pages. 359 356 """ … … 371 368 footer_text = "%s - %s - " % (student.student_id, footer_text) 372 369 370 # Insert history 371 data.extend(creator.fromStringList(student.history.messages)) 372 373 373 # Insert student data table 374 374 portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE … … 397 397 contenttable = render_table_data(tableheader,tabledata) 398 398 data.append(contenttable) 399 400 # Insert signatures 401 if signatures is not None: 402 data.append(Spacer(1, 20)) 403 signaturetable = render_signatures(signatures) 404 data.append(signaturetable) 399 405 400 406 view.response.setHeader(
Note: See TracChangeset for help on using the changeset viewer.