Changeset 12907 for main/waeup.kwarapoly/trunk/src/waeup/kwarapoly/students
- Timestamp:
- 6 May 2015, 10:13:38 (10 years ago)
- Location:
- main/waeup.kwarapoly/trunk/src/waeup/kwarapoly/students
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kwarapoly/trunk/src/waeup/kwarapoly/students/browser.py
r12877 r12907 50 50 51 51 from waeup.kwarapoly.students.interfaces import ( 52 ICustomStudent, 52 53 ICustomStudentOnlinePayment, 53 54 ICustomStudentPersonal, … … 509 510 # 510 511 # Burn this remark after reading. 512 513 514 class StudentGetMatricNumberPage(UtilityView, grok.View): 515 """ Construct and set the matriculation number. 516 """ 517 grok.context(ICustomStudent) 518 grok.name('get_matric_number') 519 grok.require('waeup.viewStudent') 520 521 def update(self): 522 students_utils = getUtility(IStudentsUtils) 523 msg, mnumber = students_utils.setMatricNumber(self.context) 524 if msg: 525 self.flash(msg, type="danger") 526 else: 527 self.flash(_('Matriculation number %s assigned.' % mnumber)) 528 self.context.writeLogMessage(self, '%s assigned' % mnumber) 529 self.redirect(self.url(self.context)) 530 return 531 532 def render(self): 533 return -
main/waeup.kwarapoly/trunk/src/waeup/kwarapoly/students/tests/test_browser.py
r12148 r12907 528 528 self.assertEqual(self.student.state, 'courses registered') 529 529 return 530 531 def test_set_matric_number(self): 532 # Login as student 533 self.browser.open(self.login_path) 534 IWorkflowState(self.student).setState('school fee paid') 535 self.browser.open(self.login_path) 536 self.browser.getControl(name="form.login").value = self.student_id 537 self.browser.getControl(name="form.password").value = 'spwd' 538 self.browser.getControl("Login").click() 539 self.assertRaises( 540 LinkNotFoundError, 541 self.browser.getLink, 'Get Matriculation Number') 542 self.student.matric_number = None 543 self.student['studycourse'].entry_mode = 'nd_ft' 544 self.student['studycourse'].entry_session = 2014 545 self.browser.open(self.student_path) 546 self.browser.getLink("Get Matriculation Number").click() 547 self.assertTrue('Matriculation number ND/14/dep1/FT/001 assigned.' 548 in self.browser.contents) 549 self.assertEqual(self.student.matric_number, 'ND/14/dep1/FT/001') 550 self.assertRaises( 551 LinkNotFoundError, 552 self.browser.getLink, 'Get Matriculation Number') 553 # Setting matric number is logged. 554 logfile = os.path.join( 555 self.app['datacenter'].storage, 'logs', 'students.log') 556 logcontent = open(logfile).read() 557 self.assertTrue('W1000000 - waeup.kwarapoly.students.browser.StudentGetMatricNumberPage - ' 558 'W1000000 - ND/14/dep1/FT/001 assigned' in logcontent) 559 return -
main/waeup.kwarapoly/trunk/src/waeup/kwarapoly/students/tests/test_utils.py
r12904 r12907 51 51 self.student.matric_number = None 52 52 msg, mnumber = utils.setMatricNumber(self.student) 53 self.assertEqual(msg, 'Wrong state.') 54 IWorkflowState(self.student).setState('school fee paid') 55 msg, mnumber = utils.setMatricNumber(self.student) 53 56 self.assertEqual(msg, 'Matriculation number cannot be set.') 54 57 self.assertEqual(mnumber, None) -
main/waeup.kwarapoly/trunk/src/waeup/kwarapoly/students/utils.py
r12904 r12907 24 24 from kofacustom.nigeria.students.utils import NigeriaStudentsUtils 25 25 from waeup.kofa.accesscodes import create_accesscode 26 from waeup.kofa.interfaces import CLEARED, RETURNING, ADMITTED, IKofaUtils 26 from waeup.kofa.interfaces import ( 27 CLEARED, RETURNING, ADMITTED, PAID, IKofaUtils) 27 28 from waeup.kofa.fees import FeeTable 28 29 from waeup.kofa.hostels.hostel import NOT_OCCUPIED … … 356 357 entry_mode = getattr( 357 358 student.get('studycourse', None), 'entry_mode', None) 359 if student.state not in (PAID, ): 360 return _('Wrong state.'), None 358 361 if None in (cert, entry_session, entry_mode): 359 362 return _('Matriculation number cannot be set.'), None -
main/waeup.kwarapoly/trunk/src/waeup/kwarapoly/students/viewlets.py
r11931 r12907 18 18 19 19 import grok 20 from zope.component import getUtility 20 21 from waeup.kofa.students.viewlets import ( 21 22 AddPreviousPaymentActionButton, AddBalancePaymentActionButton, 22 23 ManageActionButton) 23 from waeup.kofa.students.interfaces import IStudent 24 from waeup.kofa.students.interfaces import IStudent, IStudentsUtils 24 25 from waeup.kofa.students.browser import StudentBaseDisplayFormPage 25 26 from waeup.kofa.students.workflow import ( … … 86 87 return '' 87 88 return self.view.url(self.view.context, self.target) 89 90 91 class GetMatricNumberActionButton(ManageActionButton): 92 grok.order(10) 93 grok.context(IStudent) 94 grok.view(StudentBaseDisplayFormPage) 95 grok.require('waeup.viewStudent') 96 icon = 'actionicon_count.png' 97 text = _('Get Matriculation Number') 98 99 @property 100 def target_url(self): 101 students_utils = getUtility(IStudentsUtils) 102 if self.context.matric_number: 103 return '' 104 error, matric_number = students_utils.constructMatricNumber( 105 self.context) 106 if error: 107 return '' 108 return self.view.url(self.view.context, 'get_matric_number')
Note: See TracChangeset for help on using the changeset viewer.