Changeset 8595 for main/waeup.kofa/trunk/src/waeup
- Timestamp:
- 2 Jun 2012, 06:44:23 (13 years ago)
- Location:
- main/waeup.kofa/trunk/src/waeup/kofa/students
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/students/browser.py
r8558 r8595 21 21 import grok 22 22 from urllib import urlencode 23 from time import time24 23 from datetime import datetime 25 24 from copy import deepcopy … … 1049 1048 label = _('Add online payment') 1050 1049 pnav = 4 1051 factory = u'waeup.StudentOnlinePayment'1052 1053 def _fillCustomFields(self, payment, pay_details):1054 """No custom fields in the base package1055 """1056 return payment1057 1050 1058 1051 @action(_('Create ticket'), style='primary') … … 1069 1062 return 1070 1063 students_utils = getUtility(IStudentsUtils) 1071 try: 1072 pay_details = students_utils.getPaymentDetails( 1073 p_category,student) 1074 except (AttributeError, TypeError): 1075 self.flash( 1076 _('Study course data are incomplete.')) 1064 error, payment = students_utils.setPaymentDetails(p_category, student) 1065 if error is not None: 1066 self.flash(error) 1077 1067 self.redirect(self.url(self.context)) 1078 1068 return 1079 if pay_details['error']:1080 self.flash(pay_details['error'])1081 self.redirect(self.url(self.context))1082 return1083 p_item = pay_details['p_item']1084 p_session = pay_details['p_session']1085 for key in self.context.keys():1086 ticket = self.context[key]1087 if ticket.p_state == 'paid' and\1088 ticket.p_category == p_category and \1089 ticket.p_item == p_item and \1090 ticket.p_session == p_session:1091 self.flash(1092 _('This type of payment has already been made.'))1093 self.redirect(self.url(self.context))1094 return1095 payment = createObject(self.factory)1096 self.applyData(payment, **data)1097 timestamp = "%d" % int(time()*1000)1098 payment.p_id = "p%s" % timestamp1099 payment.p_item = p_item1100 payment.p_session = p_session1101 payment.p_level = pay_details['p_level']1102 payment.amount_auth = pay_details['amount']1103 payment = self._fillCustomFields(payment, pay_details)1104 1069 self.context[payment.p_id] = payment 1105 1070 self.flash(_('Payment ticket created.')) -
main/waeup.kofa/trunk/src/waeup/kofa/students/interfaces.py
r8453 r8595 64 64 """ 65 65 66 def getPaymentDetails(category, student):67 """ Get the payment dates of a student for the payment category68 specified.66 def setPaymentDetails(category, student): 67 """Create Payment object and set the payment data of a student for 68 the payment category specified. 69 69 70 70 """ -
main/waeup.kofa/trunk/src/waeup/kofa/students/utils.py
r8524 r8595 20 20 import grok 21 21 from random import SystemRandom as r 22 from time import time 22 23 from datetime import datetime 23 24 from zope.i18n import translate 24 from zope.component import getUtility 25 from zope.component import getUtility, createObject 25 26 from reportlab.pdfgen import canvas 26 27 from reportlab.lib import colors … … 252 253 return 253 254 254 def getPaymentDetails(self, category, student): 255 """Get the payment data of a student for the payment category 256 specified. 257 """ 255 def setPaymentDetails(self, category, student): 256 """Create Payment object and set the payment data of a student for 257 the payment category specified. 258 259 """ 260 factory = u'waeup.StudentOnlinePayment' 258 261 details = {} 259 details['p_item']= u''260 details['amount']= 0.0261 details['error']= u''262 details['p_session']= student['studycourse'].current_session263 details['p_level']= student['studycourse'].current_level264 session = str( details['p_session'])262 p_item = u'' 263 amount = 0.0 264 error = u'' 265 p_session = student['studycourse'].current_session 266 p_level = student['studycourse'].current_level 267 session = str(p_session) 265 268 try: 266 269 academic_session = grok.getSite()['configuration'][session] 267 270 except KeyError: 268 details['error'] = _(u'Session configuration object is not available.') 269 return details 271 return _(u'Session configuration object is not available.'), None 270 272 if category == 'schoolfee': 271 details['amount'] = getattr( 272 student['studycourse'].certificate,'school_fee_1') 273 details['p_item'] = student['studycourse'].certificate.code 273 try: 274 amount = getattr( 275 student['studycourse'].certificate,'school_fee_1') 276 p_item = student['studycourse'].certificate.code 277 except (AttributeError, TypeError): 278 return _('Study course data are incomplete.'), None 274 279 if student.state == RETURNING: 275 280 # In case of returning school fee payment the payment session 276 281 # and level contain the values of the session the student 277 282 # has paid for. 278 details['p_session'], details[ 279 'p_level'] = self.getReturningData(student) 283 p_session, p_level = self.getReturningData(student) 280 284 elif student.is_postgrad and student.state == PAID: 281 285 # Returning postgraduate students also pay for the next session 282 286 # but their level always remains the same. 283 details['p_session']+= 1284 details['amount']= getattr(287 p_session += 1 288 amount = getattr( 285 289 student['studycourse'].certificate,'school_fee_2') 286 290 elif category == 'clearance': 287 details['p_item']= student['studycourse'].certificate.code288 details['amount']= academic_session.clearance_fee291 p_item = student['studycourse'].certificate.code 292 amount = academic_session.clearance_fee 289 293 elif category == 'bed_allocation': 290 details['p_item'] = self.getAccommodationDetails(student)['bt'] 291 details['amount'] = academic_session.booking_fee 292 if details['amount'] in (0.0, None): 293 details['error'] = _(u'Amount could not be determined.') 294 return details 294 p_item = self.getAccommodationDetails(student)['bt'] 295 amount = academic_session.booking_fee 296 if amount in (0.0, None): 297 return _(u'Amount could not be determined.'), None 298 for key in student['payments'].keys(): 299 ticket = student['payments'][key] 300 if ticket.p_state == 'paid' and\ 301 ticket.p_category == category and \ 302 ticket.p_item == p_item and \ 303 ticket.p_session == p_session: 304 return _('This type of payment has already been made.'), None 305 payment = createObject(factory) 306 #self.applyData(payment, **data) 307 timestamp = "%d" % int(time()*1000) 308 payment.p_id = "p%s" % timestamp 309 payment.p_category = category 310 payment.p_item = p_item 311 payment.p_session = p_session 312 payment.p_level = p_level 313 payment.amount_auth = amount 314 return None, payment 295 315 296 316 def getAccommodationDetails(self, student):
Note: See TracChangeset for help on using the changeset viewer.