- Timestamp:
- 5 Sep 2018, 10:58:59 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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):
Note: See TracChangeset for help on using the changeset viewer.