Changeset 15998 for main/waeup.kofa
- Timestamp:
- 11 Feb 2020, 07:26:29 (5 years ago)
- Location:
- main/waeup.kofa/trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/CHANGES.txt
r15988 r15998 4 4 1.6.1.dev0 (unreleased) 5 5 ======================= 6 7 * Add `UpdateCourseTicketsView`. 6 8 7 9 * Don't show 'Base Data' header on slips if no form fields do -
main/waeup.kofa/trunk/src/waeup/kofa/browser/pages.py
r15964 r15998 2042 2042 return result 2043 2043 2044 class SwitchMaintMode Page(UtilityView, grok.View):2044 class SwitchMaintModeView(UtilityView, grok.View): 2045 2045 """Import managers must disable authentication for all other users 2046 2046 before starting an import. This pages switches maintenance mode … … 2553 2553 def delLocalRoles(self, **data): 2554 2554 return del_local_roles(self,2,**data) 2555 2556 class UpdateCourseTicketsView(UtilityView, grok.View): 2557 """Udate course tickets. 2558 """ 2559 grok.context(ICourse) 2560 grok.name('update_coursetickets') 2561 grok.require('waeup.editScores') 2562 2563 def update(self): 2564 ob_class = self.__implemented__.__name__.replace('waeup.kofa.','') 2565 grok.getSite().logger.info( 2566 '%s - course tickets updated: %s' % ( 2567 ob_class, self.context.code)) 2568 number = getUtility(IStudentsUtils).updateCourseTickets(self.context) 2569 if number is None: 2570 self.flash(_('Current academic session not set.')) 2571 elif number is 0: 2572 self.flash(_('No course ticket found.')) 2573 else: 2574 self.flash( 2575 _('%s course ticket(s) updated.' % number)) 2576 self.redirect(self.url(self.context)) 2577 return 2578 2579 def render(self): 2580 return 2555 2581 2556 2582 # -
main/waeup.kofa/trunk/src/waeup/kofa/browser/viewlets.py
r15423 r15998 640 640 grok.order(6) 641 641 642 class UpdateCourseTicketsActionButton(ManageActionButton): 643 """ 'Update credits in course tickets' button for courses. 644 """ 645 grok.context(ICourse) 646 grok.view(CoursePage) 647 grok.name('updatecoursetickets') 648 grok.require('waeup.editScores') 649 icon = 'actionicon_reload.png' 650 target = 'update_coursetickets' 651 grok.order(7) 652 653 @property 654 def target_url(self): 655 ca = grok.getSite()[ 656 'configuration'].current_academic_session 657 if not ca: 658 return '' 659 return self.view.url(self.view.context, self.target) 660 661 @property 662 def text(self): 663 ca = grok.getSite()[ 664 'configuration'].current_academic_session 665 st = academic_sessions_vocab.getTerm(ca).title 666 return _('Update session ${a} credits', mapping = {'a':st}) 667 668 @property 669 def onclick(self): 670 current_academic_session = grok.getSite()[ 671 'configuration'].current_academic_session 672 if not current_academic_session: 673 return 674 message = _("All current session (%s/%s) course tickets of students, " 675 "who paid school fee but not yet registered their courses, " 676 "will be updated.\\n\\n" 677 "You really want to update?") % ( 678 current_academic_session, current_academic_session+1) 679 return "return window.confirm('%s');" % message 680 642 681 class DownloadCSVFileActionButton(ManageActionButton): 643 682 """ 'Download csv file' button for courses. -
main/waeup.kofa/trunk/src/waeup/kofa/students/interfaces.py
r15889 r15998 180 180 """ 181 181 182 def updateCourseTickets(course): 183 """Udate registered course tickets if course 184 attributes were changed. 185 """ 186 182 187 class IStudentsContainer(IKofaObject): 183 188 """A students container contains university students. -
main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_browser.py
r15986 r15998 2375 2375 in self.browser.contents) 2376 2376 2377 def test_update_coursetickets(self): 2378 IWorkflowState(self.student).setState('school fee paid') 2379 studylevel = createObject(u'waeup.StudentStudyLevel') 2380 studylevel.level = 100 2381 studylevel.level_session = 2015 2382 self.student['studycourse'].entry_mode = 'ug_ft' 2383 self.student['studycourse'].addStudentStudyLevel( 2384 self.certificate, studylevel) 2385 self.browser.addHeader('Authorization', 'Basic mgr:mgrpw') 2386 self.browser.open( 2387 'http://localhost/app/faculties/fac1/dep1/courses/COURSE1/') 2388 self.assertFalse( 2389 'Update session 2015/2016 credits' in self.browser.contents) 2390 self.app['configuration'].current_academic_session = 2015 2391 self.browser.open( 2392 'http://localhost/app/faculties/fac1/dep1/courses/COURSE1/') 2393 self.browser.getLink("Update session 2015/2016 credits").click() 2394 self.assertTrue( 2395 'No course ticket found.' in self.browser.contents) 2396 logfile = os.path.join( 2397 self.app['datacenter'].storage, 'logs', 'main.log') 2398 logcontent = open(logfile).read() 2399 self.assertTrue( 2400 'zope.mgr - browser.pages.UpdateCourseTicketsView - ' 2401 'course tickets updated: COURSE1' in logcontent) 2402 studylevel['COURSE1'].credits = 12 2403 self.browser.getLink("Update session 2015/2016 credits").click() 2404 self.assertTrue( 2405 'No course ticket found.' in self.browser.contents) 2406 studylevel.level_session = 2015 2407 self.student['studycourse'].current_session = 2015 2408 self.browser.getLink("Update session 2015/2016 credits").click() 2409 self.assertTrue( 2410 '1 course ticket(s) updated.' in self.browser.contents) 2411 logfile = os.path.join( 2412 self.app['datacenter'].storage, 'logs', 'students.log') 2413 logcontent = open(logfile).read() 2414 self.assertTrue( 2415 'zope.mgr - students.utils.StudentsUtils - ' 2416 'K1000000 100/COURSE1 credits updated (10->12)' in logcontent) 2417 return 2418 2377 2419 2378 2420 class StudentUITests(StudentsFullSetup): -
main/waeup.kofa/trunk/src/waeup/kofa/students/utils.py
r15988 r15998 32 32 from zope.event import notify 33 33 from zope.schema.interfaces import ConstraintNotSatisfied 34 from zope.component import getUtility, createObject 34 from zope.component import getUtility, createObject, queryUtility 35 from zope.catalog.interfaces import ICatalog 35 36 from zope.formlib.form import setUpEditWidgets 36 37 from zope.i18n import translate … … 1148 1149 return pdf_stream 1149 1150 1151 def updateCourseTickets(self, course): 1152 """Udate course tickets if course attributes were changed. 1153 """ 1154 current_academic_session = grok.getSite()[ 1155 'configuration'].current_academic_session 1156 if not current_academic_session: 1157 return 1158 cat = queryUtility(ICatalog, name='coursetickets_catalog') 1159 coursetickets = cat.searchResults( 1160 code=(course.code, course.code), 1161 session=(current_academic_session,current_academic_session)) 1162 number = 0 1163 ob_class = self.__implemented__.__name__.replace('waeup.kofa.', '') 1164 for ticket in coursetickets: 1165 if ticket.credits == course.credits: 1166 continue 1167 if ticket.student.current_session != current_academic_session: 1168 continue 1169 if ticket.student.state not in (PAID,): 1170 continue 1171 number += 1 1172 ticket.student.__parent__.logger.info( 1173 '%s - %s %s/%s credits updated (%s->%s)' % ( 1174 ob_class, ticket.student.student_id, 1175 ticket.level, ticket.code, course.credits, 1176 ticket.credits)) 1177 ticket.credits = course.credits 1178 return number 1179 1150 1180 #: A dictionary which maps widget names to headlines. The headline 1151 1181 #: is rendered in forms and on pdf slips above the respective
Note: See TracChangeset for help on using the changeset viewer.