Changeset 14585


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

Replace maxCreditsExceeded by warnCreditsOOR.

Location:
main/waeup.aaue/trunk/src/waeup/aaue/students
Files:
3 edited

Legend:

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

    r14576 r14585  
    12041204        self.assertEqual(self.browser.url,
    12051205            'http://localhost/app/applicants/trans2017/register')
     1206
     1207    def test_student_course_registration_outstanding(self):
     1208        self.course = createObject('waeup.Course')
     1209        self.course.code = 'COURSE2'
     1210        self.course.semester = 1
     1211        self.course.credits = 39
     1212        self.course.passmark = 40
     1213        self.app['faculties']['fac1']['dep1'].courses.addCourse(
     1214            self.course)
     1215        IWorkflowState(self.student).setState('school fee paid')
     1216        self.browser.open(self.login_path)
     1217        self.browser.getControl(name="form.login").value = self.student_id
     1218        self.browser.getControl(name="form.password").value = 'spwd'
     1219        self.browser.getControl("Login").click()
     1220        self.browser.open(self.student_path + '/studycourse/add')
     1221        self.browser.getControl("Create course list now").click()
     1222        self.assertEqual(self.student['studycourse']['100'].number_of_tickets, 1)
     1223        self.student['studycourse'].current_level = 200
     1224        self.browser.getLink("Study Course").click()
     1225        self.browser.getLink("Add course list").click()
     1226        self.assertMatches('...Add current level 200 (Year 2)...',
     1227                           self.browser.contents)
     1228        self.browser.getControl("Create course list now").click()
     1229        self.browser.getLink("200").click()
     1230        self.browser.getLink("Edit course list").click()
     1231        self.browser.getLink("here").click()
     1232        self.browser.getControl(name="form.course").value = ['COURSE2']
     1233        self.browser.getControl("Add course ticket").click()
     1234        # Carryover COURSE1 in level 200 already has 10 credits
     1235        self.assertMatches(
     1236            '...Maximum credits exceeded...', self.browser.contents)
     1237        # If COURSE1 is outstanding, its credits won't be considered
     1238        self.student['studycourse']['200']['COURSE1'].outstanding = True
     1239        self.browser.getControl("Add course ticket").click()
     1240        self.assertMatches(
     1241            '...Successfully added COURSE2...', self.browser.contents)
     1242        return
  • main/waeup.aaue/trunk/src/waeup/aaue/students/tests/test_utils.py

    r14544 r14585  
    138138        return
    139139
    140     def test_maxCredits(self):
    141         dummy = object()
    142         utils = getUtility(IStudentsUtils)
    143         self.assertEqual(utils.maxCredits(dummy), 48)
     140    def test_maxCreditsExceeded(self):
     141        students_utils = getUtility(IStudentsUtils)
     142        studylevel = grok.Container()
     143        studylevel.total_credits = 30
     144        course = grok.Model()
     145        course.credits = 18
     146        warning = students_utils.warnCreditsOOR(studylevel, course)
     147        self.assertEqual(warning, None)
     148        course.credits = 19
     149        warning = students_utils.warnCreditsOOR(studylevel, course)
     150        self.assertEqual(warning, 'Maximum credits exceeded.')
    144151        return
    145152
  • main/waeup.aaue/trunk/src/waeup/aaue/students/utils.py

    r14571 r14585  
    445445        return text
    446446
    447     def maxCredits(self, studylevel):
    448         """Return maximum credits.
    449 
    450         """
    451         return 48
     447    def warnCreditsOOR(self, studylevel, course=None):
     448        if course and studylevel.total_credits + course.credits > 48:
     449            return  _('Maximum credits exceeded.')
     450        elif studylevel.total_credits > 48:
     451            return _('Maximum credits exceeded.')
     452        return
    452453
    453454    def getBedCoordinates(self, bedticket):
Note: See TracChangeset for help on using the changeset viewer.