Changeset 8471 for main/waeup.kofa/trunk/src/waeup/kofa
- Timestamp:
- 20 May 2012, 05:46:07 (12 years ago)
- Location:
- main/waeup.kofa/trunk/src/waeup/kofa
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/students/browser.py
r8434 r8471 1686 1686 return 1687 1687 1688 class Start CourseRegistrationPage(KofaPage):1688 class StartSessionPage(KofaPage): 1689 1689 grok.context(IStudentStudyCourse) 1690 grok.name('start_ course_registration')1690 grok.name('start_session') 1691 1691 grok.require('waeup.handleStudent') 1692 1692 grok.template('enterpin') 1693 label = _('Start course registration')1693 label = _('Start session') 1694 1694 ac_prefix = 'SFE' 1695 1695 notice = '' 1696 1696 pnav = 4 1697 buttonname = _('Start course registrationnow')1697 buttonname = _('Start now') 1698 1698 1699 1699 def update(self, SUBMIT=None): 1700 if not self.context.getStudent().state in (CLEARED,RETURNING): 1701 self.flash(_("You are in wrong state.")) 1702 self.redirect(self.url(self.context)) 1703 return 1704 if not self.context.may_register: 1705 self.flash(_("You are not entitled to start course registration.")) 1700 if not self.context.next_session_allowed: 1701 self.flash(_("You are not entitled to start session.")) 1706 1702 self.redirect(self.url(self.context)) 1707 1703 return … … 1717 1713 return 1718 1714 # Mark pin as used (this also fires a pin related transition) 1719 # and fire transition start_clearance1720 1715 if code.state == USED: 1721 1716 self.flash(_('Activation code has already been used.')) … … 1724 1719 comment = _(u"invalidated") 1725 1720 # Here we know that the ac is in state initialized so we do not 1726 # expect an e xception, but the owner might be different1721 # expect an error, but the owner might be different 1727 1722 if not invalidate_accesscode( 1728 1723 pin,comment,self.context.getStudent().student_id): … … 1735 1730 IWorkflowInfo(self.context.getStudent()).fireTransition( 1736 1731 'pay_school_fee') 1737 self.flash(_('Course registration has been started.')) 1732 elif self.context.getStudent().state == PAID: 1733 IWorkflowInfo(self.context.getStudent()).fireTransition( 1734 'pay_pg_fee') 1735 self.flash(_('Session started.')) 1738 1736 self.redirect(self.url(self.context)) 1739 1737 return -
main/waeup.kofa/trunk/src/waeup/kofa/students/studycourse.py
r8337 r8471 27 27 IStudentStudyCourse, IStudentNavigation, IStudentStudyLevel) 28 28 from waeup.kofa.students.studylevel import CourseTicket 29 from waeup.kofa.students.workflow import CLEARED, RETURNING, PAID 29 30 from waeup.kofa.utils.helpers import attrs_to_fields 30 31 … … 43 44 44 45 @property 45 def may_register(self): 46 return True 46 def next_session_allowed(self): 47 if self.getStudent().state in (CLEARED, RETURNING): 48 return True 49 if self.getStudent().state == PAID \ 50 and self.getStudent().current_mode.startswith('pg'): 51 return True 52 return False 47 53 48 54 def addStudentStudyLevel(self, cert, studylevel): -
main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_browser.py
r8468 r8471 1483 1483 self.assertTrue('Successfully removed' in self.browser.contents) 1484 1484 1485 # The new SFE-0 pin can be used for starting course registration1485 # The new SFE-0 pin can be used for starting new session 1486 1486 self.browser.open(self.studycourse_path) 1487 self.browser.getLink('Start course registration').click()1487 self.browser.getLink('Start session').click() 1488 1488 pin = self.app['accesscodes']['SFE-0'].keys()[0] 1489 1489 parts = pin.split('-')[1:] … … 1491 1491 self.browser.getControl(name="ac_series").value = sfeseries 1492 1492 self.browser.getControl(name="ac_number").value = sfenumber 1493 self.browser.getControl("Start course registrationnow").click()1494 self.assertMatches('... Course registration has been started...',1493 self.browser.getControl("Start now").click() 1494 self.assertMatches('...Session started...', 1495 1495 self.browser.contents) 1496 1496 self.assertTrue(self.student.state == 'school fee paid') 1497 return 1498 1499 def test_postgraduate_payments(self): 1500 self.certificate.study_mode = 'pg_ft' 1501 self.certificate.start_level = 999 1502 self.certificate.end_level = 999 1503 self.student['studycourse'].current_level = 999 1504 # Login 1505 self.browser.open(self.login_path) 1506 self.browser.getControl(name="form.login").value = self.student_id 1507 self.browser.getControl(name="form.password").value = 'spwd' 1508 self.browser.getControl("Login").click() 1509 # Students can add online school fee payment tickets. 1510 IWorkflowState(self.student).setState('cleared') 1511 self.browser.open(self.payments_path) 1512 self.browser.getControl("Add online payment ticket").click() 1513 self.browser.getControl(name="form.p_category").value = ['schoolfee'] 1514 self.browser.getControl("Create ticket").click() 1515 self.assertMatches('...ticket created...', 1516 self.browser.contents) 1517 ctrl = self.browser.getControl(name='val_id') 1518 value = ctrl.options[0] 1519 self.browser.getLink(value).click() 1520 self.assertMatches('...Amount Authorized...', 1521 self.browser.contents) 1522 # Payment session and level are current ones. 1523 # Postgrads have to school_fee_1. 1524 self.assertEqual(self.student['payments'][value].amount_auth, 40000.0) 1525 self.assertEqual(self.student['payments'][value].p_session, 2004) 1526 self.assertEqual(self.student['payments'][value].p_level, 999) 1527 1528 # We simulate the approval 1529 self.assertEqual(len(self.app['accesscodes']['SFE-0']),0) 1530 self.browser.open(self.browser.url + '/fake_approve') 1531 self.assertMatches('...Successful payment...', 1532 self.browser.contents) 1533 1534 # The new SFE-0 pin can be used for starting session 1535 self.browser.open(self.studycourse_path) 1536 self.browser.getLink('Start session').click() 1537 pin = self.app['accesscodes']['SFE-0'].keys()[0] 1538 parts = pin.split('-')[1:] 1539 sfeseries, sfenumber = parts 1540 self.browser.getControl(name="ac_series").value = sfeseries 1541 self.browser.getControl(name="ac_number").value = sfenumber 1542 self.browser.getControl("Start now").click() 1543 self.assertMatches('...Session started...', 1544 self.browser.contents) 1545 self.assertTrue(self.student.state == 'school fee paid') 1546 1547 # Postgrad students do not need to register courses the 1548 # can just pay for the next session. 1549 self.browser.open(self.payments_path) 1550 # Remove first payment to be sure that we access the right ticket 1551 del self.student['payments'][value] 1552 self.browser.getControl("Add online payment ticket").click() 1553 self.browser.getControl(name="form.p_category").value = ['schoolfee'] 1554 self.browser.getControl("Create ticket").click() 1555 ctrl = self.browser.getControl(name='val_id') 1556 value = ctrl.options[0] 1557 self.browser.getLink(value).click() 1558 # Payment session has increased by one, payment level remains the same. 1559 # Returning Postgraduates have to pay school_fee_2. 1560 self.assertEqual(self.student['payments'][value].amount_auth, 20000.0) 1561 self.assertEqual(self.student['payments'][value].p_session, 2005) 1562 self.assertEqual(self.student['payments'][value].p_level, 999) 1563 1564 # Student is still in old session 1565 self.assertEqual(self.student.current_session, 2004) 1566 1567 # We do not need to pay the ticket if any other 1568 # SFE pin is provided 1569 pin_container = self.app['accesscodes'] 1570 pin_container.createBatch( 1571 datetime.utcnow(), 'some_userid', 'SFE', 9.99, 1) 1572 pin = pin_container['SFE-1'].values()[0].representation 1573 sfeseries, sfenumber = pin.split('-')[1:] 1574 # The new SFE-1 pin can be used for starting new session 1575 self.browser.open(self.studycourse_path) 1576 self.browser.getLink('Start session').click() 1577 self.browser.getControl(name="ac_series").value = sfeseries 1578 self.browser.getControl(name="ac_number").value = sfenumber 1579 self.browser.getControl("Start now").click() 1580 self.assertMatches('...Session started...', 1581 self.browser.contents) 1582 self.assertTrue(self.student.state == 'school fee paid') 1583 # Student is in new session 1584 self.assertEqual(self.student.current_session, 2005) 1585 self.assertEqual(self.student['studycourse'].current_level, 999) 1497 1586 return 1498 1587 -
main/waeup.kofa/trunk/src/waeup/kofa/students/utils.py
r8420 r8471 36 36 from zope.formlib.form import setUpEditWidgets 37 37 38 from waeup.kofa.interfaces import IExtFileStore, IKofaUtils, RETURNING 38 from waeup.kofa.interfaces import IExtFileStore, IKofaUtils, RETURNING, PAID 39 39 from waeup.kofa.interfaces import MessageFactory as _ 40 40 from waeup.kofa.students.interfaces import IStudentsUtils … … 278 278 details['p_session'], details[ 279 279 'p_level'] = self.getReturningData(student) 280 elif student.current_mode.startswith('pg') and student.state == PAID: 281 # Returning postgraduate students also pay for the next session 282 # but their level always remains the same. 283 details['p_session'] += 1 284 details['amount'] = getattr( 285 student['studycourse'].certificate,'school_fee_2') 280 286 elif category == 'clearance': 281 287 details['p_item'] = student['studycourse'].certificate.code -
main/waeup.kofa/trunk/src/waeup/kofa/students/viewlets.py
r8467 r8471 431 431 return self.view.url(self.view.context, self.target) 432 432 433 class CourseRegistrationStartActionButton(ManageActionButton):433 class SartSessionActionButton(ManageActionButton): 434 434 grok.order(1) 435 435 grok.context(IStudentStudyCourse) … … 437 437 grok.require('waeup.handleStudent') 438 438 icon = 'actionicon_start.gif' 439 text = _('Start course registration') 440 target = 'start_course_registration' 441 442 @property 443 def target_url(self): 444 if not self.context.getStudent().state in (CLEARED,RETURNING) \ 445 or not self.context.may_register: 446 return '' 447 return self.view.url(self.view.context, self.target) 439 text = _('Start session') 440 target = 'start_session' 441 442 @property 443 def target_url(self): 444 if self.context.next_session_allowed: 445 return self.view.url(self.view.context, self.target) 446 return False 448 447 449 448 class AddStudyLevelActionButton(AddActionButton): -
main/waeup.kofa/trunk/src/waeup/kofa/students/vocabularies.py
r8098 r8471 40 40 start_level = int(studycourse.certificate.start_level) 41 41 end_level = int(studycourse.certificate.end_level) 42 if start_level == 10: 42 if start_level == 999 or end_level == 999: 43 levels = [999] 44 elif start_level == 10: 43 45 levels = [10,] + [level for level in range(100,end_level+200,10) 44 46 if level % 100 < 30] … … 73 75 start_level = 100 74 76 end_level = 1000 77 if start_level == 999 or end_level == 999: 78 if value != 999: 79 return _('Error: wrong level id ${value}', 80 mapping={'value': value}) 81 return course_levels.by_value[999].title 75 82 if value < start_level or value > end_level + 120: 76 83 return _('Error: level id ${value} out of range', -
main/waeup.kofa/trunk/src/waeup/kofa/students/workflow.py
r8434 r8471 106 106 transition_id = 'pay_school_fee', 107 107 title = _('Pay school fee'), 108 msg = _(' School fee paid'),108 msg = _('Payment made'), 109 109 source = RETURNING, 110 destination = PAID), 111 112 Transition( 113 transition_id = 'pay_pg_fee', 114 title = _('Pay postgraduate school fee'), 115 msg = _('Payment made'), 116 source = PAID, 110 117 destination = PAID), 111 118 … … 115 122 msg = _('School fee payment approved'), 116 123 source = RETURNING, 124 destination = PAID), 125 126 Transition( 127 transition_id = 'approve_pg_fee', 128 title = _('Approve postgraduate payment'), 129 msg = _('School fee payment approved'), 130 source = PAID, 117 131 destination = PAID), 118 132 … … 198 212 199 213 Lock and unlock clearance form. 214 Triger actions after school fee payment. 200 215 """ 201 216 … … 212 227 'pay_school_fee', 'approve_school_fee'): 213 228 getUtility(IStudentsUtils).setReturningData(obj) 229 elif event.transition.transition_id in ( 230 'pay_pg_fee', 'approve_pg_fee'): 231 new_session = obj['studycourse'].current_session + 1 232 obj['studycourse'].current_session = new_session 214 233 # In some tests we don't have a students container 215 234 try: -
main/waeup.kofa/trunk/src/waeup/kofa/university/vocabularies.py
r8439 r8471 37 37 (_('800 (Year 8)'),800), 38 38 (_('900 (Year 9)'),900), 39 (_('Postgraduate Level'),999), 39 40 ) 40 41
Note: See TracChangeset for help on using the changeset viewer.