Changeset 9532
- Timestamp:
- 5 Nov 2012, 07:19:54 (12 years ago)
- Location:
- main/waeup.kofa/trunk/src/waeup/kofa/students
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/students/browser.py
r9521 r9532 1224 1224 @action(_('Add course ticket')) 1225 1225 def addCourseTicket(self, **data): 1226 students_utils = getUtility(IStudentsUtils) 1226 1227 ticket = createObject(u'waeup.CourseTicket') 1227 1228 course = data['course'] 1228 1229 ticket.automatic = False 1229 1230 ticket.carry_over = False 1231 max_credits = students_utils.maxCreditsExceeded(self.context, course) 1232 if max_credits: 1233 self.flash(_( 1234 'Total credits exceed ${a}.', 1235 mapping = {'a': max_credits})) 1236 return 1230 1237 try: 1231 1238 self.context.addCourseTicket(ticket, course) … … 2249 2256 @action(_('Add course ticket')) 2250 2257 def addCourseTicket(self, **data): 2258 students_utils = getUtility(IStudentsUtils) 2251 2259 # Safety belt 2252 2260 if self.context.student.state != PAID: … … 2256 2264 ticket.automatic = False 2257 2265 ticket.carry_over = False 2266 max_credits = students_utils.maxCreditsExceeded(self.context, course) 2267 if max_credits: 2268 self.flash(_( 2269 'Your total credits exceed ${a}.', 2270 mapping = {'a': max_credits})) 2271 return 2258 2272 try: 2259 2273 self.context.addCourseTicket(ticket, course) -
main/waeup.kofa/trunk/src/waeup/kofa/students/interfaces.py
r9501 r9532 464 464 certcode = Attribute('The certificate code of the study course') 465 465 is_current_level = Attribute('Is this level the current level of the student?') 466 total_credits = Attribute('Total of all ticket credits in this study level.') 466 467 467 468 level_session = schema.Choice( -
main/waeup.kofa/trunk/src/waeup/kofa/students/studylevel.py
r9501 r9532 59 59 60 60 @property 61 def total_credits(self): 62 total = 0 63 for ticket in self.values(): 64 total += ticket.credits 65 return total 66 67 @property 61 68 def is_current_level(self): 62 69 try: -
main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_browser.py
r9521 r9532 725 725 self.browser.getControl("Add course ticket").click() 726 726 self.browser.getControl(name="form.course").value = ['COURSE1'] 727 self.course.credits = 100 728 self.browser.getControl("Add course ticket").click() 729 self.assertMatches( 730 '...Total credits exceed 58...', self.browser.contents) 731 self.course.credits = 10 727 732 self.browser.getControl("Add course ticket").click() 728 733 self.assertTrue('Successfully added' in self.browser.contents) … … 1873 1878 self.browser.getControl("Add course ticket").click() 1874 1879 self.browser.getControl(name="form.course").value = ['COURSE1'] 1880 self.course.credits = 100 1881 self.browser.getControl("Add course ticket").click() 1882 self.assertMatches( 1883 '...Your total credits exceed 58...', self.browser.contents) 1884 self.course.credits = 10 1875 1885 self.browser.getControl("Add course ticket").click() 1876 1886 self.assertMatches('...The ticket exists...', -
main/waeup.kofa/trunk/src/waeup/kofa/students/utils.py
r9521 r9532 573 573 return pdf_stream 574 574 575 TOTAL_CREDITS = 58 576 577 def maxCreditsExceeded(self, studylevel, course): 578 if self.TOTAL_CREDITS and \ 579 studylevel.total_credits + course.credits > self.TOTAL_CREDITS: 580 return self.TOTAL_CREDITS 581 return 0 582 575 583 VERDICTS_DICT = { 576 584 '0': _('(not yet)'),
Note: See TracChangeset for help on using the changeset viewer.