Changeset 10691 for main/waeup.kwarapoly/trunk/src/waeup/kwarapoly
- Timestamp:
- 4 Nov 2013, 09:19:39 (11 years ago)
- Location:
- main/waeup.kwarapoly/trunk/src/waeup/kwarapoly/students
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kwarapoly/trunk/src/waeup/kwarapoly/students/browser.py
r9992 r10691 18 18 import grok 19 19 from zope.i18n import translate 20 from zope.component import getUtility 20 21 from hurry.workflow.interfaces import IWorkflowInfo 21 22 from waeup.kofa.interfaces import ADMITTED 22 from waeup.kofa.interfaces import MessageFactory as _ 23 from waeup.kofa.browser.layout import UtilityView 24 from waeup.kofa.students.interfaces import IStudentsUtils 23 25 from waeup.kofa.widgets.datewidget import FriendlyDatetimeDisplayWidget 24 from waeup.kofa.students.browser import StartClearancePage, BedTicketAddPage 26 from waeup.kofa.students.browser import ( 27 StartClearancePage, BedTicketAddPage, ExportPDFAdmissionSlipPage) 28 from waeup.kwarapoly.students.interfaces import ( 29 ICustomStudent, ICustomStudentBase) 30 from waeup.kwarapoly.interfaces import MessageFactory as _ 31 from waeup.kofa.students.workflow import ( 32 ADMITTED, PAID, REQUESTED, RETURNING, CLEARED, REGISTERED, 33 VALIDATED, GRADUATED, TRANSCRIPT, CREATED, CLEARANCE) 25 34 from kofacustom.nigeria.students.browser import ( 26 35 NigeriaOnlinePaymentDisplayFormPage, … … 75 84 notice = '' 76 85 with_ac = False 86 87 class CustomExportPDFAdmissionSlipPage(ExportPDFAdmissionSlipPage): 88 """Deliver a PDF Admission slip. 89 """ 90 grok.context(ICustomStudent) 91 92 omit_fields = ('date_of_birth',) 93 94 form_fields = grok.AutoFields(ICustomStudent).select('student_id', 'reg_number') 95 96 def render(self): 97 if self.context.state in (CREATED, ADMITTED, 98 CLEARANCE, REQUESTED, CLEARED): 99 self.flash('Not allowed.') 100 self.redirect(self.url(self.context)) 101 return 102 students_utils = getUtility(IStudentsUtils) 103 return students_utils.renderPDFAdmissionLetter(self, 104 self.context.student, omit_fields=self.omit_fields) 105 106 class ExportPDFAdmissionNotificationPage(UtilityView, grok.View): 107 """Deliver a PDF Admission nostification slip. 108 """ 109 grok.context(ICustomStudent) 110 grok.name('admission_notification.pdf') 111 grok.require('waeup.viewStudent') 112 prefix = 'form' 113 label = 'Notification of Provisional Admission' 114 115 omit_fields = ('date_of_birth',) 116 117 form_fields = grok.AutoFields(ICustomStudent).select( 118 'student_id', 'reg_number', 'sex', 'lga') 119 120 def render(self): 121 if self.context.state not in (ADMITTED, CLEARANCE, REQUESTED, CLEARED): 122 self.flash('Not allowed.') 123 self.redirect(self.url(self.context)) 124 return 125 students_utils = getUtility(IStudentsUtils) 126 pre_text = '' 127 post_text = '<strong>Instructions for Freshers</strong>' 128 return students_utils.renderPDFAdmissionLetter(self, 129 self.context.student, omit_fields=self.omit_fields, 130 pre_text=pre_text, post_text=post_text) -
main/waeup.kwarapoly/trunk/src/waeup/kwarapoly/students/tests/test_browser.py
r10682 r10691 19 19 import shutil 20 20 import tempfile 21 from mechanize import LinkNotFoundError 21 22 from StringIO import StringIO 22 23 from hurry.workflow.interfaces import IWorkflowState, IWorkflowInfo … … 345 346 self.browser.contents) 346 347 return 348 349 def test_pdf_slips(self): 350 IWorkflowState(self.student).setState('school fee paid') 351 # Login 352 self.browser.open(self.login_path) 353 self.browser.getControl(name="form.login").value = self.student_id 354 self.browser.getControl(name="form.password").value = 'spwd' 355 self.browser.getControl("Login").click() 356 self.browser.open(self.student_path) 357 self.browser.getLink("Download admission letter").click() 358 self.assertEqual(self.browser.headers['Status'], '200 Ok') 359 self.assertEqual(self.browser.headers['Content-Type'], 360 'application/pdf') 361 self.browser.open(self.student_path) 362 self.assertRaises( 363 LinkNotFoundError, self.browser.getLink, 'Download admission notification') 364 self.browser.open(self.student_path, 'admission_notification.pdf') 365 self.assertFalse('Not allowed' in self.browser.contents) 366 367 IWorkflowState(self.student).setState('cleared') 368 self.browser.open(self.student_path) 369 self.browser.getLink("Download admission notification").click() 370 self.assertEqual(self.browser.headers['Status'], '200 Ok') 371 self.assertEqual(self.browser.headers['Content-Type'], 372 'application/pdf') 373 self.browser.open(self.student_path) 374 self.assertRaises( 375 LinkNotFoundError, self.browser.getLink, 'Download admission letter') 376 self.browser.open(self.student_path, 'admission_slip.pdf') 377 self.assertFalse('Not allowed' in self.browser.contents) 378 return -
main/waeup.kwarapoly/trunk/src/waeup/kwarapoly/students/viewlets.py
r9873 r10691 17 17 ## 18 18 19 import grok 19 20 from waeup.kofa.students.viewlets import ( 20 AddPreviousPaymentActionButton, AddBalancePaymentActionButton) 21 AddPreviousPaymentActionButton, AddBalancePaymentActionButton, 22 ManageActionButton) 23 from waeup.kofa.students.interfaces import IStudent 24 from waeup.kofa.students.browser import StudentBaseDisplayFormPage 25 from waeup.kofa.students.workflow import ( 26 ADMITTED, PAID, REQUESTED, RETURNING, CLEARED, REGISTERED, 27 VALIDATED, GRADUATED, TRANSCRIPT, CREATED, CLEARANCE) 28 from waeup.kwarapoly.interfaces import MessageFactory as _ 21 29 22 30 class AddPreviousPaymentActionButton(AddPreviousPaymentActionButton): … … 31 39 def target_url(self): 32 40 return '' 41 42 class AdmissionNotificationActionButton(ManageActionButton): 43 grok.order(4) 44 grok.context(IStudent) 45 grok.view(StudentBaseDisplayFormPage) 46 grok.require('waeup.viewStudent') 47 icon = 'actionicon_pdf.png' 48 text = _('Download admission notification') 49 target = 'admission_notification.pdf' 50 51 @property 52 def target_url(self): 53 if self.context.state not in (ADMITTED, CLEARANCE, REQUESTED, CLEARED): 54 return '' 55 return self.view.url(self.view.context, self.target) 56 57 class AdmissionSlipActionButton(ManageActionButton): 58 grok.order(4) 59 grok.context(IStudent) 60 grok.view(StudentBaseDisplayFormPage) 61 grok.require('waeup.viewStudent') 62 icon = 'actionicon_pdf.png' 63 text = _('Download admission letter') 64 target = 'admission_slip.pdf' 65 66 @property 67 def target_url(self): 68 if self.context.state in (CREATED, ADMITTED, 69 CLEARANCE, REQUESTED, CLEARED): 70 return '' 71 return self.view.url(self.view.context, self.target)
Note: See TracChangeset for help on using the changeset viewer.