Changeset 14588 for main


Ignore:
Timestamp:
24 Feb 2017, 09:29:33 (8 years ago)
Author:
Henrik Bettermann
Message:

Replace maxCreditsExceeded by warnCreditsOOR.

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

Legend:

Unmodified
Added
Removed
  • main/waeup.uniben/trunk/src/waeup/uniben/students/tests/test_browser.py

    r14421 r14588  
    763763        self.app['faculties']['fac1']['dep1'].courses['COURSE1'].credits = 51
    764764        self.browser.getControl("Add course ticket").click()
    765         self.assertMatches('...Total credits exceed 50...',
     765        self.assertMatches('...Maximum credits exceeded...',
    766766                           self.browser.contents)
    767767        # Final year students can't add ticket with 52 credits ...
     
    769769        self.student['studycourse'].certificate.end_level = 700
    770770        self.browser.getControl("Add course ticket").click()
    771         self.assertMatches('...Total credits exceed 51...',
     771        self.assertMatches('...Maximum credits exceeded...',
    772772                           self.browser.contents)
    773773        # ... but with 51 credits
     
    780780        self.student['studycourse'].certificate.end_level = 800
    781781        self.browser.getControl("Register course list").click()
    782         self.assertMatches('...Maximum credits of 50 exceeded...',
     782        self.assertMatches('...Maximum credits exceeded...',
    783783            self.browser.contents)
    784784        # ... but final year students can
  • main/waeup.uniben/trunk/src/waeup/uniben/students/utils.py

    r14358 r14588  
    370370        return None, payment
    371371
    372     def maxCredits(self, studylevel):
    373         """Return maximum credits.
    374 
    375         """
     372    def warnCreditsOOR(self, studylevel, course=None):
    376373        studycourse = studylevel.__parent__
    377374        certificate = getattr(studycourse,'certificate', None)
    378375        current_level = studycourse.current_level
    379376        if None in (current_level, certificate):
    380             return 0
     377            return
    381378        end_level = certificate.end_level
    382379        if current_level >= end_level:
    383             return 51
    384         return 50
     380            limit = 51
     381        else:
     382            limit = 50
     383        if course and studylevel.total_credits + course.credits > limit:
     384            return _('Maximum credits exceeded.')
     385        elif studylevel.total_credits > limit:
     386            return _('Maximum credits exceeded.')
     387        return
    385388
    386389    def clearance_disabled_message(self, student):
Note: See TracChangeset for help on using the changeset viewer.