Changeset 6846 for main/waeup.sirp/trunk/src
- Timestamp:
- 2 Oct 2011, 09:45:29 (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
r6843 r6846 47 47 48 48 # The entry never exists in create mode. 49 # To do: Use reg_number and matric_number for locating as well.50 49 def entryExists(self, row, site): 51 if row.has_key('student_id'): 52 return row['student_id'] in site['students'].keys() 50 if not 'students' in site.keys(): 51 return False 52 if 'student_id' in row.keys() and row['student_id']: 53 if row['student_id'] in site['students']: 54 student = site['students'][row['student_id']] 55 return student 56 elif 'reg_number' in row.keys() and row['reg_number']: 57 reg_number = row['reg_number'] 58 cat = queryUtility(ICatalog, name='students_catalog') 59 results = list( 60 cat.searchResults(reg_number=(reg_number, reg_number))) 61 if results: 62 return results[0] 63 elif 'matric_number' in row.keys() and row['matric_number']: 64 #import pdb; pdb.set_trace() 65 matric_number = row['matric_number'] 66 cat = queryUtility(ICatalog, name='students_catalog') 67 results = list( 68 cat.searchResults(matric_number=(matric_number, matric_number))) 69 if results: 70 return results[0] 53 71 return False 54 72 … … 57 75 58 76 def getEntry(self, row, site): 59 if not self.entryExists(row, site): 60 return None 61 parent = self.getParent(row, site) 62 return parent.get(row['student_id']) 77 return self.entryExists(row, site) 63 78 64 79 def addEntry(self, obj, row, site): … … 68 83 69 84 def delEntry(self, row, site): 70 parent = self.getParent(row, site) 71 del parent[row['student_id']] 85 student = self.entryExists(row, site) 86 if student: 87 parent = self.getParent(row, site) 88 del parent[student.student_id] 72 89 pass 73 90 … … 107 124 108 125 def parentsExist(self, row, site): 109 if not 'students' in site.keys() and row['student_id']:126 if not 'students' in site.keys(): 110 127 return False 111 if 'student_id' in row.keys() :128 if 'student_id' in row.keys() and row['student_id']: 112 129 if row['student_id'] in site['students']: 113 130 student = site['students'][row['student_id']] … … 121 138 return results[0] 122 139 elif 'matric_number' in row.keys() and row['matric_number']: 123 #import pdb; pdb.set_trace()124 140 matric_number = row['matric_number'] 125 141 cat = queryUtility(ICatalog, name='students_catalog') -
main/waeup.sirp/trunk/src/waeup/sirp/students/tests/test_batching.py
r6843 r6846 107 107 assert self.importer.entryExists( 108 108 dict(student_id='ID_NONE'), self.app) is False 109 assert self.importer.entryExists(110 dict(student_id=self.student.student_id), self.app) is True109 student = dict(student_id=self.student.student_id), self.app) 110 self.assertEqual(student.reg_number, u'123') 111 111 112 112 def test_getParent(self):
Note: See TracChangeset for help on using the changeset viewer.