Changeset 11595


Ignore:
Timestamp:
23 Apr 2014, 08:26:03 (11 years ago)
Author:
Henrik Bettermann
Message:

constructMatricNumber must not be private. We will be calling it in custom packages.

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

Legend:

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

    r11590 r11595  
    4343        site = grok.getSite()
    4444        utils = getUtility(IStudentsUtils)
    45         msg, mnumber = utils.setMatricNumber(self.student)
    46         self.assertEqual(msg, 'Matriculation number cannot be set.')
    47         self.assertEqual(mnumber, None)
    48         site['configuration'].next_matric_integer = 1
     45        # Matric number can't be set twice.
    4946        msg, mnumber = utils.setMatricNumber(self.student)
    5047        self.assertEqual(msg, 'Matriculation number already set.')
     
    5249        self.assertEqual(self.student.matric_number, '234')
    5350        self.student.matric_number = None
     51        # Matric number can't be set if next_matric_integer is 0.
     52        msg, mnumber = utils.setMatricNumber(self.student)
     53        self.assertEqual(msg, 'Matriculation number cannot be set.')
     54        self.assertEqual(mnumber, None)
     55        site['configuration'].next_matric_integer = 1
     56        # Now all requirements are met and matric number can be set.
    5457        msg, mnumber = utils.setMatricNumber(self.student)
    5558        self.assertEqual(msg, None)
    56         self.assertEqual(mnumber, 1)
     59        self.assertEqual(mnumber, '1')
    5760        self.assertEqual(self.student.matric_number, '1')
    5861        self.assertEqual(site['configuration'].next_matric_integer, 2)
    59         # Student can be found in catalog.
     62        # Student can be found in catalog with new matric number.
    6063        cat = queryUtility(ICatalog, name='students_catalog')
    6164        results = list(cat.searchResults(matric_number=('1', '1')))
  • main/waeup.kofa/trunk/src/waeup/kofa/students/utils.py

    r11592 r11595  
    516516        return None, payment
    517517
    518     def _constructMatricNumber(self, student, next_integer):
     518    def constructMatricNumber(self, student):
     519        next_integer = grok.getSite()['configuration'].next_matric_integer
     520        if next_integer == 0:
     521            return None
    519522        return unicode(next_integer)
    520523
     
    526529        the site configuration container and according to the
    527530        matriculation number construction rules defined in the
    528         _constructMatricNumber method. The new matric number is set,
     531        constructMatricNumber method. The new matric number is set,
    529532        the students catalog updated and next_matric_integer
    530533        increased by one.
     
    537540        The method can be disabled by setting next_matric_integer to zero.
    538541        """
    539         next_integer = grok.getSite()['configuration'].next_matric_integer
    540         if next_integer == 0:
    541             return _('Matriculation number cannot be set.'), None
    542542        if student.matric_number is not None:
    543543            return _('Matriculation number already set.'), None
    544544        if student.certcode is None:
    545545            return _('No certificate assigned.'), None
    546         matric_number = self._constructMatricNumber(student, next_integer)
     546        matric_number = self.constructMatricNumber(student)
    547547        if not matric_number:
    548548            return _('Matriculation number cannot be set.'), None
     
    553553        notify(grok.ObjectModifiedEvent(student))
    554554        grok.getSite()['configuration'].next_matric_integer += 1
    555         return None, next_integer
     555        return None, matric_number
    556556
    557557    def getAccommodationDetails(self, student):
Note: See TracChangeset for help on using the changeset viewer.