Changeset 9551 for main/waeup.uniben/trunk/src/waeup
- Timestamp:
- 6 Nov 2012, 07:48:28 (12 years ago)
- Location:
- main/waeup.uniben/trunk/src/waeup/uniben/students
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.uniben/trunk/src/waeup/uniben/students/browser.py
r9439 r9551 27 27 from waeup.kofa.students.browser import ( 28 28 StudentClearPage, StudentRejectClearancePage, 29 StudyLevelEditFormPage, 29 StudyLevelEditFormPage, StudentBasePDFFormPage, 30 30 msave, emit_lock_message) 31 from waeup.kofa.students.interfaces import IStudentsUtils 31 32 from waeup.kofa.students.workflow import FORBIDDEN_POSTGRAD_TRANS 32 33 from kofacustom.nigeria.students.browser import ( … … 36 37 NigeriaOnlinePaymentAddFormPage, 37 38 NigeriaExportPDFPaymentSlipPage, 39 NigeriaExportPDFClearanceSlipPage, 38 40 ) 39 #from waeup.uniben.students.interfaces import ICustomStudent40 41 41 42 from waeup.uniben.students.interfaces import ( … … 126 127 # return 127 128 129 class CustomExportPDFClearanceSlipPage(NigeriaExportPDFClearanceSlipPage): 130 """Deliver a PDF slip of the context. 131 """ 132 133 def render(self): 134 studentview = StudentBasePDFFormPage(self.context.student, 135 self.request, self.omit_fields) 136 students_utils = getUtility(IStudentsUtils) 137 return students_utils.renderPDF( 138 self, 'clearance_slip.pdf', 139 self.context.student, studentview, signatures=self._signatures(), 140 sig_in_footer=self._sigInFooter(), show_scans=False) 141 128 142 class StudyCourseCOEditFormPage(KofaEditFormPage): 129 143 """ Page to edit the student study course data by clearance officers. -
main/waeup.uniben/trunk/src/waeup/uniben/students/utils.py
r9549 r9551 207 207 return None, payment 208 208 209 def renderPDF(self, view, filename='slip.pdf', student=None,210 studentview=None, tableheader=None, tabledata=None,211 note=None, signatures=None, sig_in_footer=False):212 """Render pdf slips for various pages.213 """214 # XXX: we have to fix the import problems here.215 from waeup.kofa.browser.interfaces import IPDFCreator216 from waeup.kofa.browser.pdf import NORMAL_STYLE, ENTRY1_STYLE217 style = getSampleStyleSheet()218 creator = getUtility(IPDFCreator)219 data = []220 doc_title = view.label221 author = '%s (%s)' % (view.request.principal.title,222 view.request.principal.id)223 footer_text = view.label224 if getattr(student, 'student_id', None) is not None:225 footer_text = "%s - %s - " % (student.student_id, footer_text)226 227 # Insert student data table228 portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE229 if student is not None:230 bd_translation = trans(_('Base Data'), portal_language)231 data.append(Paragraph(bd_translation, style["Heading3"]))232 data.append(render_student_data(studentview))233 234 # Insert widgets235 if view.form_fields:236 data.append(Paragraph(view.title, style["Heading3"]))237 portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE238 separators = getattr(self, 'SEPARATORS_DICT', {})239 table = creator.getWidgetsTable(240 view.form_fields, view.context, None, lang=portal_language,241 separators=separators)242 data.append(table)243 244 # Insert scanned docs245 #data.extend(docs_as_flowables(view, portal_language))246 247 # Insert history248 if filename.startswith('clearance') or filename.startswith('course'):249 hist_translation = trans(_('Workflow History'), portal_language)250 data.append(Paragraph(hist_translation, style["Heading3"]))251 data.extend(creator.fromStringList(student.history.messages))252 253 # Insert content table (optionally on second page)254 if tabledata and tableheader:255 #data.append(PageBreak())256 data.append(Spacer(1, 20))257 data.append(Paragraph(view.content_title, style["Heading3"]))258 contenttable = render_table_data(tableheader,tabledata)259 data.append(contenttable)260 261 # Insert signatures262 if signatures and not sig_in_footer:263 data.append(Spacer(1, 20))264 signaturetable = get_signature_table(signatures)265 data.append(signaturetable)266 267 view.response.setHeader(268 'Content-Type', 'application/pdf')269 try:270 pdf_stream = creator.create_pdf(271 data, None, doc_title, author=author, footer=footer_text,272 note=note, sig_in_footer=sig_in_footer)273 except IOError:274 view.flash('Error in image file.')275 return view.redirect(view.url(view.context))276 return pdf_stream277 278 209 # Uniben prefix 279 210 STUDENT_ID_PREFIX = u'B'
Note: See TracChangeset for help on using the changeset viewer.