~azzar1/unity/add-show-desktop-key

« back to all changes in this revision

Viewing changes to ivle/webapp/admin/user.py

Add an XHTMLUnauthorizedView which redirects unauthenticated users to the
login page if a page raises an Unauthorized. Alter UserSettingsView to raise
one in the right cases, for testing.

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
from ivle.webapp.base.rest import JSONRESTView
21
21
from ivle.webapp.base.xhtml import XHTMLView
22
22
from ivle.webapp.base.plugins import ViewPlugin
23
 
from ivle.webapp.errors import NotFound
 
23
from ivle.webapp.errors import NotFound, Unauthorized
24
24
import ivle.database
25
25
import ivle.util
26
26
 
76
76
        if self.context is None:
77
77
            raise NotFound()
78
78
 
 
79
        if req.user is None or (req.user is not self.context and
 
80
                                req.user.rolenm != 'admin'):
 
81
            raise Unauthorized()
 
82
 
79
83
    def populate(self, req, ctx):
80
84
        self.plugin_scripts[Plugin] = ['settings.js']
81
85
        req.scripts_init = ['revert_settings']