- Timestamp:
- 5 Sep 2018, 10:58:59 (6 years ago)
- Location:
- main/kofacustom.edopoly/trunk/src/kofacustom/edopoly
- Files:
-
- 2 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
main/kofacustom.edopoly/trunk/src/kofacustom/edopoly/applicants/applicant.py
r15000 r15123 31 31 grok.provides(ICustomApplicant) 32 32 33 def admchecking_fee_paid(self): 34 # We don't charge if admission checking fee is not set. 35 session = str(self.__parent__.year) 36 try: 37 session_config = grok.getSite()['configuration'][session] 38 except KeyError: 39 return True 40 if session_config.admchecking_fee == 0: 41 return True 42 for key in self.keys(): 43 ticket = self[key] 44 if ticket.p_state == 'paid' and \ 45 ticket.p_category == 'admission_checking': 46 return True 47 return False 48 33 49 # Set all attributes of CustomApplicant required in ICustomApplicant as field 34 50 # properties. Doing this, we do not have to set initial attributes -
main/kofacustom.edopoly/trunk/src/kofacustom/edopoly/applicants/browser.py
r15087 r15123 19 19 """ 20 20 import grok 21 from time import time 21 22 from zope.formlib.textwidgets import BytesDisplayWidget 23 from zope.component import getUtility, createObject 24 from hurry.workflow.interfaces import IWorkflowState 22 25 from waeup.kofa.applicants.browser import ( 23 ApplicantRegistrationPage, ApplicantsContainerPage) 26 ApplicantRegistrationPage, ApplicantsContainerPage, 27 ExportPDFPageApplicationSlip) 28 from waeup.kofa.browser.layout import action, UtilityView 24 29 from kofacustom.nigeria.applicants.browser import ( 25 30 NigeriaApplicantDisplayFormPage, … … 37 42 PG_OMIT_EDIT_FIELDS, 38 43 ) 44 from waeup.kofa.applicants.workflow import ADMITTED, PAID, STARTED 39 45 from kofacustom.edopoly.applicants.interfaces import ( 40 46 ICustomUGApplicantEdit, ICustomUGApplicant, 41 ICustomPGApplicantEdit, ICustomPGApplicant) 47 ICustomPGApplicantEdit, ICustomPGApplicant, 48 ICustomApplicant,) 42 49 43 50 from kofacustom.edopoly.interfaces import MessageFactory as _ … … 75 82 """A display view for applicant data. 76 83 """ 84 grok.template('applicantdisplaypage') 77 85 78 86 @property … … 80 88 target = getattr(self.context.__parent__, 'prefix', None) 81 89 form_fields = grok.AutoFields(ICustomUGApplicant) 90 for field in UG_OMIT_DISPLAY_FIELDS: 91 form_fields = form_fields.omit(field) 82 92 form_fields['notice'].custom_widget = BytesDisplayWidget 83 93 form_fields['jamb_subjects'].custom_widget = BytesDisplayWidget … … 90 100 if not getattr(self.context, 'screening_date'): 91 101 form_fields = form_fields.omit('screening_date') 92 return form_fields 102 if not self.context.admchecking_fee_paid(): 103 form_fields = form_fields.omit( 104 'screening_score', 'aggregate', 'student_id') 105 return form_fields 106 107 @property 108 def admission_checking_info(self): 109 if self.context.state == ADMITTED and \ 110 not self.context.admchecking_fee_paid(): 111 return _('You must pay the admission checking fee ' 112 'to view your screening results and course admitted.') 113 114 @property 115 def display_actions(self): 116 state = IWorkflowState(self.context).getState() 117 actions = [] 118 if state == ADMITTED and not self.context.admchecking_fee_paid(): 119 actions = [_('Add admission checking payment ticket')] 120 return actions 121 122 def getCourseAdmitted(self): 123 """Return link, title and code in html format to the certificate 124 admitted. 125 """ 126 if self.admission_checking_info: 127 return self.admission_checking_info 128 return super(CustomApplicantDisplayFormPage, self).getCourseAdmitted() 129 130 @action(_('Add admission checking payment ticket'), style='primary') 131 def addPaymentTicket(self, **data): 132 self.redirect(self.url(self.context, '@@addacp')) 133 return 134 135 class AdmissionCheckingFeePaymentAddPage(UtilityView, grok.View): 136 """ Page to add an admission checking online payment ticket. 137 """ 138 grok.context(ICustomApplicant) 139 grok.name('addacp') 140 grok.require('waeup.payApplicant') 141 factory = u'waeup.ApplicantOnlinePayment' 142 143 def _setPaymentDetails(self, payment): 144 container = self.context.__parent__ 145 timestamp = ("%d" % int(time()*10000))[1:] 146 session = str(container.year) 147 try: 148 session_config = grok.getSite()['configuration'][session] 149 except KeyError: 150 return _(u'Session configuration object is not available.'), None 151 payment.p_id = "p%s" % timestamp 152 payment.p_item = container.title 153 payment.p_session = container.year 154 payment.amount_auth = 0.0 155 payment.p_category = 'admission_checking' 156 payment.amount_auth = session_config.admchecking_fee 157 if payment.amount_auth in (0.0, None): 158 return _('Amount could not be determined.'), None 159 return 160 161 def update(self): 162 if self.context.admchecking_fee_paid(): 163 self.flash( 164 _('Admission checking payment has already been made.'), 165 type='warning') 166 self.redirect(self.url(self.context)) 167 return 168 payment = createObject(self.factory) 169 failure = self._setPaymentDetails(payment) 170 if failure is not None: 171 self.flash(failure[0], type='danger') 172 self.redirect(self.url(self.context)) 173 return 174 self.context[payment.p_id] = payment 175 self.flash(_('Payment ticket created.')) 176 self.redirect(self.url(payment)) 177 return 178 179 def render(self): 180 return 181 182 class CustomExportPDFPageApplicationSlip(ExportPDFPageApplicationSlip): 183 """Deliver a PDF slip of the context. 184 """ 185 186 def update(self): 187 super(CustomExportPDFPageApplicationSlip, self).update() 188 if self.context.state == ADMITTED and \ 189 not self.context.admchecking_fee_paid(): 190 self.flash( 191 _('Please pay admission checking fee before trying to download ' 192 'the application slip.'), type='warning') 193 return self.redirect(self.url(self.context)) 194 return 93 195 94 196 class CustomPDFApplicationSlip(NigeriaPDFApplicationSlip): -
main/kofacustom.edopoly/trunk/src/kofacustom/edopoly/applicants/tests/test_browser.py
r15000 r15123 31 31 from kofacustom.edopoly.applicants.export import CustomApplicantExporter 32 32 from kofacustom.edopoly.applicants.batching import CustomApplicantProcessor 33 from kofacustom.edopoly.configuration import CustomSessionConfiguration 33 34 34 35 class CustomApplicantUITests(ApplicantsFullSetup): … … 36 37 37 38 layer = FunctionalLayer 39 40 def test_pay_admission_checking_fee(self): 41 IWorkflowState(self.applicant).setState('admitted') 42 self.applicant.screening_score = 55 43 self.applicant.course_admitted = self.certificate 44 self.login() 45 # SessionConfiguration is not set, thus admission checking payment 46 # is not necessary. Screening results and course admitted are visible. 47 self.assertFalse( 48 'Add admission checking payment ticket' in self.browser.contents) 49 self.assertTrue('<a href="http://localhost/app/faculties/fac1/dep1/certificates/CERT1">CERT1 - Unnamed Certificate</a>' in self.browser.contents) 50 self.assertTrue('<span>55</span>' in self.browser.contents) 51 configuration = CustomSessionConfiguration() 52 configuration.academic_session = datetime.datetime.now().year - 2 53 self.app['configuration'].addSessionConfiguration(configuration) 54 # Admission checking fee is 0, thus admission checking payment 55 # is not necessary. Screening results and course admitted are visible. 56 self.browser.open(self.view_path) 57 self.assertFalse( 58 'Add admission checking payment ticket' in self.browser.contents) 59 self.assertTrue('<a href="http://localhost/app/faculties/fac1/dep1/certificates/CERT1">CERT1 - Unnamed Certificate</a>' in self.browser.contents) 60 self.assertTrue('<span>55</span>' in self.browser.contents) 61 configuration.admchecking_fee = 22.0 62 # Admission checking payment button is now visible, but screening results 63 # and course admitted are not. 64 self.browser.open(self.view_path) 65 self.assertTrue( 66 'Add admission checking payment ticket' in self.browser.contents) 67 self.assertFalse('<a href="http://localhost/app/faculties/fac1/dep1/certificates/CERT1">CERT1 - Unnamed Certificate</a>' in self.browser.contents) 68 self.assertFalse('<span>55</span>' in self.browser.contents) 69 # Application slip can't be downloaded 70 self.assertFalse('Download application slip' in self.browser.contents) 71 slip_path = self.view_path + '/application_slip.pdf' 72 self.browser.open(slip_path) 73 self.assertTrue( 74 'Please pay admission checking fee before trying to download' 75 in self.browser.contents) 76 # Pay admission checking fee. 77 self.browser.getControl("Add admission checking").click() 78 p_id = self.applicant.keys()[0] 79 self.applicant[p_id].p_state = 'paid' 80 # Screening results and course admitted are visible after payment. 81 self.browser.open(self.view_path) 82 self.assertFalse( 83 'Add admission checking payment ticket' in self.browser.contents) 84 self.assertTrue('<a href="http://localhost/app/faculties/fac1/dep1/certificates/CERT1">CERT1 - Unnamed Certificate</a>' in self.browser.contents) 85 self.assertTrue('<span>55</span>' in self.browser.contents) 86 # Application slip can be downloaded again. 87 self.browser.getLink("Download application slip").click() 88 self.assertEqual(self.browser.headers['Status'], '200 Ok') 89 self.assertEqual(self.browser.headers['Content-Type'], 90 'application/pdf') 91 return 38 92 39 93 class ApplicantExporterTest(ApplicantImportExportSetup): -
main/kofacustom.edopoly/trunk/src/kofacustom/edopoly/interfaces.py
r15105 r15123 69 69 # Additional fees in custom package add here 70 70 71 admchecking_fee = schema.Float( 72 title = _(u'Admission Checking Fee'), 73 default = 0.0, 74 required = False, 75 ) 76 71 77 logbook_combo_fee = schema.Float( 72 78 title = _(u'Logbook Combo Fee'), -
main/kofacustom.edopoly/trunk/src/kofacustom/edopoly/utils/utils.py
r15109 r15123 56 56 'final_clearance': 'Final Clearance Fee', 57 57 'union': 'Student Union Dues', 58 'admission_checking': 'Admission Checking Fee', 58 59 } 59 60
Note: See TracChangeset for help on using the changeset viewer.