Changeset 13908 for main/waeup.kofa/trunk/src/waeup/kofa
- Timestamp:
- 10 Jun 2016, 08:15:54 (9 years ago)
- Location:
- main/waeup.kofa/trunk/src/waeup/kofa
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/browser/pages.py
r13813 r13908 365 365 self.redirect(self.application_url() + rel_link) 366 366 return 367 # Redirect lecturer after login 368 local_roles = get_user_account(self.request).getLocalRoles() 369 if local_roles.has_key('waeup.local.Lecturer'): 370 self.redirect(self.application_url() + '/my_courses') 371 return 367 372 if not self.camefrom: 368 373 self.redirect(self.application_url() + '/index') … … 978 983 return site_roles_userfriendly 979 984 985 class LecturerLandingPage(KofaPage): 986 """Display courses when lecturer logs in. 987 """ 988 grok.name('my_courses') 989 grok.require('waeup.Authenticated') 990 grok.context(IUniversity) 991 grok.template('mycourses') 992 label =_('My Courses') 993 994 @property 995 def academic_session(self): 996 current_academic_session = grok.getSite()[ 997 'configuration'].current_academic_session 998 if current_academic_session: 999 session = academic_sessions_vocab.getTerm( 1000 current_academic_session).title 1001 return session 1002 return _('no academic session set') 1003 1004 @property 1005 def getCourses(self): 1006 local_roles = get_user_account(self.request).getLocalRoles() 1007 return local_roles['waeup.local.Lecturer'] 1008 980 1009 # 981 1010 # Search pages... -
main/waeup.kofa/trunk/src/waeup/kofa/browser/viewlets.py
r13898 r13908 300 300 url = self.view.url(grok.getSite(), self.link) 301 301 text = translate(self.text, context=self.request) 302 return u'<li><a href="%s">%s</a></li>' % ( 303 url, text) 302 return u'<li><a href="%s">%s</a></li>' % (url, text) 304 303 305 304 class ManagePortalConfiguration(ManageLink): … … 339 338 text = _(u'Reports') 340 339 340 class LecturerCourses(ManageLink): 341 """A link to courses of lecturers. 342 """ 343 grok.order(6) 344 grok.require('waeup.Authenticated') 345 346 link = u'my_courses' 347 text = _(u'My Courses') 348 349 def render(self): 350 user_account = get_user_account(self.request) 351 if user_account: 352 local_roles = user_account.getLocalRoles() 353 if local_roles.has_key('waeup.local.Lecturer'): 354 url = self.view.url(grok.getSite(), self.link) 355 text = translate(self.text, context=self.request) 356 return u'<li><a href="%s">%s</a></li>' % (url, text) 357 return '' 358 341 359 class MyPreferences(ManageLink): 342 360 """A link to personal preferences, placed in upper left box. 343 361 """ 344 grok.order( 6)362 grok.order(7) 345 363 grok.require('waeup.Public') 346 364 text = _(u'My Preferences') … … 351 369 url = self.view.url(account_object) 352 370 text = translate(self.text, context=self.request) 353 return u'<li><a href="%s">%s</a></li>' % ( 354 url, text) 371 return u'<li><a href="%s">%s</a></li>' % (url, text) 355 372 return '' 356 373 … … 358 375 """A link to display site and local roles. 359 376 """ 360 grok.order( 7)377 grok.order(8) 361 378 grok.require('waeup.Public') 362 379 text = _(u'My Roles') … … 367 384 url = self.view.url(account_object) + '/my_roles' 368 385 text = translate(self.text, context=self.request) 369 return u'<li><a href="%s">%s</a></li>' % ( 370 url, text) 386 return u'<li><a href="%s">%s</a></li>' % (url, text) 371 387 return '' 372 388 -
main/waeup.kofa/trunk/src/waeup/kofa/students/browser.py
r13898 r13908 3209 3209 code=(self.context.code, self.context.code) 3210 3210 ) 3211 result= [[_('Matric No.'),3211 header = [[_('Matric No.'), 3212 3212 _('Reg. No.'), 3213 3213 _('Fullname'), … … 3216 3216 _('Level'), 3217 3217 _('Score') ],] 3218 tickets = [] 3218 3219 for ticket in list(coursetickets): 3219 3220 row = [ticket.student.matric_number, … … 3224 3225 ticket.level, 3225 3226 ticket.score] 3226 result.append(row)3227 return result3227 tickets.append(row) 3228 return header + sorted(tickets, key=lambda value: value[0]) 3228 3229 3229 3230 def render(self): -
main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_browser.py
r13904 r13908 1821 1821 prmlocal = IPrincipalRoleManager(course) 1822 1822 prmlocal.assignRoleToPrincipal('waeup.local.Lecturer', 'mrslecturer') 1823 notify(LocalRoleSetEvent( 1824 course, 'waeup.local.Lecturer', 'mrslecturer', granted=True)) 1823 1825 # Login as lecturer. 1824 1826 self.browser.open(self.login_path) 1825 1827 self.browser.getControl(name="form.login").value = 'mrslecturer' 1826 self.browser.getControl(name="form.password").value = 'mrslecturersecret' 1828 self.browser.getControl( 1829 name="form.password").value = 'mrslecturersecret' 1827 1830 self.browser.getControl("Login").click() 1828 1831 self.assertMatches('...You logged in...', self.browser.contents) 1829 # CO can see her roles. 1832 # Lecturer is on landing page 1833 self.assertTrue('(<span>COURSE1</span>)' in self.browser.contents) 1834 # Lecturer can click the 'My Roles' link. 1830 1835 self.browser.getLink("My Roles").click() 1831 1836 self.assertMatches( 1832 1837 '...<div>Academics Officer (view only)</div>...', 1833 1838 self.browser.contents) 1834 # But not her local role ...1835 self.assertFalse('Lecturer' in self.browser.contents)1836 # ... because we forgot to notify the course that the local role1837 # has changed.1838 notify(LocalRoleSetEvent(1839 course, 'waeup.local.Lecturer', 'mrslecturer', granted=True))1840 self.browser.open('http://localhost/app/users/mrslecturer/my_roles')1841 self.assertTrue('Lecturer' in self.browser.contents)1842 1839 self.assertMatches( 1843 '...<a href="http://localhost/app/faculties/fac1/dep1/courses/COURSE1">...', 1840 '...<a href="http://localhost/app/' 1841 'faculties/fac1/dep1/courses/COURSE1">...', 1844 1842 self.browser.contents) 1843 self.assertFalse('(<span>COURSE1</span>)' in self.browser.contents) 1844 # Lecturer can click the 'My Courses' link ... 1845 self.browser.getLink("My Courses").click() 1846 # ... and is is back on landing page 1847 self.assertTrue('(<span>COURSE1</span>)' in self.browser.contents) 1845 1848 # The lecturer can go to her course ... 1846 self.browser.getLink( 1847 "http://localhost/app/faculties/fac1/dep1/courses/COURSE1").click() 1849 self.browser.getLink("COURSE1").click() 1848 1850 # Lecturers can neither filter students ... 1849 1851 self.assertRaises( … … 1861 1863 # Course results can be batch edited via the edit_courses view. 1862 1864 self.app['faculties']['fac1']['dep1'].score_editing_disabled = True 1863 self.browser.open("http://localhost/app/faculties/fac1/dep1/courses/COURSE1") 1865 self.browser.open( 1866 "http://localhost/app/faculties/fac1/dep1/courses/COURSE1") 1864 1867 self.browser.getLink("Update scores").click() 1865 1868 self.assertTrue('Score editing disabled' in self.browser.contents) 1866 1869 self.app['faculties']['fac1']['dep1'].score_editing_disabled = False 1867 1870 self.browser.getLink("Update scores").click() 1868 self.assertTrue('Current academic session not set' in self.browser.contents) 1871 self.assertTrue( 1872 'Current academic session not set' in self.browser.contents) 1869 1873 self.app['configuration'].current_academic_session = 2004 1870 1874 self.browser.getLink("Update scores").click() … … 1875 1879 # Student must be in state 'courses validated'. 1876 1880 self.browser.open( 1877 "http://localhost/app/faculties/fac1/dep1/courses/COURSE1/edit_scores") 1881 'http://localhost/app/faculties/fac1/' 1882 'dep1/courses/COURSE1/edit_scores') 1878 1883 self.assertTrue( 1879 1884 'input type="text" name="scores"' in self.browser.contents) … … 1888 1893 logcontent = open(logfile).read() 1889 1894 self.assertTrue('mrslecturer - students.browser.EditScoresPage - ' 1890 1895 'K1000000 100/COURSE1 score updated (55)' in logcontent) 1891 1896 # Non-integer scores won't be accepted. 1892 1897 self.browser.open( 1893 "http://localhost/app/faculties/fac1/dep1/courses/COURSE1/edit_scores") 1898 'http://localhost/app/faculties/fac1/' 1899 'dep1/courses/COURSE1/edit_scores') 1894 1900 self.assertTrue('value="55" />' in self.browser.contents) 1895 1901 self.browser.getControl(name="scores", index=0).value = 'abc' … … 1899 1905 # Scores can be removed. 1900 1906 self.browser.open( 1901 "http://localhost/app/faculties/fac1/dep1/courses/COURSE1/edit_scores") 1907 'http://localhost/app/faculties/fac1/' 1908 'dep1/courses/COURSE1/edit_scores') 1902 1909 self.browser.getControl(name="scores", index=0).value = '' 1903 1910 self.browser.getControl("Update scores").click() … … 1906 1913 logcontent = open(logfile).read() 1907 1914 self.assertTrue('mrslecturer - students.browser.EditScoresPage - ' 1908 1915 'K1000000 100/COURSE1 score updated (None)' in logcontent) 1909 1916 # A course ticket slip can be downloaded 1910 1917 self.browser.open( 1911 "http://localhost/app/faculties/fac1/dep1/courses/COURSE1/coursetickets.pdf") 1918 'http://localhost/app/faculties/fac1/' 1919 'dep1/courses/COURSE1/coursetickets.pdf') 1912 1920 self.assertEqual(self.browser.headers['Status'], '200 Ok') 1913 1921 self.assertEqual(self.browser.headers['Content-Type'], … … 1916 1924 open(path, 'wb').write(self.browser.contents) 1917 1925 print "Sample PDF coursetickets.pdf written to %s" % path 1918 1919 1926 1920 1927 def test_change_current_mode(self):
Note: See TracChangeset for help on using the changeset viewer.