Changeset 7497
- Timestamp:
- 21 Jan 2012, 11:55:44 (13 years ago)
- Location:
- main/waeup.sirp/trunk/src/waeup/sirp/students
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/students/batching.py
r7433 r7497 32 32 from zope.catalog.interfaces import ICatalog 33 33 from waeup.sirp.interfaces import ( 34 IBatchProcessor, FatalCSVError, IObjectConverter )34 IBatchProcessor, FatalCSVError, IObjectConverter, IUserAccount) 35 35 from waeup.sirp.students.interfaces import ( 36 36 IStudent, IStudentStudyCourseImport, … … 58 58 def available_fields(self): 59 59 return sorted(list(set( 60 ['student_id','reg_number','matric_number' ] + getFields(60 ['student_id','reg_number','matric_number','password'] + getFields( 61 61 self.iface).keys()))) 62 62 … … 137 137 pass 138 138 139 def updateEntry(self, obj, row, site): 140 """Update obj to the values given in row. 141 """ 142 for key, value in row.items(): 143 # Set student password and all fields declared in interface. 144 if key == 'password': 145 IUserAccount(obj).setPassword(value) 146 elif hasattr(obj, key): 147 setattr(obj, key, value) 148 return 149 139 150 def getMapping(self, path, headerfields, mode): 140 151 """Get a mapping from CSV file headerfields to actually used fieldnames. -
main/waeup.sirp/trunk/src/waeup/sirp/students/tests/sample_student_data_migration.csv
r7357 r7497 1 student_id,firstname,lastname,reg_number,date_of_birth,matric_number,email,phone 2 A123456,Aaren,Pieri,1,1990-01-02,100000,aa@aa.ng,1234 3 B123456,Aaren,Finau,2,1990-01-03,100001,aa@aa.ng,1234 4 C123456,Aaren,Berson,3,1990-01-04,100002,aa@aa.ng,1234 1 student_id,firstname,lastname,reg_number,date_of_birth,matric_number,email,phone,password 2 A123456,Aaren,Pieri,1,1990-01-02,100000,aa@aa.ng,1234,mypw1 3 B123456,Aaren,Finau,2,1990-01-03,100001,aa@aa.ng,1234,mypw1 4 C123456,Aaren,Berson,3,1990-01-04,100002,aa@aa.ng,1234,mypw1 -
main/waeup.sirp/trunk/src/waeup/sirp/students/tests/test_browser.py
r7463 r7497 682 682 # Prepare a csv file for students 683 683 open('students.csv', 'wb').write( 684 """firstname,lastname,reg_number,date_of_birth,matric_number,email,phone 685 Aaren,Pieri,1,1990-01-02,100000,aa@aa.ng,1234 686 Claus,Finau,2,1990-01-03,100001,aa@aa.ng,1234 687 Brit,Berson,3,1990-01-04,100001,aa@aa.ng,1234 684 """firstname,lastname,reg_number,date_of_birth,matric_number,email,phone,password 685 Aaren,Pieri,1,1990-01-02,100000,aa@aa.ng,1234,mypwd1 686 Claus,Finau,2,1990-01-03,100001,aa@aa.ng,1234,mypwd1 687 Brit,Berson,3,1990-01-04,100001,aa@aa.ng,1234,mypwd1 688 688 """) 689 689 self.browser.addHeader('Authorization', 'Basic mgr:mgrpw') … … 739 739 # The students are properly indexed and we can 740 740 # thus find a student in the department 741 self.browser.open(self. container_path)741 self.browser.open(self.manage_container_path) 742 742 self.browser.getControl(name="searchtype").value = ['depcode'] 743 743 self.browser.getControl(name="searchterm").value = 'dep1' 744 744 self.browser.getControl("Search").click() 745 745 self.assertTrue('Aaren Pieri' in self.browser.contents) 746 # We can search for a new student by name ... 747 self.browser.getControl(name="searchtype").value = ['fullname'] 748 self.browser.getControl(name="searchterm").value = 'Claus' 749 self.browser.getControl("Search").click() 750 self.assertTrue('Claus Finau' in self.browser.contents) 751 # ... and check if the imported password has been properly set 752 ctrl = self.browser.getControl(name='entries') 753 value = ctrl.options[0] 754 claus = self.app['students'][value] 755 self.assertTrue(IUserAccount(claus).checkPassword('mypwd1')) 746 756 return 747 757
Note: See TracChangeset for help on using the changeset viewer.