Changeset 7280 for main/waeup.sirp/trunk/src/waeup/sirp
- Timestamp:
- 6 Dec 2011, 12:27:21 (13 years ago)
- Location:
- main/waeup.sirp/trunk/src/waeup/sirp
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/browser/resources.py
r7195 r7280 99 99 #: require the JavaScript code to be rendered into the page:: 100 100 #: 101 #: from waeup.sirp.browser.resources import datepicker101 #: from waeup.sirp.browser.resources import warning 102 102 #: # ... 103 103 #: class MyPage(...): -
main/waeup.sirp/trunk/src/waeup/sirp/students/tests/test_browser.py
r7278 r7280 510 510 '<img align="middle" height="125px" src="passport.jpg" />' 511 511 in self.browser.contents) 512 513 # The clearance slip can't yet be opened 512 # The clearance slip can't be opened because it requires a proper 513 # passport jpg file. 514 self.browser.open(self.student_path + '/clearance.pdf') 515 self.assertEqual(self.browser.headers['Status'], '200 Ok') 516 self.assertTrue('Error in image file' in self.browser.contents) 517 # We remove the passport file again 518 self.browser.open(self.manage_student_path) 519 self.browser.getControl('Delete').click() 514 520 self.browser.open(self.student_path + '/clearance.pdf') 515 521 self.assertEqual(self.browser.headers['Status'], '200 Ok') -
main/waeup.sirp/trunk/src/waeup/sirp/students/utils.py
r7256 r7280 28 28 Table, Spacer) 29 29 from reportlab.platypus.tables import TableStyle 30 from zope.component import getUtility 30 31 from zope.formlib.form import setUpEditWidgets 32 from waeup.sirp.interfaces import IExtFileStore 31 33 from waeup.sirp.students.interfaces import IStudentsUtils 32 34 … … 63 65 data = [] 64 66 style = getSampleStyleSheet() 67 img = getUtility(IExtFileStore).getFileByContext( 68 studentview.context, attr='passport.jpg') 69 #import pdb; pdb.set_trace() 70 if img is None: 71 from waeup.sirp.browser import DEFAULT_PASSPORT_IMAGE_PATH 72 img = open(DEFAULT_PASSPORT_IMAGE_PATH, 'rb') 73 doc_img = Image(img.name, width=4*cm, height=3*cm, kind='bound') 74 data.append([doc_img]) 75 data.append([Spacer(1, 12)]) 65 76 for widget in studentview.widgets: 66 77 if widget.name == 'form.adm_code': … … 164 175 #story.append(HRFlowable()) 165 176 if student: 166 story.append(Spacer(1, 1 8))177 story.append(Spacer(1, 12)) 167 178 studenttable = render_student_data(student, studentview) 168 179 story.append(studenttable) 169 story.append(Spacer(1, 1 8))180 story.append(Spacer(1, 12)) 170 181 set_up_widgets(view) 171 182 data = [] … … 176 187 f_text = Paragraph(f_text, style["Normal"]) 177 188 data.append([f_label,f_text]) 189 # First, import browser components locally 190 # to avoid circular import 191 from waeup.sirp.students.viewlets import FileManager 192 from waeup.sirp.browser import DEFAULT_IMAGE_PATH 193 fm = FileManager(view.context, view.request, view) 194 # Collect viewlets 195 fm.update() 196 # Insert list of scanned documents 197 for viewlet in fm.viewlets: 198 f_label = '<font size=12>%s</font>' % viewlet.label 199 f_label = Paragraph(f_label, style["Normal"]) 200 if viewlet.template.__grok_name__ == 'imagedisplay': 201 # In case we define FileDisplay viewlets with 202 # an imagedisplay template in the customization package 203 img = getUtility(IExtFileStore).getFileByContext( 204 view.context, attr=viewlet.download_name) 205 if img is None: 206 img = open(DEFAULT_IMAGE_PATH, 'rb') 207 doc_img = Image(img.name, width=2*cm, height=1*cm, kind='bound') 208 data.append([f_label,doc_img]) 209 else: 210 f_text = '<font size=12>%s</font>' % viewlet.title 211 f_text = Paragraph(f_text, style["Normal"]) 212 data.append([f_label,f_text]) 178 213 table = Table(data,style=SLIP_STYLE) 179 214 story.append(table) 180 frame_body.addFromList(story,pdf) 181 215 try: 216 frame_body.addFromList(story,pdf) 217 except IOError: 218 view.flash('Error in image file.') 219 return view.redirect(view.url(view.context)) 182 220 story = [] 183 221 frame_footer = Frame(1*cm,0,width-(2*cm),1*cm) … … 186 224 story.append(Paragraph(f_text, style["Normal"])) 187 225 frame_footer.addFromList(story,pdf) 188 189 226 view.response.setHeader( 190 227 'Content-Type', 'application/pdf') -
main/waeup.sirp/trunk/src/waeup/sirp/students/viewlets.py
r7243 r7280 29 29 StudentClearanceDisplayFormPage, StudentClearanceManageFormPage, 30 30 write_log_message, StudentBaseManageFormPage, StudentBaseDisplayFormPage, 31 StudentFilesUploadPage )31 StudentFilesUploadPage, ExportPDFClearanceSlipPage) 32 32 from waeup.sirp.students.interfaces import IStudent, IStudentClearance 33 33 … … 377 377 download_name = u'birth_certificate' 378 378 379 class BirthCertificateSlip(BirthCertificateDisplay): 380 grok.view(ExportPDFClearanceSlipPage) 381 379 382 class BirthCertificateUpload(FileUpload): 380 383 """Birth Certificate upload viewlet. … … 394 397 title = u'Acceptance Letter Scan' 395 398 download_name = u'acceptance_letter' 399 400 class AcceptanceLetterSlip(AcceptanceLetterDisplay): 401 grok.view(ExportPDFClearanceSlipPage) 396 402 397 403 class AcceptanceLetterUpload(FileUpload):
Note: See TracChangeset for help on using the changeset viewer.