Changeset 14582 for main/waeup.kofa/trunk/src/waeup/kofa
- Timestamp:
- 24 Feb 2017, 05:59:04 (8 years ago)
- Location:
- main/waeup.kofa/trunk/src/waeup/kofa/students
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/students/browser.py
r14575 r14582 148 148 max_credits = students_utils.maxCreditsExceeded(view.context, course) 149 149 if max_credits: 150 view.flash(_( 151 'Total credits exceed ${a}.', 152 mapping = {'a': max_credits}), type="warning") 150 view.flash(_('Total credits exceeded.'), type="warning") 153 151 return False 154 152 try: … … 2734 2732 return 2735 2733 students_utils = getUtility(IStudentsUtils) 2736 max_credits = students_utils.maxCredits(self.context) 2737 if max_credits and self.context.total_credits > max_credits: 2738 self.flash(_('Maximum credits of ${a} exceeded.', 2739 mapping = {'a':max_credits}), type="warning") 2734 max_credits = students_utils.maxCreditsExceeded(self.context) 2735 if max_credits: 2736 self.flash(_('Maximum credits exceeded.'), type="warning") 2740 2737 return 2741 2738 msg = self.context.course_registration_forbidden -
main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_browser.py
r14574 r14582 824 824 self.browser.getControl("Add course ticket").click() 825 825 self.assertMatches( 826 '...Total credits exceed 50...', self.browser.contents)826 '...Total credits exceeded...', self.browser.contents) 827 827 self.course.credits = 10 828 828 self.browser.getControl("Add course ticket").click() … … 2510 2510 self.browser.getControl("Add course ticket").click() 2511 2511 self.assertMatches( 2512 '...Total credits exceed 50...', self.browser.contents)2512 '...Total credits exceeded...', self.browser.contents) 2513 2513 self.course.credits = 10 2514 2514 self.browser.getControl("Add course ticket").click() … … 2536 2536 self.student['studycourse']['200']['COURSE1'].credits = 60 2537 2537 self.browser.getControl("Register course list").click() 2538 self.assertTrue('Maximum credits of 50exceeded' in self.browser.contents)2538 self.assertTrue('Maximum credits exceeded' in self.browser.contents) 2539 2539 # Student can now remove the ticket 2540 2540 ctrl = self.browser.getControl(name='val_id') … … 2605 2605 # Carryover COURSE1 in level 200 already has 10 credits 2606 2606 self.assertMatches( 2607 '...Total credits exceed 50...', self.browser.contents)2607 '...Total credits exceeded...', self.browser.contents) 2608 2608 # If COURSE1 is outstanding, its credits won't be considered 2609 2609 self.student['studycourse']['200']['COURSE1'].outstanding = True -
main/waeup.kofa/trunk/src/waeup/kofa/students/utils.py
r14473 r14582 1008 1008 return pdf_stream 1009 1009 1010 def maxCredits(self, studylevel): 1011 """Return maximum credits. 1012 At some universities maximum credits is not constant, it 1013 depends on the student's study level. Set `maxCredits` None or 0 1014 in order to deactivate the limitation. 1015 """ 1016 return 50 1017 1018 def maxCreditsExceeded(self, studylevel, course): 1019 max_credits = self.maxCredits(studylevel) 1020 if max_credits and \ 1021 studylevel.total_credits + course.credits > max_credits: 1022 return max_credits 1023 return 0 1010 def maxCreditsExceeded(self, studylevel, course=None): 1011 """Return True if maximum credits is exceeded. 1012 """ 1013 if course and studylevel.total_credits + course.credits > 50: 1014 return True 1015 elif studylevel.total_credits > 50: 1016 return True 1017 return False 1024 1018 1025 1019 def getBedCoordinates(self, bedticket):
Note: See TracChangeset for help on using the changeset viewer.