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

« back to all changes in this revision

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

Port ivle.webapp.filesystem.{diff,svnlog}'s media to the new framework.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 
18
18
# Author: Matt Giuca, Will Grant
19
19
 
20
 
from ivle.webapp.base.rest import JSONRESTView, require_permission
 
20
from ivle.webapp.base.rest import JSONRESTView
21
21
from ivle.webapp.base.xhtml import XHTMLView
22
 
from ivle.webapp.base.plugins import ViewPlugin, MediaPlugin
23
 
from ivle.webapp.errors import NotFound, Unauthorized
 
22
from ivle.webapp.base.plugins import BasePlugin
24
23
import ivle.database
25
24
import ivle.util
26
25
 
39
38
    def __init__(self, req, login):
40
39
        super(UserRESTView, self).__init__(self, req, login)
41
40
        self.context = ivle.database.User.get_by_login(req.store, login)
42
 
        if self.context is None:
43
 
            raise NotFound()
44
41
 
45
 
    @require_permission('view')
46
42
    def GET(self, req):
47
43
        # XXX Check Caps
48
44
        user = ivle.util.object_to_dict(user_fields_list, self.context)
54
50
        user['local_password'] = self.context.passhash is not None
55
51
        return user
56
52
 
57
 
    @require_permission('edit')
58
53
    def PATCH(self, req, data):
 
54
        # XXX Check Caps
59
55
        # XXX Admins can set extra fields
60
56
        # Note: Cannot change password here (use change_password named op)
61
57
 
71
67
class UserSettingsView(XHTMLView):
72
68
    template = 'user-settings.html'
73
69
    appname = 'settings'
74
 
    permission = 'edit'
75
70
 
76
71
    def __init__(self, req, login):
77
72
        self.context = ivle.database.User.get_by_login(req.store, login)
78
 
        if self.context is None:
79
 
            raise NotFound()
80
73
 
81
74
    def populate(self, req, ctx):
 
75
        if not self.context:
 
76
            raise NotFound()
 
77
 
82
78
        self.plugin_scripts[Plugin] = ['settings.js']
83
79
        req.scripts_init = ['revert_settings']
84
80
 
85
81
        ctx['login'] = self.context.login
86
82
 
87
 
class Plugin(ViewPlugin, MediaPlugin):
 
83
class Plugin(BasePlugin):
88
84
    """
89
85
    The Plugin class for the user plugin.
90
86
    """