Changeset 9830 for main


Ignore:
Timestamp:
5 Jan 2013, 18:41:35 (12 years ago)
Author:
Henrik Bettermann
Message:

Ease customization of max_credits. In some universities maximum credits is not constant, it
depends on the student's study level.

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

    r9822 r9830  
    22372237        'level_session', 'level_verdict')
    22382238    pnav = 4
    2239     max_credits = 50
    22402239
    22412240    def update(self):
     
    23062305            self.redirect(self.url(self.context))
    23072306            return
    2308         if self.context.total_credits > self.max_credits:
     2307        students_utils = getUtility(IStudentsUtils)
     2308        max_credits = students_utils.maxCredits(self.context)
     2309        if self.context.total_credits > max_credits:
    23092310            self.flash(_('Maximum credits of ${a} exceeded.',
    2310                 mapping = {'a':self.max_credits}))
     2311                mapping = {'a':max_credits}))
    23112312            return
    23122313        IWorkflowInfo(self.context.student).fireTransition(
  • main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_browser.py

    r9823 r9830  
    755755        self.browser.getControl("Add course ticket").click()
    756756        self.assertMatches(
    757             '...Total credits exceed 58...', self.browser.contents)
     757            '...Total credits exceed 50...', self.browser.contents)
    758758        self.course.credits = 10
    759759        self.browser.getControl("Add course ticket").click()
     
    20292029        self.browser.getControl("Add course ticket").click()
    20302030        self.assertMatches(
    2031             '...Your total credits exceed 58...', self.browser.contents)
     2031            '...Your total credits exceed 50...', self.browser.contents)
    20322032        self.course.credits = 10
    20332033        self.browser.getControl("Add course ticket").click()
  • main/waeup.kofa/trunk/src/waeup/kofa/students/utils.py

    r9762 r9830  
    586586        return pdf_stream
    587587
    588     TOTAL_CREDITS = 58
     588    def maxCredits(self, studylevel):
     589        """Return maximum credits.
     590
     591        In some universities maximum credits is not constant, it
     592        depends on the student's study level.
     593        """
     594        return 50
    589595
    590596    def maxCreditsExceeded(self, studylevel, course):
    591         if self.TOTAL_CREDITS and \
    592             studylevel.total_credits + course.credits > self.TOTAL_CREDITS:
    593             return self.TOTAL_CREDITS
     597        max_credits = self.maxCredits(studylevel)
     598        if max_credits and \
     599            studylevel.total_credits + course.credits > max_credits:
     600            return max_credits
    594601        return 0
    595602
Note: See TracChangeset for help on using the changeset viewer.