Changeset 9296 for main/waeup.kofa/trunk
- Timestamp:
- 5 Oct 2012, 05:42:19 (12 years ago)
- Location:
- main/waeup.kofa/trunk/src/waeup/kofa/students
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/students/batching.py
r9295 r9296 28 28 from time import time 29 29 from datetime import datetime 30 from zope.i18n import translate 30 31 from zope.interface import Interface 31 32 from zope.schema import getFields … … 37 38 IBatchProcessor, FatalCSVError, IObjectConverter, IUserAccount, 38 39 IObjectHistory, VALIDATED, REGISTERED, IGNORE_MARKER) 40 from waeup.kofa.interfaces import IKofaUtils 39 41 from waeup.kofa.interfaces import MessageFactory as _ 40 42 from waeup.kofa.students.interfaces import ( … … 721 723 'current_session', 722 724 'current_level', 723 'bypass_validation'] 725 'bypass_validation', 726 'validated_by'] 724 727 725 728 def checkUpdateRequirements(self, obj, row, site): … … 741 744 return 'Study level object is missing.' 742 745 # Check if student is in state REGISTERED or VALIDATED 743 if row.get('bypass_validation') in ('1', 'True', 'TRUE', 'yes'):746 if row.get('bypass_validation'): 744 747 if obj.student.state not in (VALIDATED, REGISTERED): 745 748 return 'Student in wrong state.' … … 760 763 level_string = str(obj.current_level) 761 764 obj[level_string].level_verdict = row['current_verdict'] 762 # Fire transition depending on student's state 765 # Fire transition and set studylevel attributes 766 # depending on student's state 763 767 if obj.__parent__.state == REGISTERED: 768 validated_by = row.get('validated_by', '') 769 if validated_by in (IGNORE_MARKER, ''): 770 portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE 771 system = translate(_('System'),'waeup.kofa', 772 target_language=portal_language) 773 obj[level_string].validated_by = system 774 else: 775 obj[level_string].validated_by = validated_by 776 obj[level_string].validation_date = datetime.utcnow() 764 777 IWorkflowInfo(obj.__parent__).fireTransition('bypass_validation') 765 obj[level_string].validated_by = _('System')766 obj[level_string].validation_date = datetime.utcnow()767 778 else: 768 779 IWorkflowInfo(obj.__parent__).fireTransition('return') -
main/waeup.kofa/trunk/src/waeup/kofa/students/interfaces.py
r9257 r9296 423 423 ) 424 424 425 bypass_validation = schema.Bool( 426 title = _(u'Bypass validation'), 427 required = False, 428 ) 429 430 validated_by = schema.TextLine( 431 title = _(u'Validated by'), 432 required = False, 433 ) 434 425 435 class IStudentStudyLevel(IKofaObject): 426 436 """A container for course tickets. -
main/waeup.kofa/trunk/src/waeup/kofa/students/tests/sample_student_data.csv
r9293 r9296 8 8 X111111,Fabian,Riester,7,1990-01-02,100006,aa@aa.ng,1234,m,courses validated 9 9 X222222,Thomas,Kinderman,8,1990-01-02,100007,aa@aa.ng,1234,m,courses validated 10 X333333,Paula,Schall,9,1990-01-02,100008,aa@aa.ng,1234,m,courses registered -
main/waeup.kofa/trunk/src/waeup/kofa/students/tests/sample_studycourse_data.csv
r9293 r9296 9 9 7,,CERT1,2008,200 10 10 8,,CERT1,2008,200 11 9,,CERT1,2008,200 -
main/waeup.kofa/trunk/src/waeup/kofa/students/tests/sample_studylevel_data.csv
r9293 r9296 10 10 6,,2008,A,200 11 11 7,,2008,A,200 12 9,,2008,A,200 -
main/waeup.kofa/trunk/src/waeup/kofa/students/tests/sample_verdict_data.csv
r9293 r9296 1 matric_number,current_session,current_level,current_verdict,bypass_validation 2 100000,2008,200,0,0 3 100001,2008,100,B,False 4 100002,2007,200,C, 5 100003,2008,200,A, 6 100004,2008,200,, 7 100005,2008,200,A,1 8 100006,2008,200,A,True 9 100007,2008,200,A,True 1 matric_number,current_session,current_level,current_verdict,bypass_validation,validated_by 2 100000,2008,200,0,0, 3 100001,2008,100,B,False, 4 100002,2007,200,C,, 5 100003,2008,200,A,, 6 100004,2008,200,,, 7 100005,2008,200,A,1, 8 100006,2008,200,A,True, 9 100007,2008,200,A,True, 10 100008,2008,200,A,True,Juliana -
main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_batching.py
r9295 r9296 360 360 self.csv_file, STUDENT_HEADER_FIELDS) 361 361 self.assertEqual(num_warns,0) 362 self.assertEqual(len(self.app['students']), 9)362 self.assertEqual(len(self.app['students']), 10) 363 363 self.assertEqual(self.app['students']['X666666'].reg_number,'1') 364 364 self.assertEqual( … … 980 980 num, num_warns, fin_file, fail_file = self.processor.doImport( 981 981 self.csv_file, VERDICT_HEADER_FIELDS,'update') 982 content = open(fail_file).read() 982 #content = open(fail_file).read() 983 #import pdb; pdb.set_trace() 983 984 self.assertEqual(num_warns,5) 984 985 self.assertEqual(studycourse.current_verdict, '0') … … 994 995 self.assertTrue(isinstance( 995 996 student['studycourse']['200'].validation_date, datetime.datetime)) 997 student = self.processor.getParent( 998 dict(matric_number='100008'), self.app) 999 self.assertEqual(student['studycourse']['200'].validated_by, 'Juliana') 996 1000 content = open(fail_file).read() 997 1001 self.assertEqual( 998 1002 content, 999 'current_session,current_ verdict,bypass_validation,'1000 'matric_number, current_level,--ERRORS--\r\n'1001 '2008, B,False,100001,100,Current level does not correspond.\r\n'1002 '2007, C,<IGNORE>,100002,200,Current session does not correspond.\r\n'1003 '2008, A,<IGNORE>,100003,200,Student in wrong state.\r\n'1004 '2008, <IGNORE>,<IGNORE>,100004,200,No verdict in import file.\r\n'1005 '2008, A,True,100007,200,Study level object is missing.\r\n'1003 'current_session,current_level,bypass_validation,current_verdict,' 1004 'matric_number,validated_by,--ERRORS--\r\n' 1005 '2008,100,False,B,100001,<IGNORE>,Current level does not correspond.\r\n' 1006 '2007,200,<IGNORE>,C,100002,<IGNORE>,Current session does not correspond.\r\n' 1007 '2008,200,<IGNORE>,A,100003,<IGNORE>,Student in wrong state.\r\n' 1008 '2008,200,<IGNORE>,<IGNORE>,100004,<IGNORE>,No verdict in import file.\r\n' 1009 '2008,200,True,A,100007,<IGNORE>,Study level object is missing.\r\n' 1006 1010 ) 1007 1011 logcontent = open(self.logfile).read()
Note: See TracChangeset for help on using the changeset viewer.