Changeset 11595 for main/waeup.kofa/trunk/src/waeup/kofa
- Timestamp:
- 23 Apr 2014, 08:26:03 (11 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/tests/test_utils.py
r11590 r11595 43 43 site = grok.getSite() 44 44 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. 49 46 msg, mnumber = utils.setMatricNumber(self.student) 50 47 self.assertEqual(msg, 'Matriculation number already set.') … … 52 49 self.assertEqual(self.student.matric_number, '234') 53 50 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. 54 57 msg, mnumber = utils.setMatricNumber(self.student) 55 58 self.assertEqual(msg, None) 56 self.assertEqual(mnumber, 1)59 self.assertEqual(mnumber, '1') 57 60 self.assertEqual(self.student.matric_number, '1') 58 61 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. 60 63 cat = queryUtility(ICatalog, name='students_catalog') 61 64 results = list(cat.searchResults(matric_number=('1', '1'))) -
main/waeup.kofa/trunk/src/waeup/kofa/students/utils.py
r11592 r11595 516 516 return None, payment 517 517 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 519 522 return unicode(next_integer) 520 523 … … 526 529 the site configuration container and according to the 527 530 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, 529 532 the students catalog updated and next_matric_integer 530 533 increased by one. … … 537 540 The method can be disabled by setting next_matric_integer to zero. 538 541 """ 539 next_integer = grok.getSite()['configuration'].next_matric_integer540 if next_integer == 0:541 return _('Matriculation number cannot be set.'), None542 542 if student.matric_number is not None: 543 543 return _('Matriculation number already set.'), None 544 544 if student.certcode is None: 545 545 return _('No certificate assigned.'), None 546 matric_number = self. _constructMatricNumber(student, next_integer)546 matric_number = self.constructMatricNumber(student) 547 547 if not matric_number: 548 548 return _('Matriculation number cannot be set.'), None … … 553 553 notify(grok.ObjectModifiedEvent(student)) 554 554 grok.getSite()['configuration'].next_matric_integer += 1 555 return None, next_integer555 return None, matric_number 556 556 557 557 def getAccommodationDetails(self, student):
Note: See TracChangeset for help on using the changeset viewer.