- Timestamp:
- 3 Nov 2012, 18:47:31 (12 years ago)
- Location:
- main/waeup.kofa/trunk/src/waeup/kofa/students
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/students/browser.py
r9516 r9517 1338 1338 return 1339 1339 1340 @action(_('Add online payment ticket'))1341 def addPaymentTicket(self, **data):1342 self.redirect(self.url(self.context, '@@addop'))1340 #@action(_('Add online payment ticket')) 1341 #def addPaymentTicket(self, **data): 1342 # self.redirect(self.url(self.context, '@@addop')) 1343 1343 1344 1344 class OnlinePaymentAddFormPage(KofaAddFormPage): … … 1378 1378 if error is not None: 1379 1379 self.flash(error) 1380 if 'previous session' in error or 'Would you like' in error:1381 self.redirect(self.url(self.context) + '/@@addpp')1382 return1383 self.redirect(self.url(self.context))1384 1380 return 1385 1381 self.context[payment.p_id] = payment … … 1402 1398 label = _('Add previous session online payment') 1403 1399 pnav = 4 1400 1401 def update(self): 1402 if self.context.student.is_fresh: 1403 self.flash(_("You can't pay for a session below your entry session.")) 1404 self.redirect(self.url(self.context)) 1405 super(PreviousPaymentAddFormPage, self).update() 1406 return 1404 1407 1405 1408 class OnlinePaymentDisplayFormPage(KofaDisplayFormPage): -
main/waeup.kofa/trunk/src/waeup/kofa/students/student.py
r9334 r9517 36 36 from waeup.kofa.interfaces import ( 37 37 IObjectHistory, IUserAccount, IFileStoreNameChooser, IFileStoreHandler, 38 IKofaUtils, CLEARANCE, registration_states_vocab, IExtFileStore,) 38 IKofaUtils, registration_states_vocab, IExtFileStore, 39 CLEARANCE) 39 40 from waeup.kofa.students.accommodation import StudentAccommodation 40 41 from waeup.kofa.students.export import EXPORTER_NAMES … … 190 191 self.get('studycourse', None), 'is_postgrad', False) 191 192 return is_postgrad 193 194 @property 195 def is_fresh(self): 196 entry_session = getattr( 197 self.get('studycourse', None), 'entry_session', None) 198 if self.current_session == entry_session: 199 return True 200 return False 192 201 193 202 def transfer(self, certificate, current_session=None, -
main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_browser.py
r9516 r9517 760 760 self.browser.open(self.payments_path) 761 761 IWorkflowState(self.student).setState('cleared') 762 self.browser.get Control("Add onlinepayment ticket").click()762 self.browser.getLink("Add current session payment ticket").click() 763 763 self.browser.getControl(name="form.p_category").value = ['schoolfee'] 764 764 self.browser.getControl("Create ticket").click() … … 781 781 # can be initialized a second time if the former ticket is not yet paid. 782 782 self.browser.open(self.payments_path) 783 self.browser.get Control("Add onlinepayment ticket").click()783 self.browser.getLink("Add current session payment ticket").click() 784 784 self.browser.getControl(name="form.p_category").value = ['schoolfee'] 785 785 self.browser.getControl("Create ticket").click() … … 827 827 # (with same p_item, p_session and p_category) can be added 828 828 self.browser.open(self.payments_path) 829 self.browser.get Control("Add onlinepayment ticket").click()829 self.browser.getLink("Add current session payment ticket").click() 830 830 self.browser.getControl(name="form.p_category").value = ['schoolfee'] 831 831 self.browser.getControl("Create ticket").click() … … 833 833 '...This type of payment has already been made...', 834 834 self.browser.contents) 835 # The PreviousPaymentAddFormPage opens836 self.assertEqual(self.browser.url, self.payments_path + '/@@addpp')837 835 838 836 # Managers can open the pdf payment slip … … 887 885 self.browser.addHeader('Authorization', 'Basic mgr:mgrpw') 888 886 self.browser.open(self.payments_path) 889 self.browser.get Control("Add onlinepayment ticket").click()887 self.browser.getLink("Add current session payment ticket").click() 890 888 self.browser.getControl(name="form.p_category").value = ['bed_allocation'] 891 889 # If student is not in accommodation session, payment cannot be processed … … 895 893 self.browser.contents) 896 894 self.app['hostels'].accommodation_session = 2004 897 self.browser.get Control("Add onlinepayment ticket").click()895 self.browser.getLink("Add current session payment ticket").click() 898 896 self.browser.getControl(name="form.p_category").value = ['bed_allocation'] 899 897 self.browser.getControl("Create ticket").click() … … 2046 2044 self.assertRaises( 2047 2045 LookupError, self.browser.getControl, name='val_id') 2048 self.browser.get Control("Add onlinepayment ticket").click()2046 self.browser.getLink("Add current session payment ticket").click() 2049 2047 self.browser.getControl(name="form.p_category").value = ['schoolfee'] 2050 2048 self.browser.getControl("Create ticket").click() … … 2136 2134 configuration2.booking_fee = 123.4 2137 2135 self.app['configuration'].addSessionConfiguration(configuration2) 2138 2136 configuration3 = createObject('waeup.SessionConfiguration') 2137 configuration3.academic_session = 2005 2138 configuration3.clearance_fee = 3456.0 2139 configuration3.booking_fee = 123.4 2140 self.app['configuration'].addSessionConfiguration(configuration3) 2139 2141 self.student['studycourse'].entry_session = 2002 2140 2142 … … 2148 2150 IWorkflowState(self.student).setState('courses registered') 2149 2151 self.browser.open(self.payments_path) 2150 self.browser.getControl("Add online payment ticket").click() 2151 self.browser.getControl(name="form.p_category").value = ['schoolfee'] 2152 self.browser.getControl("Create ticket").click() 2153 2154 # Amount cannot be determined since the state is not 2155 # 'cleared' or 'returning' 2156 self.assertMatches('...Amount could not be determined...', 2157 self.browser.contents) 2158 self.assertMatches('...Would you like to pay for a previous session?...', 2159 self.browser.contents) 2152 self.browser.getLink("Add previous session payment ticket").click() 2160 2153 2161 2154 # Previous session payment form is provided 2155 self.assertEqual(self.student.current_session, 2004) 2162 2156 self.browser.getControl(name="form.p_category").value = ['schoolfee'] 2163 2157 self.browser.getControl(name="form.p_session").value = ['2000'] … … 2167 2161 self.browser.contents) 2168 2162 self.browser.getControl(name="form.p_category").value = ['schoolfee'] 2169 self.browser.getControl(name="form.p_session").value = ['200 4']2163 self.browser.getControl(name="form.p_session").value = ['2005'] 2170 2164 self.browser.getControl(name="form.p_level").value = ['300'] 2171 2165 self.browser.getControl("Create ticket").click() 2172 2166 self.assertMatches('...This is not a previous session...', 2173 2167 self.browser.contents) 2168 # Students can pay current session school fee. 2174 2169 self.browser.getControl(name="form.p_category").value = ['schoolfee'] 2175 self.browser.getControl(name="form.p_session").value = ['200 3']2170 self.browser.getControl(name="form.p_session").value = ['2004'] 2176 2171 self.browser.getControl(name="form.p_level").value = ['300'] 2177 2172 self.browser.getControl("Create ticket").click() … … 2186 2181 2187 2182 # Payment session is properly set 2188 self.assertEqual(self.student['payments'][value].p_session, 200 3)2183 self.assertEqual(self.student['payments'][value].p_session, 2004) 2189 2184 self.assertEqual(self.student['payments'][value].p_level, 300) 2190 2185 … … 2200 2195 # Current payment flag is set False 2201 2196 self.assertFalse(self.student['payments'][value].p_current) 2197 2198 # Button and form are not available for fresh students 2199 self.student['studycourse'].entry_session = 2004 2200 self.browser.open(self.payments_path) 2201 self.assertFalse( 2202 "Add previous session payment ticket" in self.browser.contents) 2203 self.browser.open(self.payments_path + '/addpp') 2204 self.assertTrue( 2205 "You can't pay for a session below your entry session" in 2206 self.browser.contents) 2202 2207 return 2203 2208 … … 2215 2220 IWorkflowState(self.student).setState('cleared') 2216 2221 self.browser.open(self.payments_path) 2217 self.browser.get Control("Add onlinepayment ticket").click()2222 self.browser.getLink("Add current session payment ticket").click() 2218 2223 self.browser.getControl(name="form.p_category").value = ['schoolfee'] 2219 2224 self.browser.getControl("Create ticket").click() … … 2255 2260 # Remove first payment to be sure that we access the right ticket 2256 2261 del self.student['payments'][value] 2257 self.browser.get Control("Add onlinepayment ticket").click()2262 self.browser.getLink("Add current session payment ticket").click() 2258 2263 self.browser.getControl(name="form.p_category").value = ['schoolfee'] 2259 2264 self.browser.getControl("Create ticket").click() … … 2301 2306 # callback view (see test_manage_payments) 2302 2307 self.browser.getLink("Payments").click() 2303 self.browser.get Control("Add onlinepayment ticket").click()2308 self.browser.getLink("Add current session payment ticket").click() 2304 2309 self.browser.getControl(name="form.p_category").value = ['bed_allocation'] 2305 2310 self.browser.getControl("Create ticket").click() -
main/waeup.kofa/trunk/src/waeup/kofa/students/utils.py
r9516 r9517 309 309 amount = 0.0 310 310 if previous_session: 311 if previous_session < student['studycourse'].entry_session: 312 return _('The previous session must not fall below ' 313 'your entry session.'), None 314 if category == 'schoolfee': 315 # School fee is always paid for the following session 316 if previous_session > student['studycourse'].current_session: 317 return _('This is not a previous session.'), None 318 else: 319 if previous_session > student['studycourse'].current_session - 1: 320 return _('This is not a previous session.'), None 311 321 p_session = previous_session 312 322 p_level = previous_level … … 328 338 return _('Study course data are incomplete.'), None 329 339 if previous_session: 330 if previous_session < student['studycourse'].entry_session: 331 return _('The previous session must not fall below ' 332 'your entry session.'), None 333 if previous_session > student['studycourse'].current_session - 1: 334 return _('This is not a previous session.'), None 340 # Students can pay for previous sessions in all workflow states. 341 # Fresh students are excluded by the update method of the 342 # PreviousPaymentAddFormPage. 335 343 if previous_level == 100: 336 344 amount = getattr(certificate, 'school_fee_1', 0.0) … … 343 351 # In case of returning school fee payment the payment session 344 352 # and level contain the values of the session the student 345 # has paid for. 353 # has paid for. Payment session is always next session. 346 354 p_session, p_level = self.getReturningData(student) 347 355 amount = getattr(certificate, 'school_fee_2', 0.0) … … 372 380 p_item = trans(_('no bed allocated'), portal_language) 373 381 if amount in (0.0, None): 374 return _('Amount could not be determined.' + 375 ' Would you like to pay for a previous session?'), None 382 return _('Amount could not be determined.'), None 376 383 for key in student['payments'].keys(): 377 384 ticket = student['payments'][key] … … 380 387 ticket.p_item == p_item and \ 381 388 ticket.p_session == p_session: 382 return _('This type of payment has already been made.' + 383 ' Would you like to pay for another session?'), None 389 return _('This type of payment has already been made.'), None 384 390 payment = createObject(u'waeup.StudentOnlinePayment') 385 391 timestamp = ("%d" % int(time()*10000))[1:] -
main/waeup.kofa/trunk/src/waeup/kofa/students/viewlets.py
r9452 r9517 43 43 CourseTicketDisplayFormPage, OnlinePaymentDisplayFormPage, 44 44 AccommodationManageFormPage, BedTicketDisplayFormPage, 45 StudentClearanceEditFormPage, StudentPersonalEditFormPage) 45 StudentClearanceEditFormPage, StudentPersonalEditFormPage, 46 PaymentsManageFormPage) 46 47 from waeup.kofa.students.interfaces import ( 47 48 IStudentsContainer, IStudent, IStudentStudyCourse, IStudentAccommodation, 48 49 IStudentStudyLevel, ICourseTicket, IStudentOnlinePayment, IBedTicket, 50 IStudentPaymentsContainer, 49 51 ) 50 52 from waeup.kofa.utils.helpers import get_fileformat … … 589 591 return self.view.url(self.view.context, self.target) 590 592 return '' 593 594 class AddPaymentActionButton(AddActionButton): 595 grok.order(1) 596 grok.context(IStudentPaymentsContainer) 597 grok.view(PaymentsManageFormPage) 598 grok.require('waeup.payStudent') 599 text = _('Add current session payment ticket') 600 target = 'addop' 601 602 class AddPreviousPaymentActionButton(AddActionButton): 603 grok.order(2) 604 grok.context(IStudentPaymentsContainer) 605 grok.view(PaymentsManageFormPage) 606 grok.require('waeup.payStudent') 607 text = _('Add previous session payment ticket') 608 target = 'addpp' 609 610 @property 611 def target_url(self): 612 student = self.view.context.student 613 if student.is_fresh: 614 return '' 615 return self.view.url(self.view.context, self.target) 591 616 592 617 class StudentsTab(PrimaryNavTab):
Note: See TracChangeset for help on using the changeset viewer.