Changeset 11887 for main/waeup.kwarapoly/trunk
- Timestamp:
- 28 Oct 2014, 17:48:22 (10 years ago)
- Location:
- main/waeup.kwarapoly/trunk
- Files:
-
- 4 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kwarapoly/trunk
- Property svn:mergeinfo changed
/main/waeup.kwarapoly/branches/uli-pdfsigs (added) merged: 11877-11878,11880,11884-11886
- Property svn:mergeinfo changed
-
main/waeup.kwarapoly/trunk/src/waeup/kwarapoly
- Property svn:mergeinfo changed
/main/waeup.kwarapoly/branches/uli-pdfsigs/src/waeup/kwarapoly (added) merged: 11878,11880,11884-11886
- Property svn:mergeinfo changed
-
main/waeup.kwarapoly/trunk/src/waeup/kwarapoly/browser/pdf.py
r10145 r11887 21 21 22 22 import os 23 from string import Template 23 24 from waeup.kofa.browser.pdf import PDFCreator 24 25 … … 34 35 #watermark_pos = [-25, 100] 35 36 logo_pos = [507, 740, 70] 37 38 signature_img_path = os.path.join( 39 os.path.dirname(__file__), 'static', 'pdf_signature.png') 40 41 def substitute_markers(self, text): 42 """If `text` contains some marker, substitute it. 43 44 Markers are standard library string template placeholders. See 45 https://docs.python.org/2/library/string.html and 46 `string.Template` for details. Roughly, placeholders look like 47 ``${some_marker}``. 48 49 Valid markers: 50 ``signature_img_path`` -- path to signature image stored in 51 `signature_img_path`` attribute. 52 """ 53 text = Template(text) 54 return text.safe_substitute( 55 { 56 'signature_img_path': self.signature_img_path, 57 } 58 ) 59 60 def create_pdf(self, *args, **kw): 61 """Create PDF from args and keywords. 62 63 Unlike the base method, we mangle any `notes` keyword and 64 substitute any valid placeholder strings in it. See 65 `substitute_markers` for a list of valid placeholders. 66 67 XXX: This is only a quick, dirty hack, that should not appear 68 in this package. Instead it should be moved to the 69 waeup.kofa basepackage. 70 71 Please note: string substitution like this can introduce nasty 72 security holes. For instance all dynamic input in `notes` must 73 be cleaned up and placeholder expressions should be removed 74 from it before using it in `note`. 75 76 Also, `note` is clearly misused in this case. We might want to 77 look for a more general approach, maybe z3c.rml? 78 """ 79 if 'note' in kw.keys() and kw['note'] is not None: 80 kw['note'] = self.substitute_markers(kw['note']) 81 return super(CustomPDFCreator, self).create_pdf(*args, **kw) -
main/waeup.kwarapoly/trunk/src/waeup/kwarapoly/students/browser.py
r11873 r11887 56 56 ) 57 57 58 58 59 class CustomStudentBaseEditFormPage(NigeriaStudentBaseEditFormPage): 59 60 """ View to edit student base data … … 62 63 'email', 'phone', 'sex') 63 64 64 class CustomStudentPersonalDisplayFormPage(NigeriaStudentPersonalDisplayFormPage): 65 66 class CustomStudentPersonalDisplayFormPage( 67 NigeriaStudentPersonalDisplayFormPage): 65 68 """ Page to display student personal data 66 69 """ … … 73 76 'personal_updated'].custom_widget = FriendlyDatetimeDisplayWidget('le') 74 77 78 75 79 class CustomStudentPersonalEditFormPage(NigeriaStudentPersonalEditFormPage): 76 80 """ Page to edit personal data … … 79 83 'personal_updated') 80 84 81 class CustomStudentPersonalManageFormPage(NigeriaStudentPersonalManageFormPage): 85 86 class CustomStudentPersonalManageFormPage( 87 NigeriaStudentPersonalManageFormPage): 82 88 """ Page to edit personal data 83 89 """ … … 86 92 form_fields[ 87 93 'personal_updated'].custom_widget = FriendlyDatetimeDisplayWidget('le') 94 88 95 89 96 class CustomOnlinePaymentDisplayFormPage(NigeriaOnlinePaymentDisplayFormPage): … … 98 105 'payment_date'].custom_widget = FriendlyDatetimeDisplayWidget('le') 99 106 107 100 108 class CustomOnlinePaymentAddFormPage(NigeriaOnlinePaymentAddFormPage): 101 109 """ Page to add an online payment ticket … … 103 111 form_fields = grok.AutoFields(ICustomStudentOnlinePayment).select( 104 112 'p_category') 113 105 114 106 115 class CustomExportPDFPaymentSlipPage(NigeriaExportPDFPaymentSlipPage): … … 110 119 form_fields = grok.AutoFields(ICustomStudentOnlinePayment).omit( 111 120 'provider_amt', 'gateway_amt', 'thirdparty_amt', 'p_item') 112 form_fields['creation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le') 113 form_fields['payment_date'].custom_widget = FriendlyDatetimeDisplayWidget('le') 121 form_fields['creation_date'].custom_widget = FriendlyDatetimeDisplayWidget( 122 'le') 123 form_fields['payment_date'].custom_widget = FriendlyDatetimeDisplayWidget( 124 'le') 125 114 126 115 127 class CustomStartClearancePage(StartClearancePage): … … 118 130 119 131 120 class CustomStudentClearanceDisplayFormPage(NigeriaStudentClearanceDisplayFormPage): 132 class CustomStudentClearanceDisplayFormPage( 133 NigeriaStudentClearanceDisplayFormPage): 121 134 """ Page to display student clearance data 122 135 """ … … 135 148 form_fields['officer_comment'].custom_widget = BytesDisplayWidget 136 149 return form_fields 150 137 151 138 152 class CustomExportPDFClearanceSlipPage(NigeriaExportPDFClearanceSlipPage): … … 152 166 return form_fields 153 167 154 class CustomStudentClearanceManageFormPage(NigeriaStudentClearanceManageFormPage): 168 169 class CustomStudentClearanceManageFormPage( 170 NigeriaStudentClearanceManageFormPage): 155 171 """ Page to edit student clearance data 156 172 """ … … 165 181 ICustomUGStudentClearance).omit('clr_code') 166 182 return form_fields 183 167 184 168 185 class CustomStudentClearanceEditFormPage(NigeriaStudentClearanceEditFormPage): … … 183 200 return form_fields 184 201 202 185 203 class BedTicketAddPage(BedTicketAddPage): 186 204 """ Page to add an online payment ticket … … 190 208 with_ac = False 191 209 210 192 211 class CustomExportPDFAdmissionSlipPage(ExportPDFAdmissionSlipPage): 193 212 """Deliver a PDF Admission slip. … … 197 216 omit_fields = ('date_of_birth', 'current_level') 198 217 199 form_fields = grok.AutoFields(ICustomStudent).select('student_id', 'reg_number') 218 form_fields = grok.AutoFields(ICustomStudent).select( 219 'student_id', 'reg_number') 200 220 201 221 def render(self): … … 208 228 return students_utils.renderPDFAdmissionLetter(self, 209 229 self.context.student, omit_fields=self.omit_fields) 230 210 231 211 232 class ExportPDFAdmissionNotificationPage(UtilityView, grok.View): … … 235 256 pre_text=pre_text, post_text=post_text) 236 257 258 237 259 # copied from waeup.aaue 238 260 class CustomExportPDFCourseRegistrationSlipPage( … … 262 284 'I recommend to approve the course registration. <br>', 263 285 _('Head of Department\'s Signature'), '<br>')], 264 [('' 286 [('', _('Principal Assistant Registrar\'s Signature'), '<br>')], 265 287 [('', _('Director\'s Signature'))] 266 288 ) … … 270 292 Sem = translate('Sem.', 'waeup.kofa', target_language=portal_language) 271 293 Code = translate('Code', 'waeup.kofa', target_language=portal_language) 272 Title = translate('Title', 'waeup.kofa', target_language=portal_language) 273 Cred = translate('Cred.', 'waeup.kofa', target_language=portal_language) 274 Score = translate('Score', 'waeup.kofa', target_language=portal_language) 275 Grade = translate('Grade', 'waeup.kofa', target_language=portal_language) 294 Title = translate('Title', 'waeup.kofa', 295 target_language=portal_language) 296 Cred = translate( 297 'Cred.', 'waeup.kofa', target_language=portal_language) 298 Score = translate('Score', 'waeup.kofa', 299 target_language=portal_language) 300 Grade = translate('Grade', 'waeup.kofa', 301 target_language=portal_language) 276 302 Signature = translate(_('HOD\'s Signature'), 'waeup.kwarapoly', 277 303 target_language=portal_language) … … 283 309 tableheader = [] 284 310 contenttitle = [] 285 for i in range(1, 7):311 for i in range(1, 7): 286 312 tabledata.append(sorted( 287 [value for value in self.context.values() if value.semester == i], 313 [value for value in self.context.values() 314 if value.semester == i], 288 315 key=lambda value: str(value.semester) + value.code)) 289 tableheader.append([(Code, 'code', 2.0),290 (Title, 'title', 7),316 tableheader.append([(Code, 'code', 2.0), 317 (Title, 'title', 7), 291 318 (Cred, 'credits', 1.5), 292 319 (Score, 'score', 1.4), … … 310 337 ) 311 338 339 312 340 class ExportPDFRegistrationSlipPage(grok.View): 313 341 """Deliver a PDF slip of the context. … … 343 371 <strong>IMPORTANT NOTICE</strong> 344 372 <br /><br /> 345 This registration slip must be supplied before attendance of lectures. Note that:<br /><br /> 346 1. All fees due must be paid in full.<br /><br /> 347 2. All information required must be available on the Registration Form.<br /><br /> 348 3. The Signature of all appropriate Polytechnic Authority must be obtained.<br /><br /> 349 4. The endorsed Registration Form should be returned to the respective Institutes and Administrative Offices.<br /><br /> 350 5. No student may change his subject or course of study as shown in the signed Registration Form without clearance from the Admissions Office and the Director of the appropriate Institute.<br /><br /> 351 6. All candidates admitted into the HND I programmes should submit the photocopies of their original certificates of ND and SSCE with scratch card online for clearance latest a week after the admission is offered. Failure to comply with this directive may lead to the forfeiture of the admission.<br /><br /> 352 373 This registration slip must be supplied before attendance of lectures. 374 Note that: 375 <br /><br /> 376 1. All fees due must be paid in full. 377 <br /><br /> 378 2. All information required must be available on the Registration Form. 379 <br /><br /> 380 3. The Signature of all appropriate Polytechnic Authority must be obtained. 381 <br /><br /> 382 4. The endorsed Registration Form should be returned to the respective 383 Institutes and Administrative Offices. 384 <br /><br /> 385 5. No student may change his subject or course of study as shown in the 386 signed Registration Form without clearance from the Admissions Office 387 and the Director of the appropriate Institute. 388 <br /><br /> 389 6. All candidates admitted into the HND I programmes should submit the 390 photocopies of their original certificates of ND and SSCE with scratch 391 card online for clearance latest a week after the admission is offered. 392 Failure to comply with this directive may lead to the forfeiture of 393 the admission. 394 <br /><br /> 395 <!-- image size: 229x100 pixels; ratio (2.29:1) must be kept --> 396 <img src="${signature_img_path}" valign="-30" 397 height="75" width="172" /> 398 <br /> 353 399 M.O. Adebayo<br /> 354 400 Admission Officer<br /> … … 359 405 <strong>INSTRUCTIONS TO FRESHERS</strong> 360 406 <br /><br /> 361 You are hereby offered a provisional admission for the 2014/2015 session subject to the conditions that: 362 <br /><br /> 363 1. The information given in your Application Form is correct.<br /><br /> 364 2. The original of your Credentials are presented for scrutiny.<br /><br /> 365 3. If at any time the Credentials submitted are found to be false/fake or incorrect, your admission shall be withdrawn.<br /><br /> 366 4. The name by which you are admitted and registered shall remain same throughout the duration of your programme.<br /><br /> 367 5. You are to fill and submit the Undertaking Form at the point of registration failure which your admission will be forfeited.<br /><br /> 368 6. You will dress decently covering your nakedness at all times.<br /><br /> 369 7. Payment of school fees will be once and in full and should be by Interswitch to the designated Banks. Failure to pay fees by the mode mentioned above by the closing date means you have declined the offer and your place will be given to another eligible candidate immediately.<br /><br /> 370 8. You present a Certificate of medical fitness from the Polytechnic Clinic.<br /><br /> 371 9. All indigenes of Kwara State are required to present Certificate of Citizenship.<br /><br /> 372 10. The Polytechnic reserves the right to withdraw your admission at any stage, if you are found to be a cultist or an expelled individual from any tertiary institution.<br /><br /> 373 11. You are prepared to take up accommodation provided on the campuses by the authority.<br /><br /> 374 12. There will be no refund of school fees once paid.<br /><br /> 375 13. If you accept this offer with the above stated conditions, please make a photocopy of this document and return it to the Admission Office immediately.<br /><br /> 376 14. You possess the entry requirement for the programme you are admitted.<br /><br /> 377 407 You are hereby offered a provisional admission for the 2014/2015 session 408 subject to the conditions that: 409 <br /><br /> 410 1. The information given in your Application Form is correct. 411 <br /><br /> 412 2. The original of your Credentials are presented for scrutiny. 413 <br /><br /> 414 3. If at any time the Credentials submitted are found to be false/fake 415 or incorrect, your admission shall be withdrawn. 416 <br /><br /> 417 4. The name by which you are admitted and registered shall remain same 418 throughout the duration of your programme. 419 <br /><br /> 420 5. You are to fill and submit the Undertaking Form at the point of 421 registration failure which your admission will be forfeited. 422 <br /><br /> 423 6. You will dress decently covering your nakedness at all times. 424 <br /><br /> 425 7. Payment of school fees will be once and in full and should be by 426 Interswitch to the designated Banks. Failure to pay fees by the 427 mode mentioned above by the closing date means you have declined 428 the offer and your place will be given to another eligible 429 candidate immediately. 430 <br /><br /> 431 8. You present a Certificate of medical fitness from the Polytechnic 432 Clinic. 433 <br /><br /> 434 9. All indigenes of Kwara State are required to present Certificate of 435 Citizenship. 436 <br /><br /> 437 10. The Polytechnic reserves the right to withdraw your admission at 438 any stage, if you are found to be a cultist or an expelled 439 individual from any tertiary institution. 440 <br /><br /> 441 11. You are prepared to take up accommodation provided on the campuses 442 by the authority. 443 <br /><br /> 444 12. There will be no refund of school fees once paid. 445 <br /><br /> 446 13. If you accept this offer with the above stated conditions, please 447 make a photocopy of this document and return it to the Admission 448 Office immediately. 449 <br /><br /> 450 14. You possess the entry requirement for the programme you are admitted. 451 <br /><br /> 452 453 <!-- image size: 229x100 pixels; ratio (2.29:1) must be kept --> 454 <img src="${signature_img_path}" valign="-30" 455 height="75" width="172" /> 456 <br /> 378 457 M.O. Adebayo<br /> 379 458 Admission Officer<br /> 380 459 For: Registrar 381 460 """ 461 # XXX: a note for <img /> tag used here (from reportlab docs): 462 # The valign attribute may be set to a css like value from "baseline", "sub", 463 # "super", "top", "text-top", "middle", "bottom", "text-bottom"; 464 # the value may also be a numeric percentage or an absolute value. 465 # 466 # Burn this remark after reading.
Note: See TracChangeset for help on using the changeset viewer.