Changeset 9137 for main/waeup.kofa/trunk/src/waeup/kofa
- Timestamp:
- 31 Aug 2012, 20:19:08 (12 years ago)
- Location:
- main/waeup.kofa/trunk/src/waeup/kofa/students
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/students/student.py
r9136 r9137 28 28 from zope.interface import implementedBy 29 29 from zope.securitypolicy.interfaces import IPrincipalRoleManager 30 from zope.schema.interfaces import ConstraintNotSatisfied 30 31 31 32 from waeup.kofa.image import KofaImageFile … … 149 150 """ 150 151 studycourse = createObject(u'waeup.StudentStudyCourse') 151 studycourse.certificate = certificate 152 studycourse.entry_mode = 'transfer' 153 studycourse.current_session = current_session 154 studycourse.current_level = current_level 155 studycourse.current_verdict = current_verdict 156 studycourse.previous_verdict = previous_verdict 152 try: 153 studycourse.certificate = certificate 154 studycourse.entry_mode = 'transfer' 155 studycourse.current_session = current_session 156 studycourse.current_level = current_level 157 studycourse.current_verdict = current_verdict 158 studycourse.previous_verdict = previous_verdict 159 except ConstraintNotSatisfied: 160 return -1 157 161 old = self['studycourse'] 158 162 studycourse.entry_session = old.entry_session … … 160 164 if 'studycourse_1' in self.keys(): 161 165 if 'studycourse_2' in self.keys(): 162 return False166 return -2 163 167 self['studycourse_2'] = old 164 168 else: … … 169 173 '%s - transferred from %s to %s' % ( 170 174 self.student_id, old.certificate.code, studycourse.certificate.code)) 171 return True 175 history = IObjectHistory(self) 176 history.addMessage('Transferred from %s to %s' % ( 177 old.certificate.code, studycourse.certificate.code)) 178 return 172 179 173 180 -
main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_student.py
r9136 r9137 267 267 self.assertRaises( 268 268 RequiredMissing, self.student.transfer, self.certificate2) 269 success = self.student.transfer(self.certificate2, 270 current_session=2013) 269 error = self.student.transfer(self.certificate2, current_session=1000) 270 self.assertTrue(error == -1) 271 error = self.student.transfer(self.certificate2, current_session=2013) 272 self.assertTrue(error == None) 271 273 self.assertEqual(self.student['studycourse_1'].certificate.code, 'CERT1') 272 274 self.assertEqual(self.student['studycourse'].certificate.code, 'CERT2') … … 281 283 self.assertTrue('system - K1000000 - transferred from CERT1 to CERT2' 282 284 in logcontent) 285 messages = ' '.join(self.student.history.messages) 286 self.assertMatches( 287 '...<YYYY-MM-DD hh:mm:ss> UTC - ' 288 'Transferred from CERT1 to CERT2 by system', messages) 283 289 284 290 # The students_catalog has been updated. … … 297 303 298 304 # Students can be transferred (only) two times. 299 success= self.student.transfer(self.certificate,305 error = self.student.transfer(self.certificate, 300 306 current_session=2013) 301 self.assertTrue( success)302 success= self.student.transfer(self.certificate2,307 self.assertTrue(error == None) 308 error = self.student.transfer(self.certificate2, 303 309 current_session=2013) 304 self.assert False(success)310 self.assertTrue(error == -2) 305 311 self.assertEqual([i for i in self.student.keys()], 306 312 [u'accommodation', u'payments', u'studycourse',
Note: See TracChangeset for help on using the changeset viewer.