Changeset 11784
- Timestamp:
- 29 Aug 2014, 19:04:38 (10 years ago)
- Location:
- main/waeup.uniben/trunk/src/waeup/uniben/applicants
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.uniben/trunk/src/waeup/uniben/applicants/applicant.py
r9064 r11784 31 31 grok.provides(ICustomApplicant) 32 32 33 def admchecking_fee_paid(self): 34 for key in self.keys(): 35 ticket = self[key] 36 if ticket.p_state == 'paid' and ticket.p_category == 'admission_checking': 37 return True 38 return False 39 33 40 # Set all attributes of CustomApplicant required in ICustomApplicant as field 34 41 # properties. Doing this, we do not have to set initial attributes -
main/waeup.uniben/trunk/src/waeup/uniben/applicants/browser.py
r11782 r11784 19 19 """ 20 20 import grok 21 from time import time 21 22 from zope.component import getUtility, createObject 22 23 from zope.security import checkPermission 24 from hurry.workflow.interfaces import IWorkflowState 25 from waeup.kofa.browser.layout import action, UtilityView 23 26 from waeup.kofa.interfaces import IExtFileStore 24 27 from waeup.kofa.applicants.browser import ( 25 28 ApplicantRegistrationPage, ApplicantsContainerPage, 26 29 ApplicationFeePaymentAddPage, 27 OnlinePaymentApprovePage) 30 OnlinePaymentApprovePage, 31 ExportPDFPageApplicationSlip) 28 32 from waeup.kofa.applicants.interfaces import ( 29 33 ISpecialApplicant, IApplicantsUtils) … … 34 38 from waeup.uniben.applicants.interfaces import ( 35 39 ICustomApplicant) 40 from waeup.kofa.applicants.workflow import ADMITTED, PAID 36 41 37 42 from waeup.uniben.interfaces import MessageFactory as _ … … 112 117 and self.context.state in ('paid', 'submitted') 113 118 114 # customizations for admission checking payments 119 # Customizations for admission checking payments 120 115 121 @property 116 122 def form_fields(self): 117 if self.context.special: 118 form_fields = grok.AutoFields(ISpecialApplicant).omit('locked') 119 else: 120 form_fields = grok.AutoFields(ICustomApplicant).omit( 121 'locked', 'course_admitted', 'password', 'suspended') 123 form_fields = super(CustomApplicantDisplayFormPage, self).form_fields 124 if not self.context.admchecking_fee_paid(): 125 form_fields = form_fields.omit( 126 'screening_score', 'aggregate', 'student_id') 122 127 return form_fields 123 128 129 @property 130 def display_actions(self): 131 state = IWorkflowState(self.context).getState() 132 actions = [] 133 if state == ADMITTED and not self.context.admchecking_fee_paid(): 134 actions = [_('Add admission checking payment ticket')] 135 return actions 136 137 138 def getCourseAdmitted(self): 139 """Return link, title and code in html format to the certificate 140 admitted. 141 """ 142 course_admitted = self.context.course_admitted 143 if getattr(course_admitted, '__parent__',None) and \ 144 self.context.admchecking_fee_paid(): 145 url = self.url(course_admitted) 146 title = course_admitted.title 147 code = course_admitted.code 148 return '<a href="%s">%s - %s</a>' %(url,code,title) 149 return '' 150 151 @action(_('Add admission checking payment ticket'), style='primary') 152 def addPaymentTicket(self, **data): 153 self.redirect(self.url(self.context, '@@addacp')) 154 return 155 124 156 class CustomNigeriaPDFApplicationSlip(NigeriaPDFApplicationSlip): 125 126 157 127 158 @property … … 147 178 return '' 148 179 149 # customizations for admission checking payments 180 class AdmissionCheckingFeePaymentAddPage(UtilityView, grok.View): 181 """ Page to add an admission checking online payment ticket. 182 """ 183 grok.context(ICustomApplicant) 184 grok.name('addacp') 185 grok.require('waeup.payApplicant') 186 factory = u'waeup.ApplicantOnlinePayment' 187 188 def _setPaymentDetails(self, payment): 189 container = self.context.__parent__ 190 timestamp = ("%d" % int(time()*10000))[1:] 191 session = str(container.year) 192 try: 193 session_config = grok.getSite()['configuration'][session] 194 except KeyError: 195 return _(u'Session configuration object is not available.'), None 196 payment.p_id = "p%s" % timestamp 197 payment.p_item = container.title 198 payment.p_session = container.year 199 payment.amount_auth = 0.0 200 payment.p_category = 'admission_checking' 201 payment.amount_auth = session_config.admchecking_fee 202 if payment.amount_auth in (0.0, None): 203 return _('Amount could not be determined.'), None 204 return 205 150 206 def update(self): 151 # Additional requirements in custom packages. 152 if self.custom_requirements: 153 self.flash( 154 self.custom_requirements, 155 type='danger') 156 self.redirect(self.url(self.context)) 157 return 158 if not self.context.special: 159 for key in self.context.keys(): 160 ticket = self.context[key] 161 if ticket.p_state == 'paid': 162 self.flash( 163 _('This type of payment has already been made.'), 164 type='warning') 165 self.redirect(self.url(self.context)) 166 return 167 applicants_utils = getUtility(IApplicantsUtils) 168 container = self.context.__parent__ 207 if self.context.admchecking_fee_paid(): 208 self.flash( 209 _('Admission checking payment has already been made.'), 210 type='warning') 211 self.redirect(self.url(self.context)) 212 return 169 213 payment = createObject(self.factory) 170 failure = applicants_utils.setPaymentDetails( 171 container, payment, self.context) 214 failure = self._setPaymentDetails(payment) 172 215 if failure is not None: 173 216 self.flash(failure[0], type='danger') … … 179 222 return 180 223 224 def render(self): 225 return 226 181 227 182 228 class CustomApplicantManageFormPage(NigeriaApplicantManageFormPage): … … 191 237 """ 192 238 193 # customizations for admission checking payments 239 194 240 def update(self): 195 flashtype, msg, log = self.context.approveApplicantPayment() 241 if self.context.p_category == 'admission_checking': 242 if self.context.p_state == 'paid': 243 flashtype = 'warning' 244 msg = _('This ticket has already been paid.') 245 log = None 246 else: 247 self.context.approve() 248 log = 'payment approved: %s' % self.context.p_id 249 msg = _('Payment approved') 250 flashtype = 'success' 251 else: 252 flashtype, msg, log = self.context.approveApplicantPayment() 196 253 if log is not None: 197 254 applicant = self.context.__parent__ … … 206 263 self.flash(msg, type=flashtype) 207 264 return 265 266 class CustomExportPDFPageApplicationSlip(ExportPDFPageApplicationSlip): 267 """Deliver a PDF slip of the context. 268 """ 269 270 271 def update(self): 272 super(CustomExportPDFPageApplicationSlip, self).update() 273 if self.context.state == ADMITTED and \ 274 not self.context.admchecking_fee_paid(): 275 self.flash( 276 _('Please pay admission checking fee before trying to download ' 277 'the application slip.'), type='warning') 278 return self.redirect(self.url(self.context)) 279 return -
main/waeup.uniben/trunk/src/waeup/uniben/applicants/browser_templates/applicantdisplaypage.pt
r11315 r11784 109 109 </tbody> 110 110 </table> 111 <form action="." tal:attributes="action request/URL" method="post" 112 i18n:domain="waeup.kofa"> 113 <div tal:condition="view/availableActions"> 114 <span tal:repeat="action view/actions" 115 tal:omit-tag=""> 116 <input tal:condition="python:action.label in view.display_actions" 117 tal:replace="structure action/render"/> 118 </span> 119 </div> 120 </form>
Note: See TracChangeset for help on using the changeset viewer.