Ignore:
Timestamp:
24 Feb 2017, 05:59:04 (8 years ago)
Author:
Henrik Bettermann
Message:

Simplify configuration of maximum credits.

Location:
main/waeup.kofa/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/CHANGES.txt

    r14574 r14582  
    441.5.1.dev0 (unreleased)
    55=======================
     6
     7* Simplify configuration of maximum credits.
    68
    79* Add `outstanding` attribute to course tickets.
  • main/waeup.kofa/trunk/src/waeup/kofa/students/browser.py

    r14575 r14582  
    148148    max_credits = students_utils.maxCreditsExceeded(view.context, course)
    149149    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")
    153151        return False
    154152    try:
     
    27342732            return
    27352733        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")
    27402737            return
    27412738        msg = self.context.course_registration_forbidden
  • main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_browser.py

    r14574 r14582  
    824824        self.browser.getControl("Add course ticket").click()
    825825        self.assertMatches(
    826             '...Total credits exceed 50...', self.browser.contents)
     826            '...Total credits exceeded...', self.browser.contents)
    827827        self.course.credits = 10
    828828        self.browser.getControl("Add course ticket").click()
     
    25102510        self.browser.getControl("Add course ticket").click()
    25112511        self.assertMatches(
    2512             '...Total credits exceed 50...', self.browser.contents)
     2512            '...Total credits exceeded...', self.browser.contents)
    25132513        self.course.credits = 10
    25142514        self.browser.getControl("Add course ticket").click()
     
    25362536        self.student['studycourse']['200']['COURSE1'].credits = 60
    25372537        self.browser.getControl("Register course list").click()
    2538         self.assertTrue('Maximum credits of 50 exceeded' in self.browser.contents)
     2538        self.assertTrue('Maximum credits exceeded' in self.browser.contents)
    25392539        # Student can now remove the ticket
    25402540        ctrl = self.browser.getControl(name='val_id')
     
    26052605        # Carryover COURSE1 in level 200 already has 10 credits
    26062606        self.assertMatches(
    2607             '...Total credits exceed 50...', self.browser.contents)
     2607            '...Total credits exceeded...', self.browser.contents)
    26082608        # If COURSE1 is outstanding, its credits won't be considered
    26092609        self.student['studycourse']['200']['COURSE1'].outstanding = True
  • main/waeup.kofa/trunk/src/waeup/kofa/students/utils.py

    r14473 r14582  
    10081008        return pdf_stream
    10091009
    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
    10241018
    10251019    def getBedCoordinates(self, bedticket):
Note: See TracChangeset for help on using the changeset viewer.