- Timestamp:
- 16 Jan 2013, 13:16:20 (12 years ago)
- Location:
- main/waeup.kofa/trunk/src/waeup/kofa
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/browser/static/waeup-base.css
r9840 r9895 160 160 } 161 161 162 .form-table td { 162 .input-table { 163 width: 50%; 164 } 165 166 .form-table td, .input-table td { 163 167 padding: 5px 0px 5px 4px; 164 168 border-top: none; -
main/waeup.kofa/trunk/src/waeup/kofa/students/browser.py
r9868 r9895 139 139 return None 140 140 141 142 def addCourseTicket(view, course=None): 143 students_utils = getUtility(IStudentsUtils) 144 ticket = createObject(u'waeup.CourseTicket') 145 ticket.automatic = False 146 ticket.carry_over = False 147 max_credits = students_utils.maxCreditsExceeded(view.context, course) 148 if max_credits: 149 view.flash(_( 150 'Total credits exceed ${a}.', 151 mapping = {'a': max_credits})) 152 return False 153 try: 154 view.context.addCourseTicket(ticket, course) 155 except KeyError: 156 view.flash(_('The ticket exists.')) 157 return False 158 view.flash(_('Successfully added ${a}.', 159 mapping = {'a':ticket.code})) 160 return True 161 141 162 class StudentsBreadcrumb(Breadcrumb): 142 163 """A breadcrumb for the students container. … … 1157 1178 _('Remove selected tickets'),_('Cancel')] 1158 1179 1159 def update(self ):1180 def update(self, ADD=None, course=None): 1160 1181 if not self.context.__parent__.is_current: 1161 1182 emit_lock_message(self) … … 1170 1191 warning.need() 1171 1192 datatable.need() 1193 if ADD is not None: 1194 if not course: 1195 self.flash(_('No valid course code entered.')) 1196 self.redirect(self.url(self.context, u'@@manage')+'?tab2') 1197 return 1198 cat = queryUtility(ICatalog, name='courses_catalog') 1199 result = cat.searchResults(code=(course, course)) 1200 if len(result) != 1: 1201 self.flash(_('Course not found.')) 1202 else: 1203 course = list(result)[0] 1204 addCourseTicket(self, course) 1205 self.redirect(self.url(self.context, u'@@manage')+'?tab2') 1172 1206 return 1173 1207 … … 1189 1223 msave(self, **data) 1190 1224 return 1191 1192 @action(_('Add course ticket'))1193 def addCourseTicket(self, **data):1194 self.redirect(self.url(self.context, '@@add'))1195 1225 1196 1226 @jsaction(_('Remove selected tickets')) … … 1296 1326 @action(_('Add course ticket')) 1297 1327 def addCourseTicket(self, **data): 1298 students_utils = getUtility(IStudentsUtils)1299 ticket = createObject(u'waeup.CourseTicket')1300 1328 course = data['course'] 1301 ticket.automatic = False 1302 ticket.carry_over = False 1303 max_credits = students_utils.maxCreditsExceeded(self.context, course) 1304 if max_credits: 1305 self.flash(_( 1306 'Total credits exceed ${a}.', 1307 mapping = {'a': max_credits})) 1308 return 1309 try: 1310 self.context.addCourseTicket(ticket, course) 1311 except KeyError: 1312 self.flash(_('The ticket exists.')) 1313 return 1314 self.flash(_('Successfully added ${a}.', 1315 mapping = {'a':ticket.code})) 1316 self.redirect(self.url(self.context, u'@@manage')+'?tab2') 1329 success = addCourseTicket(self, course) 1330 if success: 1331 self.redirect(self.url(self.context, u'@@manage')+'?tab2') 1317 1332 return 1318 1333 … … 2294 2309 pnav = 4 2295 2310 2296 def update(self ):2311 def update(self, ADD=None, course=None): 2297 2312 if not self.context.__parent__.is_current: 2298 2313 emit_lock_message(self) … … 2305 2320 datatable.need() 2306 2321 warning.need() 2322 if ADD is not None: 2323 if not course: 2324 self.flash(_('No valid course code entered.')) 2325 return 2326 cat = queryUtility(ICatalog, name='courses_catalog') 2327 result = cat.searchResults(code=(course, course)) 2328 if len(result) != 1: 2329 self.flash(_('Course not found.')) 2330 return 2331 course = list(result)[0] 2332 addCourseTicket(self, course) 2307 2333 return 2308 2334 … … 2319 2345 def translated_values(self): 2320 2346 return translated_values(self) 2321 2322 @action(_('Add course ticket'))2323 def addCourseTicket(self, **data):2324 self.redirect(self.url(self.context, 'ctadd'))2325 2347 2326 2348 def _delCourseTicket(self, **data): … … 2373 2395 return 2374 2396 2375 @action(_('Register course list') , style='primary')2397 @action(_('Register course list')) 2376 2398 def registerCourses(self, **data): 2377 2399 self._registerCourses(**data) 2378 2400 return 2379 2380 2401 2381 2402 class CourseTicketAddFormPage2(CourseTicketAddFormPage): … … 2396 2417 @action(_('Add course ticket')) 2397 2418 def addCourseTicket(self, **data): 2398 students_utils = getUtility(IStudentsUtils)2399 2419 # Safety belt 2400 2420 if self.context.student.state != PAID: 2401 2421 return 2402 ticket = createObject(u'waeup.CourseTicket')2403 2422 course = data['course'] 2404 ticket.automatic = False 2405 ticket.carry_over = False 2406 max_credits = students_utils.maxCreditsExceeded(self.context, course) 2407 if max_credits: 2408 self.flash(_( 2409 'Your total credits exceed ${a}.', 2410 mapping = {'a': max_credits})) 2411 return 2412 try: 2413 self.context.addCourseTicket(ticket, course) 2414 except KeyError: 2415 self.flash(_('The ticket exists.')) 2416 return 2417 self.flash(_('Successfully added ${a}.', 2418 mapping = {'a':ticket.code})) 2419 self.redirect(self.url(self.context, u'@@edit')) 2420 return 2421 2423 success = addCourseTicket(self, course) 2424 if success: 2425 self.redirect(self.url(self.context, u'@@edit')) 2426 return 2422 2427 2423 2428 class SetPasswordPage(KofaPage): -
main/waeup.kofa/trunk/src/waeup/kofa/students/browser_templates/studyleveleditpage.pt
r9698 r9895 50 50 </div> 51 51 52 <br /><br /><br /> 53 <table class="input-table"> 54 <tr> 55 <td> 56 <input class="btn primary" type="submit" name="ADD" 57 i18n:translate="" 58 value="Add course ticket" /> 59 </td> 60 <td> 61 <input type="text" name="course" /> 62 <div class="hint" i18n:translate=""> 63 Enter valid course code. 64 </div> 65 </td> 66 </tr> 67 </table> 68 <p i18n:translate=""> 69 You don't know the course code? Then select a course 70 <a href="ctadd">here</a>. 71 </p> 52 72 </form> 53 73 -
main/waeup.kofa/trunk/src/waeup/kofa/students/browser_templates/studylevelmanagepage.pt
r9328 r9895 75 75 </div> 76 76 77 <br /><br /><br /> 78 <table class="input-table"> 79 <tr> 80 <td> 81 <input class="btn primary" type="submit" name="ADD" 82 i18n:translate="" 83 value="Add course ticket" /> 84 </td> 85 <td> 86 <input type="text" name="course" /> 87 <div class="hint" i18n:translate=""> 88 Enter valid course code. 89 </div> 90 </td> 91 </tr> 92 </table> 93 <p i18n:translate=""> 94 You don't know the course code? Then select a course 95 <a href="add">here</a>. 96 </p> 97 77 98 </div> 78 99 </div> -
main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_browser.py
r9874 r9895 750 750 self.assertTrue('zope.mgr - students.browser.StudyLevelManageFormPage ' 751 751 '- K1000000 - removed: COURSE1' in logcontent) 752 self.browser.get Control("Add course ticket").click()752 self.browser.getLink("here").click() 753 753 self.browser.getControl(name="form.course").value = ['COURSE1'] 754 754 self.course.credits = 100 … … 759 759 self.browser.getControl("Add course ticket").click() 760 760 self.assertTrue('Successfully added' in self.browser.contents) 761 # We can do the same by adding the course on the manage page directly 762 del self.student['studycourse']['100']['COURSE1'] 763 self.browser.getControl(name="course").value = 'COURSE1' 761 764 self.browser.getControl("Add course ticket").click() 765 self.assertTrue('Successfully added' in self.browser.contents) 766 self.browser.getLink("here").click() 762 767 self.browser.getControl(name="form.course").value = ['COURSE1'] 763 768 self.browser.getControl("Add course ticket").click() … … 2018 2023 self.browser.getLink("100").click() 2019 2024 self.browser.getLink("Edit course list").click() 2020 self.browser.get Control("Add course ticket").click()2025 self.browser.getLink("here").click() 2021 2026 self.browser.getControl(name="form.course").value = ['COURSE1'] 2022 2027 self.browser.getControl("Add course ticket").click() … … 2031 2036 self.browser.getLink("200").click() 2032 2037 self.browser.getLink("Edit course list").click() 2033 self.browser.get Control("Add course ticket").click()2038 self.browser.getLink("here").click() 2034 2039 self.browser.getControl(name="form.course").value = ['COURSE1'] 2035 2040 self.course.credits = 100 2036 2041 self.browser.getControl("Add course ticket").click() 2037 2042 self.assertMatches( 2038 '... Your total credits exceed 50...', self.browser.contents)2043 '...Total credits exceed 50...', self.browser.contents) 2039 2044 self.course.credits = 10 2040 2045 self.browser.getControl("Add course ticket").click() … … 2063 2068 self.browser.getControl("Register course list").click() 2064 2069 self.assertTrue('Maximum credits of 50 exceeded' in self.browser.contents) 2065 # Student can now remove the ticket 2070 # Student can now remove the ticket ... 2066 2071 ctrl = self.browser.getControl(name='val_id') 2067 2072 ctrl.getControl(value='COURSE1').selected = True 2068 2073 self.browser.getControl("Remove selected", index=0).click() 2069 2074 self.assertTrue('Successfully removed' in self.browser.contents) 2070 # Course list can be registered, even if it's empty 2075 # ... and add the same ticket using the edit page directly. 2076 # We can do the same by adding the course on the manage page directly 2077 self.browser.getControl(name="course").value = 'COURSE1' 2078 self.browser.getControl("Add course ticket").click() 2079 # Course list can be registered 2071 2080 self.browser.getControl("Register course list").click() 2072 2081 self.assertTrue('Course list has been registered' in self.browser.contents) … … 2096 2105 self.browser.getLink("999").click() 2097 2106 self.browser.getLink("Edit course list").click() 2098 self.browser.get Control("Add course ticket").click()2107 self.browser.getLink("here").click() 2099 2108 self.browser.getControl(name="form.course").value = ['COURSE1'] 2100 2109 self.browser.getControl("Add course ticket").click()
Note: See TracChangeset for help on using the changeset viewer.