Changeset 9565 for main/waeup.kofa
- Timestamp:
- 7 Nov 2012, 08:27:23 (12 years ago)
- Location:
- main/waeup.kofa/trunk/src/waeup/kofa
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/browser/pages.py
r9545 r9565 62 62 63 63 from waeup.kofa.students.catalog import search as searchstudents 64 from waeup.kofa.students.catalog import StudentQueryResultItem 64 65 from waeup.kofa.university.catalog import search 65 66 from waeup.kofa.university.vocabularies import course_levels … … 1890 1891 """ 1891 1892 grok.context(ICertificate) 1892 grok.require('waeup.showStudents')1893 1893 grok.name('showcertstudents') 1894 pnav = 11895 label = _('Students')1896 1894 1897 1895 @property … … 1899 1897 hitlist = searchstudents(query=self.context.code, 1900 1898 searchtype='certcode', view=self) 1899 return hitlist 1900 1901 class ShowStudentsInCoursePage(ShowStudentsInDepartmentPage): 1902 """Page that lists all students studying a certificate. 1903 """ 1904 grok.context(ICourse) 1905 grok.name('showcoursestudents') 1906 1907 @property 1908 def getStudents(self): 1909 hitlist = [] 1910 cat = queryUtility(ICatalog, name='coursetickets_catalog') 1911 results = cat.searchResults(code=(self.context.code, self.context.code)) 1912 for result in results: 1913 hitlist.append(StudentQueryResultItem(result.student, view=self)) 1901 1914 return hitlist 1902 1915 -
main/waeup.kofa/trunk/src/waeup/kofa/browser/viewlets.py
r9274 r9565 452 452 text = _('Manage certificate') 453 453 454 class ShowCourseStudentsActionButton(ManageActionButton): 455 """ 'Show students' button in course. 456 """ 457 grok.context(ICourse) 458 grok.view(CoursePage) 459 grok.require('waeup.showStudents') 460 icon = 'actionicon_student.png' 461 text = _('Show students') 462 target = 'showcoursestudents' 463 454 464 class ShowCertificateStudentsActionButton(ManageActionButton): 455 465 """ 'Show students' button for certificates. -
main/waeup.kofa/trunk/src/waeup/kofa/students/dynamicroles.py
r9002 r9565 29 29 from waeup.kofa.students.interfaces import IStudent 30 30 31 # All components in here have the same context: Student instances32 grok.context(IStudent)33 34 31 class StudentPrincipalRoleManager(AnnotationPrincipalRoleManager, 35 32 grok.Adapter): 36 33 grok.provides(IPrincipalRoleManager) 34 grok.context(IStudent) 37 35 38 36 #: The attribute name to lookup for additional roles … … 70 68 obj = getattr(self._context, self.extra_attrib, None) 71 69 current_level = 0 72 # Lookup local roles for connected c ourse and all parent70 # Lookup local roles for connected certificate and all parent 73 71 # objects. This way we fake 'role inheritance'. 74 72 while obj is not None: -
main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_browser.py
r9563 r9565 1406 1406 self.assertTrue(self.student_id in self.browser.contents) 1407 1407 1408 def test_handle_courses_by_lecturer(self): 1409 # Create course lecturer 1410 self.app['users'].addUser('mrslecturer', 'mrslecturersecret') 1411 self.app['users']['mrslecturer'].email = 'mrslecturer@foo.ng' 1412 self.app['users']['mrslecturer'].title = u'Mercedes Benz' 1413 # Assign local Courselecturer100 role for a certificate 1414 course = self.app['faculties']['fac1']['dep1'].courses['COURSE1'] 1415 prmlocal = IPrincipalRoleManager(course) 1416 prmlocal.assignRoleToPrincipal('waeup.local.Lecturer', 'mrslecturer') 1417 # Login as lecturer 1418 self.browser.open(self.login_path) 1419 self.browser.getControl(name="form.login").value = 'mrslecturer' 1420 self.browser.getControl(name="form.password").value = 'mrslecturersecret' 1421 self.browser.getControl("Login").click() 1422 self.assertMatches('...You logged in...', self.browser.contents) 1423 # CO can see her roles 1424 self.browser.getLink("My Roles").click() 1425 self.assertMatches( 1426 '...<div>Academics Officer (view only)</div>...', 1427 self.browser.contents) 1428 # But not her local role ... 1429 self.assertFalse('Lecturer' in self.browser.contents) 1430 # ... because we forgot to notify the course that the local role 1431 # has changed 1432 notify(LocalRoleSetEvent( 1433 course, 'waeup.local.Lecturer', 'mrslecturer', granted=True)) 1434 self.browser.open('http://localhost/app/users/mrslecturer/my_roles') 1435 self.assertTrue('Lecturer' in self.browser.contents) 1436 self.assertMatches( 1437 '...<a href="http://localhost/app/faculties/fac1/dep1/courses/COURSE1">...', 1438 self.browser.contents) 1439 # The lecturer can go to her course 1440 self.browser.getLink( 1441 "http://localhost/app/faculties/fac1/dep1/courses/COURSE1").click() 1442 # and view the list of students 1443 self.browser.getLink("Show students").click() 1444 self.assertTrue('<th>Fullname</th>' in self.browser.contents) 1445 # No student in course so far 1446 self.assertFalse(self.student_id in self.browser.contents) 1447 studylevel = createObject(u'waeup.StudentStudyLevel') 1448 studylevel.level = 100 1449 self.student['studycourse'].addStudentStudyLevel( 1450 self.certificate, studylevel) 1451 # Now the student has registered the course and can 1452 # be seen by the lecturer. 1453 self.assertFalse(self.student_id in self.browser.contents) 1454 # XXX: So far the lecturer can neither access ths student ... 1455 self.assertRaises( 1456 Unauthorized, self.browser.open, self.student_path) 1457 # ... nor the respective course ticket since a 1458 # CourseTicketPrincipalRoleManager does not yet exist. 1459 self.assertTrue('COURSE1' in self.student['studycourse']['100'].keys()) 1460 course_ticket_path = self.student_path + '/studycourse/100/COURSE1' 1461 self.assertRaises( 1462 Unauthorized, self.browser.open, course_ticket_path) 1463 1408 1464 def test_change_current_mode(self): 1409 1465 self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
Note: See TracChangeset for help on using the changeset viewer.