Changeset 8490


Ignore:
Timestamp:
22 May 2012, 08:02:09 (12 years ago)
Author:
uli
Message:

Let conversion checks for student imports reset the student id counter.

Location:
main/waeup.kofa/trunk/src/waeup/kofa/students
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/students/batching.py

    r8349 r8490  
    259259                # be changed if empty
    260260                conv_dict['state'] = IGNORE_MARKER
     261
     262        try:
     263            # Correct stud_id counter. As the IConverter for students
     264            # creates student objects that are not used afterwards, we
     265            # have to fix the site-wide student_id counter.
     266            site = grok.getSite()
     267            students = site['students']
     268            students._curr_stud_id -= 1
     269        except (KeyError, TypeError, AttributeError):
     270                pass
    261271        return errs, inv_errs, conv_dict
    262272
  • main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_batching.py

    r8489 r8490  
    322322
    323323    def test_checkConversion(self):
     324        # Make sure we can check conversions and that the stud_id
     325        # counter is not raised during such checks.
     326        initial_stud_id = self.app['students']._curr_stud_id
    324327        errs, inv_errs, conv_dict = self.processor.checkConversion(
    325328            dict(reg_number='1', state='admitted'))
     
    334337        self.assertEqual(len(errs),1)
    335338        self.assertTrue(('state', 'not allowed') in errs)
     339        new_stud_id = self.app['students']._curr_stud_id
     340        self.assertEqual(initial_stud_id, new_stud_id)
     341        return
    336342
    337343    def test_delEntry(self):
Note: See TracChangeset for help on using the changeset viewer.