Changeset 9456 for main/waeup.uniben
- Timestamp:
- 29 Oct 2012, 12:48:24 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.uniben/trunk/src/waeup/uniben/students/utils.py
r9346 r9456 180 180 return None, payment 181 181 182 def renderPDF(self, view, filename='slip.pdf', student=None, 183 studentview=None, tableheader=None, tabledata=None, 184 note=None, signatures=None): 185 """Render pdf slips for various pages. 186 """ 187 # XXX: we have to fix the import problems here. 188 from waeup.kofa.browser.interfaces import IPDFCreator 189 from waeup.kofa.browser.pdf import NORMAL_STYLE, ENTRY1_STYLE 190 style = getSampleStyleSheet() 191 creator = getUtility(IPDFCreator) 192 data = [] 193 doc_title = view.label 194 author = '%s (%s)' % (view.request.principal.title, 195 view.request.principal.id) 196 footer_text = view.label 197 if getattr(student, 'student_id', None) is not None: 198 footer_text = "%s - %s - " % (student.student_id, footer_text) 199 200 # Insert student data table 201 portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE 202 if student is not None: 203 bd_translation = trans(_('Base Data'), portal_language) 204 data.append(Paragraph(bd_translation, style["Heading3"])) 205 data.append(render_student_data(studentview)) 206 207 # Insert widgets 208 if view.form_fields: 209 data.append(Paragraph(view.title, style["Heading3"])) 210 portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE 211 separators = getattr(self, 'SEPARATORS_DICT', {}) 212 table = creator.getWidgetsTable( 213 view.form_fields, view.context, None, lang=portal_language, 214 separators=separators) 215 data.append(table) 216 217 # Insert scanned docs 218 data.extend(docs_as_flowables(view, portal_language)) 219 220 # Insert content table (optionally on second page) 221 if tabledata and tableheader: 222 #data.append(PageBreak()) 223 data.append(Spacer(1, 20)) 224 data.append(Paragraph(view.content_title, style["Heading3"])) 225 contenttable = render_table_data(tableheader,tabledata) 226 data.append(contenttable) 227 228 # Insert signatures 229 if signatures: 230 data.append(Spacer(1, 20)) 231 signaturetable = get_signature_table(signatures) 232 data.append(signaturetable) 233 234 # Insert history 235 if filename.startswith('clearance') or filename.startswith('course'): 236 hist_translation = trans(_('Workflow History'), portal_language) 237 data.append(Paragraph(hist_translation, style["Heading3"])) 238 data.extend(creator.fromStringList(student.history.messages)) 239 240 view.response.setHeader( 241 'Content-Type', 'application/pdf') 242 try: 243 pdf_stream = creator.create_pdf( 244 data, None, doc_title, author=author, footer=footer_text, 245 note=note) 246 except IOError: 247 view.flash('Error in image file.') 248 return view.redirect(view.url(view.context)) 249 return pdf_stream 250 182 251 # Uniben prefix 183 252 STUDENT_ID_PREFIX = u'B'
Note: See TracChangeset for help on using the changeset viewer.