Changeset 9028 for main/waeup.kofa/trunk/src/waeup/kofa/students
- Timestamp:
- 20 Jul 2012, 08:56:34 (12 years ago)
- Location:
- main/waeup.kofa/trunk/src/waeup/kofa/students
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/students/batching.py
r9001 r9028 43 43 IStudentOnlinePayment, IStudentVerdictUpdate) 44 44 from waeup.kofa.students.workflow import ( 45 IMPORTABLE_STATES, IMPORTABLE_TRANSITIONS) 45 IMPORTABLE_STATES, IMPORTABLE_TRANSITIONS, 46 FORBIDDEN_POSTGRAD_TRANS, FORBIDDEN_POSTGRAD_STATES) 46 47 from waeup.kofa.utils.batching import BatchProcessor 47 48 … … 171 172 if transition not in allowed_transitions: 172 173 return 'Transition not allowed.' 174 if transition in FORBIDDEN_POSTGRAD_TRANS and \ 175 obj.is_postgrad: 176 return 'Transition not allowed (pg student).' 177 state = row.get('state', IGNORE_MARKER) 178 if state not in (IGNORE_MARKER, ''): 179 if state in FORBIDDEN_POSTGRAD_STATES and \ 180 obj.is_postgrad: 181 return 'State not allowed (pg student).' 173 182 return None 174 183 … … 262 271 errs, inv_errs, conv_dict = converter.fromStringDict( 263 272 row, self.factory_name, mode=mode) 264 if row.has_key('transition') and \ 265 not row['transition'] in IMPORTABLE_TRANSITIONS: 266 if row['transition'] not in (IGNORE_MARKER, ''): 267 errs.append(('transition','not allowed')) 268 if row.has_key('state') and \ 269 not row['state'] in IMPORTABLE_STATES: 270 if row['state'] not in (IGNORE_MARKER, ''): 271 errs.append(('state','not allowed')) 272 else: 273 # state is an attribute of Student and must not 274 # be changed if empty 275 conv_dict['state'] = IGNORE_MARKER 276 273 if row.has_key('transition'): 274 if row['transition'] not in IMPORTABLE_TRANSITIONS: 275 if row['transition'] not in (IGNORE_MARKER, ''): 276 errs.append(('transition','not allowed')) 277 if row.has_key('state'): 278 if row['state'] not in IMPORTABLE_STATES: 279 if row['state'] not in (IGNORE_MARKER, ''): 280 errs.append(('state','not allowed')) 281 else: 282 # State is an attribute of Student and must not 283 # be changed if empty. 284 conv_dict['state'] = IGNORE_MARKER 277 285 try: 278 286 # Correct stud_id counter. As the IConverter for students … … 435 443 return errs, inv_errs, conv_dict 436 444 445 def checkUpdateRequirements(self, obj, row, site): 446 """Checks requirements the object must fulfill when being updated. 447 448 This method is not used in case of deleting or adding objects. 449 450 Returns error messages as strings in case of requirement 451 problems. 452 """ 453 current_level = row.get('current_level', None) 454 if current_level == '999' and obj.state in FORBIDDEN_POSTGRAD_STATES: 455 return 'Not a pg student.' 456 return None 457 437 458 class StudentStudyLevelProcessor(StudentProcessorBase): 438 459 """A batch processor for IStudentStudyLevel objects. -
main/waeup.kofa/trunk/src/waeup/kofa/students/browser.py
r9026 r9028 58 58 from waeup.kofa.students.catalog import search 59 59 from waeup.kofa.students.workflow import (CREATED, ADMITTED, PAID, 60 CLEARANCE, REQUESTED, RETURNING, CLEARED, REGISTERED, VALIDATED) 60 CLEARANCE, REQUESTED, RETURNING, CLEARED, REGISTERED, VALIDATED, 61 FORBIDDEN_POSTGRAD_TRANS) 61 62 from waeup.kofa.students.studylevel import StudentStudyLevel, CourseTicket 62 63 from waeup.kofa.students.vocabularies import StudyLevelSource … … 378 379 allowed_transitions = [t for t in self.wf_info.getManualTransitions() 379 380 if not t[0].startswith('pay')] 381 if self.context.is_postgrad: 382 allowed_transitions = [t for t in allowed_transitions 383 if not t[0] in FORBIDDEN_POSTGRAD_TRANS] 380 384 return [dict(name='', title=_('No transition'))] +[ 381 385 dict(name=x, title=y) for x, y in allowed_transitions] -
main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_batching.py
r8920 r9028 23 23 import unittest 24 24 import datetime 25 import grok 25 26 from time import time 27 from zope.event import notify 26 28 from zope.component import createObject 27 29 from zope.component.hooks import setSite, clearSite 28 30 from zope.interface.verify import verifyClass, verifyObject 31 from hurry.workflow.interfaces import IWorkflowState 29 32 30 33 from waeup.kofa.app import University … … 178 181 def setup_student(self, student): 179 182 # set predictable values for `student` 180 student.matric_number = u' M123456'183 student.matric_number = u'234' 181 184 student.adm_code = u'my adm code' 182 185 student.clearance_locked = False 183 186 student.clr_code = u'my clr code' 184 187 student.perm_address = u'Studentroad 21\nLagos 123456\n' 185 student.reg_number = u'123456' 186 student.student_id = u'A111111' 188 student.reg_number = u'123' 187 189 student.firstname = u'Anna' 188 190 student.lastname = u'Tester' … … 240 242 241 243 242 class StudentProcessorTest( FunctionalTestCase):244 class StudentProcessorTest(StudentImportExportSetup): 243 245 244 246 layer = FunctionalLayer … … 246 248 def setUp(self): 247 249 super(StudentProcessorTest, self).setUp() 248 # Setup a sample site for each test249 app = University()250 self.dc_root = tempfile.mkdtemp()251 app['datacenter'].setStoragePath(self.dc_root)252 253 # Prepopulate the ZODB...254 self.getRootFolder()['app'] = app255 # we add the site immediately after creation to the256 # ZODB. Catalogs and other local utilities are not setup257 # before that step.258 self.app = self.getRootFolder()['app']259 # Set site here. Some of the following setup code might need260 # to access grok.getSite() and should get our new app then261 setSite(app)262 250 263 251 # Add student with subobjects 264 252 student = Student() 265 student.firstname = u'Anna'266 student.lastname = u'Tester'267 student.reg_number = u'123'268 student.matric_number = u'234'269 253 self.app['students'].addStudent(student) 254 student = self.setup_student(student) 255 notify(grok.ObjectModifiedEvent(student)) 270 256 self.student = self.app['students'][student.student_id] 257 271 258 self.processor = StudentProcessor() 272 259 self.workdir = tempfile.mkdtemp() … … 292 279 open(self.csv_file_duplicates, 'wb').write(STUDENT_SAMPLE_DATA_DUPLICATES) 293 280 294 def tearDown(self):295 super(StudentProcessorTest, self).tearDown()296 shutil.rmtree(self.workdir)297 shutil.rmtree(self.dc_root)298 clearSite()299 return300 301 281 def test_interface(self): 302 282 # Make sure we fulfill the interface contracts. … … 350 330 self.assertEqual(initial_stud_id, new_stud_id) 351 331 return 332 333 def test_checkUpdateRequirements(self): 334 # Make sure that pg students can't be updated with wrong transition. 335 err = self.processor.checkUpdateRequirements(self.student, 336 dict(reg_number='1', state='returning'), self.app) 337 self.assertTrue(err is None) 338 self.certificate.study_mode = 'pg_ft' 339 err = self.processor.checkUpdateRequirements(self.student, 340 dict(reg_number='1', state='returning'), self.app) 341 self.assertEqual(err, 'State not allowed (pg student).') 342 IWorkflowState(self.student).setState('school fee paid') 343 err = self.processor.checkUpdateRequirements(self.student, 344 dict(reg_number='1', transition='reset6'), self.app) 345 self.assertEqual(err, 'Transition not allowed (pg student).') 346 err = self.processor.checkUpdateRequirements(self.student, 347 dict(reg_number='1', transition='register_courses'), self.app) 348 self.assertEqual(err, 'Transition not allowed (pg student).') 349 352 350 353 351 def test_delEntry(self): -
main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_export.py
r8983 r9028 48 48 49 49 'my adm code,0,my clr code,1981-02-04#,anna@sample.com,,' 50 'Anna,Tester, M123456,M.,NG,"Studentroad 21\nLagos 123456\n",'51 '+234-123-12345#,123 456,f,A111111,0,,created'50 'Anna,Tester,234,M.,NG,"Studentroad 21\nLagos 123456\n",' 51 '+234-123-12345#,123,f,A111111,0,,created' 52 52 in result 53 53 ) … … 68 68 69 69 'my adm code,0,my clr code,1981-02-04#,anna@sample.com,,' 70 'Anna,Tester, M123456,M.,NG,"Studentroad 21\nLagos 123456\n",'71 '+234-123-12345#,123 456,f,A111111,0,,created'70 'Anna,Tester,234,M.,NG,"Studentroad 21\nLagos 123456\n",' 71 '+234-123-12345#,123,f,A111111,0,,created' 72 72 in result 73 73 ) … … 87 87 88 88 'my adm code,0,my clr code,1981-02-04#,anna@sample.com,,' 89 'Anna,Tester, M123456,M.,NG,"Studentroad 21\nLagos 123456\n",'90 '+234-123-12345#,123 456,f,A111111,0,,created'89 'Anna,Tester,234,M.,NG,"Studentroad 21\nLagos 123456\n",' 90 '+234-123-12345#,123,f,A111111,0,,created' 91 91 in result 92 92 ) -
main/waeup.kofa/trunk/src/waeup/kofa/students/workflow.py
r9022 r9028 17 17 REGISTERED, VALIDATED) 18 18 19 FORBIDDEN_POSTGRAD_STATES = (RETURNING, REGISTERED, VALIDATED) 20 19 21 REGISTRATION_TRANSITIONS = ( 20 22 Transition( … … 183 185 IMPORTABLE_TRANSITIONS = [i.transition_id for i in REGISTRATION_TRANSITIONS] 184 186 187 FORBIDDEN_POSTGRAD_TRANS = ['reset6', 'register_courses'] 185 188 LOCK_CLEARANCE_TRANS = ('reset2', 'request_clearance') 186 189 UNLOCK_CLEARANCE_TRANS = ('reset3', 'reset4', 'start_clearance')
Note: See TracChangeset for help on using the changeset viewer.