- Timestamp:
- 27 Jan 2012, 16:33:02 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/students/batching.py
r7513 r7522 33 33 from hurry.workflow.interfaces import IWorkflowState 34 34 from waeup.sirp.interfaces import ( 35 IBatchProcessor, FatalCSVError, IObjectConverter, IUserAccount) 35 IBatchProcessor, FatalCSVError, IObjectConverter, IUserAccount, 36 IObjectHistory) 36 37 from waeup.sirp.students.interfaces import ( 37 38 IStudent, IStudentStudyCourseImport, … … 39 40 from waeup.sirp.students.workflow import IMPORTABLE_STATES 40 41 from waeup.sirp.utils.batching import BatchProcessor 42 from waeup.sirp.utils.helpers import get_current_principal 41 43 42 44 class StudentProcessor(BatchProcessor): … … 131 133 parent = self.getParent(row, site) 132 134 parent.addStudent(obj) 135 # In some tests we don't have a students container or a user 136 try: 137 user = get_current_principal() 138 parent.logger.info('%s - %s - Student record imported' % ( 139 user.id,obj.student_id)) 140 history = IObjectHistory(obj) 141 history.addMessage('Student record imported') 142 except (TypeError, AttributeError): 143 pass 133 144 return 134 145 … … 145 156 for key, value in row.items(): 146 157 # Set student password and all fields declared in interface. 147 if key == 'password' :158 if key == 'password' and value != '': 148 159 IUserAccount(obj).setPassword(value) 149 160 elif key == 'reg_state': 150 161 IWorkflowState(obj).setState(value) 162 msg = "State '%s' set" % value 163 history = IObjectHistory(obj) 164 history.addMessage(msg) 151 165 elif hasattr(obj, key): 152 166 setattr(obj, key, value) … … 183 197 row, self.factory_name) 184 198 if row.has_key('reg_state') and \ 185 row['reg_state'] is not None and \186 199 not row['reg_state'] in IMPORTABLE_STATES: 187 errs.append(('reg_state','not allowed')) 200 if row['reg_state'] != '': 201 errs.append(('reg_state','not allowed')) 202 else: 203 errs.append(('reg_state','no value provided')) 188 204 return errs, inv_errs, conv_dict 189 205
Note: See TracChangeset for help on using the changeset viewer.