Changeset 6843 for main/waeup.sirp/trunk/src/waeup/sirp/students
- Timestamp:
- 2 Oct 2011, 07:57:57 (13 years ago)
- Location:
- main/waeup.sirp/trunk/src/waeup/sirp/students
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/students/batching.py
r6841 r6843 47 47 48 48 # The entry never exists in create mode. 49 # To do: Use reg_number and matric_number for locating as well. 49 50 def entryExists(self, row, site): 50 51 if row.has_key('student_id'): … … 90 91 result = [] 91 92 return sorted(list(set( 92 ['student_id','reg_number'] + getFields(self.iface).keys()))) 93 ['student_id','reg_number','matric_number'] + getFields( 94 self.iface).keys()))) 93 95 94 96 def checkHeaders(self, headerfields, mode='ignore'): 95 if not 'reg_number' in headerfields and not 'student_id' in headerfields :97 if not 'reg_number' in headerfields and not 'student_id' in headerfields and not 'matric_number' in headerfields: 96 98 raise FatalCSVError( 97 "Need at least columns student_id or reg_number for import!")99 "Need at least columns student_id or reg_number or matric_number for import!") 98 100 # Check for fields to be ignored... 99 101 not_ignored_fields = [x for x in headerfields … … 105 107 106 108 def parentsExist(self, row, site): 107 if not 'students' in site.keys() :109 if not 'students' in site.keys() and row['student_id']: 108 110 return False 109 111 if 'student_id' in row.keys(): … … 111 113 student = site['students'][row['student_id']] 112 114 return student 113 else: 114 # Here we know that the reg_number is in row 115 elif 'reg_number' in row.keys() and row['reg_number']: 115 116 reg_number = row['reg_number'] 116 117 cat = queryUtility(ICatalog, name='students_catalog') 117 118 results = list( 118 119 cat.searchResults(reg_number=(reg_number, reg_number))) 120 if results: 121 return results[0] 122 elif 'matric_number' in row.keys() and row['matric_number']: 123 #import pdb; pdb.set_trace() 124 matric_number = row['matric_number'] 125 cat = queryUtility(ICatalog, name='students_catalog') 126 results = list( 127 cat.searchResults(matric_number=(matric_number, matric_number))) 119 128 if results: 120 129 return results[0] -
main/waeup.sirp/trunk/src/waeup/sirp/students/tests/test_batching.py
r6840 r6843 133 133 num, num_warns, fin_file, fail_file = self.importer.doImport( 134 134 self.csv_file, STUDENT_HEADER_FIELDS) 135 self.assertEqual(num_warns,0) 135 136 assert len(self.app['students'].keys()) == 4 136 137 shutil.rmtree(os.path.dirname(fin_file)) … … 203 204 self.csv_file, STUDYCOURSE_HEADER_FIELDS,'update') 204 205 studycourse = self.importer.getEntry(dict(reg_number='1'), self.app) 206 self.assertEqual(num_warns,0) 205 207 self.assertEqual(studycourse.certificate.code, u'CERT1') 206 208 shutil.rmtree(os.path.dirname(fin_file))
Note: See TracChangeset for help on using the changeset viewer.