Changeset 7993 for main/waeup.kofa/trunk/src/waeup
- Timestamp:
- 27 Mar 2012, 20:59:30 (13 years ago)
- Location:
- main/waeup.kofa/trunk/src/waeup/kofa
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/students/browser.py
r7878 r7993 49 49 from waeup.kofa.widgets.phonewidget import PhoneWidget 50 50 from waeup.kofa.students.interfaces import ( 51 IStudentsContainer, IStudent, IStudentClearance, 51 IStudentsContainer, IStudent, 52 IUGStudentClearance,IPGStudentClearance, 52 53 IStudentPersonal, IStudentBase, IStudentStudyCourse, 53 54 IStudentAccommodation, IStudentStudyLevel, … … 393 394 grok.name('view_clearance') 394 395 grok.require('waeup.viewStudent') 395 form_fields = grok.AutoFields(IStudentClearance).omit('clearance_locked') 396 form_fields['date_of_birth'].custom_widget = FriendlyDateDisplayWidget('le') 397 pnav = 4 396 pnav = 4 397 398 @property 399 def form_fields(self): 400 cm = getattr(self.context,'current_mode', None) 401 if cm is not None and cm.startswith('pg'): 402 form_fields = grok.AutoFields(IPGStudentClearance).omit('clearance_locked') 403 else: 404 form_fields = grok.AutoFields(IUGStudentClearance).omit('clearance_locked') 405 form_fields['date_of_birth'].custom_widget = FriendlyDateDisplayWidget('le') 406 return form_fields 398 407 399 408 @property … … 408 417 grok.name('clearance.pdf') 409 418 grok.require('waeup.viewStudent') 410 form_fields = grok.AutoFields(IStudentClearance).omit('clearance_locked')411 form_fields['date_of_birth'].custom_widget = FriendlyDateDisplayWidget('le')412 419 prefix = 'form' 420 421 @property 422 def form_fields(self): 423 cm = getattr(self.context,'current_mode', None) 424 if cm is not None and cm.startswith('pg'): 425 form_fields = grok.AutoFields(IPGStudentClearance).omit('clearance_locked') 426 else: 427 form_fields = grok.AutoFields(IUGStudentClearance).omit('clearance_locked') 428 form_fields['date_of_birth'].custom_widget = FriendlyDateDisplayWidget('le') 429 return form_fields 413 430 414 431 @property … … 440 457 grok.require('waeup.manageStudent') 441 458 grok.template('clearanceeditpage') 442 form_fields = grok.AutoFields(IStudentClearance)443 459 label = _('Manage clearance data') 444 460 pnav = 4 445 form_fields['date_of_birth'].custom_widget = FriendlyDateWidget('le-year') 461 462 @property 463 def form_fields(self): 464 cm = getattr(self.context,'current_mode', None) 465 if cm is not None and cm.startswith('pg'): 466 form_fields = grok.AutoFields(IPGStudentClearance) 467 else: 468 form_fields = grok.AutoFields(IUGStudentClearance) 469 form_fields['date_of_birth'].custom_widget = FriendlyDateWidget('le-year') 470 return form_fields 446 471 447 472 def update(self): … … 1561 1586 grok.name('cedit') 1562 1587 grok.require('waeup.handleStudent') 1563 form_fields = grok.AutoFields(1564 IStudentClearance).omit('clearance_locked')1565 1588 label = _('Edit clearance data') 1566 form_fields['date_of_birth'].custom_widget = FriendlyDateWidget('le-year') 1589 1590 @property 1591 def form_fields(self): 1592 cm = getattr(self.context,'current_mode', None) 1593 if cm is not None and cm.startswith('pg'): 1594 form_fields = grok.AutoFields(IPGStudentClearance).omit('clearance_locked') 1595 else: 1596 form_fields = grok.AutoFields(IUGStudentClearance).omit('clearance_locked') 1597 form_fields['date_of_birth'].custom_widget = FriendlyDateWidget('le-year') 1598 return form_fields 1567 1599 1568 1600 def update(self): -
main/waeup.kofa/trunk/src/waeup/kofa/students/interfaces.py
r7983 r7993 211 211 ) 212 212 213 class I StudentClearance(IKofaObject):214 """Representation of student clearance data.213 class IUGStudentClearance(IKofaObject): 214 """Representation of undergraduate student clearance data. 215 215 216 216 """ … … 238 238 ) 239 239 240 class IPGStudentClearance(IUGStudentClearance): 241 """Representation of postgraduate student clearance data. 242 243 """ 244 employer = schema.TextLine( 245 title = _(u'Employer'), 246 required = False, 247 readonly = False, 248 ) 249 240 250 class IStudentPersonal(IKofaObject): 241 251 """Representation of student personal data. … … 247 257 ) 248 258 249 class IStudent(IStudentBase,I StudentClearance,IStudentPersonal):259 class IStudent(IStudentBase,IUGStudentClearance,IPGStudentClearance,IStudentPersonal): 250 260 """Representation of a student. 251 261 -
main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_browser.py
r7983 r7993 109 109 self.student_path = self.container_path + '/' + self.student_id 110 110 self.manage_student_path = self.student_path + '/manage_base' 111 self.clearance_student_path = self.student_path + '/view_clearance' 112 self.personal_student_path = self.student_path + '/view_personal' 113 self.edit_clearance_student_path = self.student_path + '/edit_clearance' 114 self.edit_personal_student_path = self.student_path + '/edit_personal' 115 self.studycourse_student_path = self.student_path + '/studycourse' 116 self.payments_student_path = self.student_path + '/payments' 117 self.acco_student_path = self.student_path + '/accommodation' 118 self.history_student_path = self.student_path + '/history' 111 self.clearance_path = self.student_path + '/view_clearance' 112 self.personal_path = self.student_path + '/view_personal' 113 self.edit_clearance_path = self.student_path + '/cedit' 114 self.manage_clearance_path = self.student_path + '/edit_clearance' 115 self.edit_personal_path = self.student_path + '/edit_personal' 116 self.studycourse_path = self.student_path + '/studycourse' 117 self.payments_path = self.student_path + '/payments' 118 self.acco_path = self.student_path + '/accommodation' 119 self.history_path = self.student_path + '/history' 119 120 120 121 # Create 5 access codes with prefix'PWD' … … 399 400 self.browser.getLink("Clearance Data").click() 400 401 self.assertEqual(self.browser.headers['Status'], '200 Ok') 401 self.assertEqual(self.browser.url, self.clearance_ student_path)402 self.assertEqual(self.browser.url, self.clearance_path) 402 403 self.browser.getLink("Manage").click() 403 404 self.assertEqual(self.browser.headers['Status'], '200 Ok') 404 self.assertEqual(self.browser.url, self. edit_clearance_student_path)405 self.assertEqual(self.browser.url, self.manage_clearance_path) 405 406 self.browser.getControl(name="form.date_of_birth").value = '09/10/1961' 406 407 self.browser.getControl("Save").click() … … 411 412 self.browser.getLink("Personal Data").click() 412 413 self.assertEqual(self.browser.headers['Status'], '200 Ok') 413 self.assertEqual(self.browser.url, self.personal_ student_path)414 self.assertEqual(self.browser.url, self.personal_path) 414 415 self.browser.getLink("Edit").click() 415 416 self.assertEqual(self.browser.headers['Status'], '200 Ok') 416 self.assertEqual(self.browser.url, self.edit_personal_ student_path)417 self.assertEqual(self.browser.url, self.edit_personal_path) 417 418 self.browser.getControl("Save").click() 418 419 self.assertMatches('...Form has been saved...', … … 423 424 self.browser.getLink("Payments").click() 424 425 self.assertEqual(self.browser.headers['Status'], '200 Ok') 425 self.assertEqual(self.browser.url, self.payments_ student_path)426 self.assertEqual(self.browser.url, self.payments_path) 426 427 self.browser.open(self.student_path) 427 428 self.browser.getLink("Accommodation").click() 428 429 self.assertEqual(self.browser.headers['Status'], '200 Ok') 429 self.assertEqual(self.browser.url, self.acco_ student_path)430 self.assertEqual(self.browser.url, self.acco_path) 430 431 self.browser.open(self.student_path) 431 432 self.browser.getLink("History").click() 432 433 self.assertEqual(self.browser.headers['Status'], '200 Ok') 433 self.assertEqual(self.browser.url, self.history_ student_path)434 self.assertEqual(self.browser.url, self.history_path) 434 435 self.assertMatches('...Student admitted by Manager...', 435 436 self.browser.contents) … … 477 478 # The image is stored even if form has errors 478 479 self.browser.addHeader('Authorization', 'Basic mgr:mgrpw') 479 self.browser.open(self. edit_clearance_student_path)480 self.browser.open(self.manage_clearance_path) 480 481 # No birth certificate has been uploaded yet 481 482 # Browsing the link shows a placerholder image … … 486 487 # Create a pseudo image file and select it to be uploaded in form 487 488 # as birth certificate 488 self.browser.open(self. edit_clearance_student_path)489 self.browser.open(self.manage_clearance_path) 489 490 pseudo_image = StringIO('I pretend to be a graphics file') 490 491 ctrl = self.browser.getControl(name='birthcertificateupload') … … 514 515 self.assertEqual(len(self.browser.contents), 31) 515 516 # Reuploading a file which is bigger than 150k will raise an error 516 self.browser.open(self. edit_clearance_student_path)517 self.browser.open(self.manage_clearance_path) 517 518 photo_content = 'A' * 1024 * 151 # A string of 21 KB size 518 519 pseudo_image = StringIO(photo_content) … … 551 552 'birth_certificate deleted' in self.browser.contents) 552 553 # Managers can add and delete second file 553 self.browser.open(self. edit_clearance_student_path)554 self.browser.open(self.manage_clearance_path) 554 555 pseudo_image = StringIO('I pretend to be a graphics file') 555 556 ctrl = self.browser.getControl(name='birthcertificateupload') … … 609 610 self.browser.getLink("Study Course").click() 610 611 self.assertEqual(self.browser.headers['Status'], '200 Ok') 611 self.assertEqual(self.browser.url, self.studycourse_ student_path)612 self.assertEqual(self.browser.url, self.studycourse_path) 612 613 self.assertTrue('Undergraduate Full-Time' in self.browser.contents) 613 614 self.browser.getLink("Manage").click() … … 840 841 self.browser.contents) 841 842 # CO can view the student ... 842 self.browser.open(self.clearance_ student_path)843 self.assertEqual(self.browser.headers['Status'], '200 Ok') 844 self.assertEqual(self.browser.url, self.clearance_ student_path)843 self.browser.open(self.clearance_path) 844 self.assertEqual(self.browser.headers['Status'], '200 Ok') 845 self.assertEqual(self.browser.url, self.clearance_path) 845 846 # ... but not other students 846 847 other_student = Student() … … 853 854 Unauthorized, self.browser.open, other_student_path) 854 855 # Only in state clearance requested the CO does see the 'Clear' button 855 self.browser.open(self.clearance_ student_path)856 self.browser.open(self.clearance_path) 856 857 self.assertFalse('Clear student' in self.browser.contents) 857 858 IWorkflowInfo(self.student).fireTransition('request_clearance') 858 self.browser.open(self.clearance_ student_path)859 self.browser.open(self.clearance_path) 859 860 self.assertTrue('Clear student' in self.browser.contents) 860 861 self.browser.getLink("Clear student").click() … … 869 870 self.assertTrue('clearance started' in self.browser.contents) 870 871 IWorkflowInfo(self.student).fireTransition('request_clearance') 871 self.browser.open(self.clearance_ student_path)872 self.browser.open(self.clearance_path) 872 873 self.browser.getLink("Reject clearance").click() 873 874 self.assertTrue('Clearance request has been rejected' … … 941 942 self.student['studycourse'].addStudentStudyLevel( 942 943 cert,studylevel) 943 L110_student_path = self.studycourse_ student_path + '/110'944 L110_student_path = self.studycourse_path + '/110' 944 945 # Only in state courses registered and only if the current level 945 946 # corresponds with the name of the study level object … … 958 959 self.student['studycourse'].addStudentStudyLevel( 959 960 cert,studylevel2) 960 L200_student_path = self.studycourse_ student_path + '/200'961 L200_student_path = self.studycourse_path + '/200' 961 962 self.browser.open(L200_student_path) 962 963 self.assertFalse('Validate' in self.browser.contents) … … 1220 1221 # if certain requirements are met 1221 1222 self.browser.addHeader('Authorization', 'Basic mgr:mgrpw') 1222 self.browser.open(self.payments_ student_path)1223 self.browser.open(self.payments_path) 1223 1224 self.browser.getControl("Add online payment ticket").click() 1224 1225 self.browser.getControl(name="form.p_category").value = ['schoolfee'] … … 1240 1241 # The same payment (with same p_item, p_session and p_category) 1241 1242 # can be initialized a second time if the former ticket is not yet paid. 1242 self.browser.open(self.payments_ student_path)1243 self.browser.open(self.payments_path) 1243 1244 self.browser.getControl("Add online payment ticket").click() 1244 1245 self.browser.getControl(name="form.p_category").value = ['schoolfee'] … … 1261 1262 # Now the first ticket is paid and no more ticket of same type 1262 1263 # (with same p_item, p_session and p_category) can be added 1263 self.browser.open(self.payments_ student_path)1264 self.browser.open(self.payments_path) 1264 1265 self.browser.getControl("Add online payment ticket").click() 1265 1266 self.browser.getControl(name="form.p_category").value = ['schoolfee'] … … 1276 1277 1277 1278 # Managers can remove online school fee payment tickets 1278 self.browser.open(self.payments_ student_path)1279 self.browser.open(self.payments_path) 1279 1280 self.browser.getControl("Remove selected").click() 1280 1281 self.assertMatches('...No payment selected...', self.browser.contents) … … 1286 1287 1287 1288 # Managers can add online clearance payment tickets 1288 self.browser.open(self.payments_ student_path + '/addop')1289 self.browser.open(self.payments_path + '/addop') 1289 1290 self.browser.getControl(name="form.p_category").value = ['clearance'] 1290 1291 self.browser.getControl("Create ticket").click() … … 1320 1321 1321 1322 # Students can add online clearance payment tickets 1322 self.browser.open(self.payments_ student_path + '/addop')1323 self.browser.open(self.payments_path + '/addop') 1323 1324 self.browser.getControl(name="form.p_category").value = ['clearance'] 1324 1325 self.browser.getControl("Create ticket").click() … … 1375 1376 1376 1377 # Students can add online school fee payment tickets 1377 self.browser.open(self.payments_ student_path)1378 self.browser.open(self.payments_path) 1378 1379 self.browser.getControl("Add online payment ticket").click() 1379 1380 self.browser.getControl(name="form.p_category").value = ['schoolfee'] … … 1395 1396 # Students can remove only online payment tickets which have 1396 1397 # not received a valid callback 1397 self.browser.open(self.payments_ student_path)1398 self.browser.open(self.payments_path) 1398 1399 self.assertRaises( 1399 1400 LookupError, self.browser.getControl, name='val_id') 1400 self.browser.open(self.payments_ student_path + '/addop')1401 self.browser.open(self.payments_path + '/addop') 1401 1402 self.browser.getControl(name="form.p_category").value = ['gown'] 1402 1403 self.browser.getControl("Create ticket").click() 1403 self.browser.open(self.payments_ student_path)1404 self.browser.open(self.payments_path) 1404 1405 ctrl = self.browser.getControl(name='val_id') 1405 1406 value = ctrl.options[0] … … 1411 1412 IWorkflowInfo(self.student).fireTransition('request_clearance') 1412 1413 IWorkflowInfo(self.student).fireTransition('clear') 1413 self.browser.open(self.studycourse_ student_path)1414 self.browser.open(self.studycourse_path) 1414 1415 self.browser.getLink('Start course registration').click() 1415 1416 pin = self.app['accesscodes']['SFE-0'].keys()[0] … … 1428 1429 # callback view (see test_manage_payments) 1429 1430 self.browser.addHeader('Authorization', 'Basic mgr:mgrpw') 1430 self.browser.open(self.payments_ student_path)1431 self.browser.open(self.payments_path) 1431 1432 self.browser.getControl("Add online payment ticket").click() 1432 1433 self.browser.getControl(name="form.p_category").value = ['bed_allocation'] … … 1452 1453 sfeseries, sfenumber = parts 1453 1454 # Managers can use HOS code and book a bed space with it 1454 self.browser.open(self.acco_ student_path)1455 self.browser.open(self.acco_path) 1455 1456 self.browser.getLink("Book accommodation").click() 1456 1457 self.assertMatches('...You are in the wrong...', … … 1481 1482 self.browser.contents) 1482 1483 # The bed ticket displays the data correctly 1483 self.browser.open(self.acco_ student_path + '/2004')1484 self.browser.open(self.acco_path + '/2004') 1484 1485 self.assertMatches('...Hall 1, Block A, Room 101, Bed A...', 1485 1486 self.browser.contents) … … 1529 1530 self.assertMatches(old_owner, self.student_id) 1530 1531 bed2.owner = self.student_id 1531 self.browser.open(self.acco_ student_path + '/2004')1532 self.browser.open(self.acco_path + '/2004') 1532 1533 self.assertMatches( 1533 1534 "...booking cancelled...", self.browser.contents) … … 1545 1546 "... Hall 1, Block A, Room 101, Bed B...", self.browser.contents) 1546 1547 # Managers can delete bed tickets 1547 self.browser.open(self.acco_ student_path)1548 self.browser.open(self.acco_path) 1548 1549 ctrl = self.browser.getControl(name='val_id') 1549 1550 value = ctrl.options[0] … … 1582 1583 1583 1584 # Students can use HOS code and book a bed space with it 1584 self.browser.open(self.acco_ student_path)1585 self.browser.open(self.acco_path) 1585 1586 self.browser.getLink("Book accommodation").click() 1586 1587 self.assertMatches('...You are in the wrong...', … … 1617 1618 1618 1619 # The bed ticket displays the data correctly 1619 self.browser.open(self.acco_ student_path + '/2004')1620 self.browser.open(self.acco_path + '/2004') 1620 1621 self.assertMatches('...Hall 1, Block A, Room 101, Bed A...', 1621 1622 self.browser.contents) … … 1631 1632 # Students can't relocate themselves 1632 1633 self.assertFalse('Relocate' in self.browser.contents) 1633 relocate_path = self.acco_ student_path + '/2004/relocate'1634 relocate_path = self.acco_path + '/2004/relocate' 1634 1635 self.assertRaises( 1635 1636 Unauthorized, self.browser.open, relocate_path) 1636 1637 1637 1638 # Students can't the Remove button and check boxes 1638 self.browser.open(self.acco_ student_path)1639 self.browser.open(self.acco_path) 1639 1640 self.assertFalse('Remove' in self.browser.contents) 1640 1641 self.assertFalse('val_id' in self.browser.contents) … … 1664 1665 results = cat.searchResults(student_id=(None, None)) 1665 1666 self.assertEqual(len(results),1) 1667 1668 def test_change_current_mode(self): 1669 self.browser.addHeader('Authorization', 'Basic mgr:mgrpw') 1670 self.browser.open(self.clearance_path) 1671 self.assertFalse('Employer' in self.browser.contents) 1672 self.browser.open(self.manage_clearance_path) 1673 self.assertFalse('Employer' in self.browser.contents) 1674 self.student.clearance_locked = False 1675 self.browser.open(self.edit_clearance_path) 1676 self.assertFalse('Employer' in self.browser.contents) 1677 # Now we change the study mode of the certificate and a different 1678 # interface is used by clearance views 1679 self.certificate.study_mode = 'pg_ft' 1680 self.browser.open(self.clearance_path) 1681 self.assertTrue('Employer' in self.browser.contents) 1682 self.browser.open(self.manage_clearance_path) 1683 self.assertTrue('Employer' in self.browser.contents) 1684 self.browser.open(self.edit_clearance_path) 1685 self.assertTrue('Employer' in self.browser.contents) -
main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_export.py
r7973 r7993 66 66 self.assertEqual( 67 67 result, 68 'adm_code,clearance_locked,clr_code,date_of_birth,email, '68 'adm_code,clearance_locked,clr_code,date_of_birth,email,employer,' 69 69 'firstname,lastname,matric_number,middlename,nationality,' 70 70 'perm_address,phone,reg_number,sex,student_id\r\n' 71 71 72 'my adm code,0,my clr code,1981-02-04#,anna@sample.com, Anna,'72 'my adm code,0,my clr code,1981-02-04#,anna@sample.com,,Anna,' 73 73 'Tester,M123456,M.,nigeria,"Studentroad 21\nLagos 123456\n",' 74 74 '+234-123-12345,123456,f,A111111\r\n' … … 85 85 self.assertEqual( 86 86 result, 87 'adm_code,clearance_locked,clr_code,date_of_birth,email, '87 'adm_code,clearance_locked,clr_code,date_of_birth,email,employer,' 88 88 'firstname,lastname,matric_number,middlename,nationality,' 89 89 'perm_address,phone,reg_number,sex,student_id\r\n' 90 90 91 'my adm code,0,my clr code,1981-02-04#,anna@sample.com, Anna,'91 'my adm code,0,my clr code,1981-02-04#,anna@sample.com,,Anna,' 92 92 'Tester,M123456,M.,nigeria,"Studentroad 21\nLagos 123456\n",' 93 93 '+234-123-12345,123456,f,A111111\r\n' -
main/waeup.kofa/trunk/src/waeup/kofa/students/utils.py
r7927 r7993 380 380 381 381 VERDICTS_DICT = { 382 '0': 'not yet',382 '0': _('(not yet)'), 383 383 'A': 'Successful student', 384 384 'B': 'Student with carryover courses', -
main/waeup.kofa/trunk/src/waeup/kofa/students/viewlets.py
r7888 r7993 41 41 AccommodationManageFormPage, BedTicketDisplayFormPage,) 42 42 from waeup.kofa.students.interfaces import ( 43 IStudentsContainer, IStudent, IStudentClearance,43 IStudentsContainer, IStudent, 44 44 IStudentStudyCourse, IStudentAccommodation, IStudentStudyLevel, 45 45 ICourseTicket, IStudentOnlinePayment, IBedTicket, … … 600 600 """ 601 601 grok.baseclass() 602 grok.context(IStudent Clearance)602 grok.context(IStudent) 603 603 grok.viewletmanager(FileManager) 604 604 grok.view(StudentClearanceDisplayFormPage) … … 623 623 """ 624 624 grok.baseclass() 625 grok.context(IStudent Clearance)625 grok.context(IStudent) 626 626 grok.viewletmanager(FileManager) 627 627 grok.view(StudentClearanceManageFormPage) … … 744 744 grok.baseclass() 745 745 grok.name('none.jpg') 746 grok.context(IStudent Clearance)746 grok.context(IStudent) 747 747 grok.require('waeup.viewStudent') 748 748 download_name = u'none.jpg' -
main/waeup.kofa/trunk/src/waeup/kofa/utils/utils.py
r7969 r7993 122 122 'ug_ft': 'Undergraduate Full-Time', 123 123 'ug_pt': 'Undergraduate Part-Time', 124 'pg_ft': 'Postgraduate Full-Time', 125 'pg_pt': 'Postgraduate Part-Time', 124 126 } 125 127
Note: See TracChangeset for help on using the changeset viewer.