Changeset 9831


Ignore:
Timestamp:
5 Jan 2013, 22:45:40 (12 years ago)
Author:
Henrik Bettermann
Message:

In Uniben fresh and returning students must not register courses with more than 50 credits. For final year students maximum credits is 51.

Location:
main/waeup.uniben/trunk/src/waeup/uniben
Files:
4 edited

Legend:

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

    r9796 r9831  
    2828#   If you enable this, please make sure the external services
    2929#   do exist really and are not bothered by being spammed by a test programme.
    30 EXTERNAL_TESTS = True
     30EXTERNAL_TESTS = False
    3131
    3232def external_test(func):
  • main/waeup.uniben/trunk/src/waeup/uniben/students/browser.py

    r9775 r9831  
    193193            self.redirect(self.url(self.context))
    194194            return
    195         if self.context.total_credits > self.max_credits:
     195        students_utils = getUtility(IStudentsUtils)
     196        max_credits = students_utils.maxCredits(self.context)
     197        if self.context.total_credits > max_credits:
    196198            self.flash(_('Maximum credits of ${a} exceeded.',
    197                 mapping = {'a':self.max_credits}))
     199                mapping = {'a':max_credits}))
    198200            return
    199201        IWorkflowInfo(self.context.student).fireTransition(
  • main/waeup.uniben/trunk/src/waeup/uniben/students/tests/test_browser.py

    r9765 r9831  
    687687                           self.browser.contents)
    688688        self.browser.getControl("Create course list now").click()
    689         # A level with one course ticket was created
     689        # A level with no course ticket was created
    690690        self.assertEqual(self.student['studycourse']['700'].number_of_tickets, 0)
    691691        self.browser.getLink("700").click()
     
    693693        self.browser.getControl("Add course ticket").click()
    694694        self.browser.getControl(name="form.course").value = ['COURSE1']
     695        # Non-final year students can't add ticket with 51 credits
     696        self.app['faculties']['fac1']['dep1'].courses['COURSE1'].credits = 51
     697        self.browser.getControl("Add course ticket").click()
     698        self.assertMatches('...Your total credits exceed 50...',
     699                           self.browser.contents)
     700        # Final year students can't add ticket with 52 credits ...
     701        self.app['faculties']['fac1']['dep1'].courses['COURSE1'].credits = 52
     702        self.student['studycourse'].certificate.end_level = 700
     703        self.browser.getControl("Add course ticket").click()
     704        self.assertMatches('...Your total credits exceed 51...',
     705                           self.browser.contents)
     706        # ... but with 51 credits
     707        self.app['faculties']['fac1']['dep1'].courses['COURSE1'].credits = 51
    695708        self.browser.getControl("Add course ticket").click()
    696709        self.assertMatches('...Successfully added COURSE1...',
    697710                           self.browser.contents)
    698         # Special postgraduate students can register course lists
     711        # Non-final year special postgraduate students can't register
     712        # course lists if their total credits are 51 and thus exceed 50 ...
     713        self.student['studycourse'].certificate.end_level = 800
     714        self.browser.getControl("Register course list").click()
     715        self.assertMatches('...Maximum credits of 50 exceeded...',
     716            self.browser.contents)
     717        # ... but final year students can
     718        self.student['studycourse'].certificate.end_level = 700
    699719        self.browser.getControl("Register course list").click()
    700720        self.assertMatches('...Course list has been registered...',
  • main/waeup.uniben/trunk/src/waeup/uniben/students/utils.py

    r9796 r9831  
    225225        return None, payment
    226226
     227    def maxCredits(self, studylevel):
     228        """Return maximum credits.
     229
     230        """
     231        studycourse = studylevel.__parent__
     232        certificate = getattr(studycourse,'certificate', None)
     233        current_level = studycourse.current_level
     234        if None in (current_level, certificate):
     235            return 0
     236        end_level = certificate.end_level
     237        if current_level >= end_level:
     238            return 51
     239        return 50
     240
    227241    # Uniben prefix
    228242    STUDENT_ID_PREFIX = u'B'
Note: See TracChangeset for help on using the changeset viewer.