Changeset 11862
- Timestamp:
- 21 Oct 2014, 07:07:04 (10 years ago)
- Location:
- main/waeup.kofa/trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/CHANGES.txt
r11826 r11862 4 4 1.3dev (unreleased) 5 5 =================== 6 7 * Add permission, page and button to mass-clear all students in a department. 6 8 7 9 * Hide export download button 24 hours after file generation. -
main/waeup.kofa/trunk/src/waeup/kofa/browser/viewlets.py
r11254 r11862 476 476 grok.order(3) 477 477 478 class ClearDepartmentStudentsActionButton(ManageActionButton): 479 """ 'Clear all students' button for departments. 480 """ 481 grok.context(IDepartment) 482 grok.view(DepartmentPage) 483 grok.name('cleardepartmentstudents') 484 grok.require('waeup.clearAllStudents') 485 icon = 'actionicon_accept.png' 486 text = _('Clear all students') 487 target = 'clearallstudents' 488 grok.order(4) 489 490 @property 491 def onclick(self): 492 return "return window.confirm(%s);" % _( 493 "'All students, who requested clearance in this department, will be cleared. Are you sure?'") 494 478 495 class ManageCourseActionButton(ManageActionButton): 479 496 """ 'Edit settings' button for courses. -
main/waeup.kofa/trunk/src/waeup/kofa/permissions.py
r11673 r11862 59 59 grok.name('waeup.showStudents') 60 60 61 class ClearAllStudents(grok.Permission): 62 grok.name('waeup.clearAllStudents') 63 61 64 class EditScores(grok.Permission): 62 65 grok.name('waeup.editScores') … … 128 131 grok.permissions('waeup.showStudents', 129 132 'waeup.viewAcademics', 130 'waeup.exportData') 133 'waeup.exportData', 134 'waeup.clearAllStudents') 131 135 132 136 class LocalStudentsManager(grok.Role): … … 158 162 grok.permissions('waeup.showStudents', 159 163 'waeup.viewAcademics', 160 'waeup.exportData') 164 'waeup.exportData', 165 'waeup.clearAllStudents') 161 166 162 167 class PGClearanceOfficer(grok.Role): … … 168 173 grok.permissions('waeup.showStudents', 169 174 'waeup.viewAcademics', 170 'waeup.exportData') 175 'waeup.exportData', 176 'waeup.clearAllStudents') 171 177 172 178 class CourseAdviser100(grok.Role): … … 336 342 'waeup.clearStudent', 'waeup.payStudent', 337 343 'waeup.uploadStudentFile', 'waeup.showStudents', 344 'waeup.clearAllStudents', 338 345 'waeup.editScores', 339 346 'waeup.triggerTransition', … … 369 376 'waeup.clearStudent', 'waeup.payStudent', 370 377 'waeup.uploadStudentFile', 'waeup.showStudents', 378 'waeup.clearAllStudents', 371 379 'waeup.editScores', 372 380 #'waeup.triggerTransition', -
main/waeup.kofa/trunk/src/waeup/kofa/students/browser.py
r11772 r11862 3004 3004 return list(set(hitlist)) 3005 3005 3006 class ClearAllStudentsInDepartmentPage(UtilityView, grok.View): 3007 """ Clear all students of a department in state 'clearance requested'. 3008 """ 3009 grok.context(IDepartment) 3010 grok.name('clearallstudents') 3011 grok.require('waeup.clearAllStudents') 3012 3013 def update(self): 3014 cat = queryUtility(ICatalog, name='students_catalog') 3015 students = cat.searchResults( 3016 depcode=(self.context.code, self.context.code), 3017 state=(REQUESTED, REQUESTED) 3018 ) 3019 num = 0 3020 for student in students: 3021 if getUtility(IStudentsUtils).clearance_disabled_message(student): 3022 continue 3023 IWorkflowInfo(student).fireTransition('clear') 3024 num += 1 3025 self.flash(_('%d students have been cleared.' % num)) 3026 self.redirect(self.url(self.context)) 3027 return 3028 3029 def render(self): 3030 return 3031 3032 3006 3033 class EditScoresPage(KofaPage): 3007 3034 """Page that filters and lists students. -
main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_browser.py
r11774 r11862 1384 1384 return 1385 1385 1386 def test_handle_clearance_by_co(self):1386 def init_clearance_officer(self): 1387 1387 # Create clearance officer 1388 1388 self.app['users'].addUser('mrclear', 'mrclearsecret') … … 1394 1394 #prmglobal.assignRoleToPrincipal('waeup.StudentsOfficer', 'mrclear') 1395 1395 # Assign local ClearanceOfficer role 1396 department = self.app['faculties']['fac1']['dep1']1397 prmlocal = IPrincipalRoleManager( department)1396 self.department = self.app['faculties']['fac1']['dep1'] 1397 prmlocal = IPrincipalRoleManager(self.department) 1398 1398 prmlocal.assignRoleToPrincipal('waeup.local.ClearanceOfficer', 'mrclear') 1399 1399 IWorkflowState(self.student).setState('clearance started') 1400 # Add another student for testing 1401 other_student = Student() 1402 other_student.firstname = u'Dep2' 1403 other_student.lastname = u'Student' 1404 self.app['students'].addStudent(other_student) 1405 self.other_student_path = ( 1406 'http://localhost/app/students/%s' % other_student.student_id) 1400 1407 # Login as clearance officer 1401 1408 self.browser.open(self.login_path) … … 1403 1410 self.browser.getControl(name="form.password").value = 'mrclearsecret' 1404 1411 self.browser.getControl("Login").click() 1412 1413 def test_handle_clearance_by_co(self): 1414 self.init_clearance_officer() 1405 1415 self.assertMatches('...You logged in...', self.browser.contents) 1406 1416 # CO is landing on index page … … 1419 1429 # has changed 1420 1430 notify(LocalRoleSetEvent( 1421 department, 'waeup.local.ClearanceOfficer', 'mrclear', granted=True))1431 self.department, 'waeup.local.ClearanceOfficer', 'mrclear', granted=True)) 1422 1432 self.browser.open('http://localhost/app/users/mrclear/my_roles') 1423 1433 self.assertTrue('Clearance Officer' in self.browser.contents) … … 1430 1440 self.assertEqual(self.browser.url, self.clearance_path) 1431 1441 # ... but not other students 1432 other_student = Student()1433 other_student.firstname = u'Dep2'1434 other_student.lastname = u'Student'1435 self.app['students'].addStudent(other_student)1436 other_student_path = (1437 'http://localhost/app/students/%s' % other_student.student_id)1438 1442 self.assertRaises( 1439 Unauthorized, self.browser.open, other_student_path)1443 Unauthorized, self.browser.open, self.other_student_path) 1440 1444 # Clearance is disabled for this session 1441 1445 self.browser.open(self.clearance_path) … … 1536 1540 IWorkflowInfo(self.student).fireTransition('clear') 1537 1541 self.assertEqual(self.student.officer_comment, None) 1542 return 1543 1544 def test_handle_mass_clearance_by_co(self): 1545 self.init_clearance_officer() 1546 # Additional setups according to test above 1547 notify(LocalRoleSetEvent( 1548 self.department, 'waeup.local.ClearanceOfficer', 'mrclear', granted=True)) 1549 self.app['configuration']['2004'].clearance_enabled = True 1550 IWorkflowState(self.student).setState('clearance requested') 1551 # Update the catalog 1552 notify(grok.ObjectModifiedEvent(self.student)) 1553 # The CO can go to the department and clear all students in department 1554 self.browser.open('http://localhost/app/faculties/fac1/dep1') 1555 self.browser.getLink("Clear all students").click() 1556 self.assertTrue('1 students have been cleared' in self.browser.contents) 1557 self.browser.open(self.history_path) 1558 self.assertTrue('Cleared by Carlo Pitter' in self.browser.contents) 1559 logfile = os.path.join( 1560 self.app['datacenter'].storage, 'logs', 'students.log') 1561 logcontent = open(logfile).read() 1562 self.assertTrue( 1563 'INFO - mrclear - K1000000 - Cleared' in logcontent) 1564 self.browser.open('http://localhost/app/faculties/fac1/dep1') 1565 self.browser.getLink("Clear all students").click() 1566 self.assertTrue('0 students have been cleared' in self.browser.contents) 1567 return 1538 1568 1539 1569 def test_handle_courses_by_ca(self):
Note: See TracChangeset for help on using the changeset viewer.