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

« back to all changes in this revision

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

  • Committer: William Grant
  • Date: 2009-08-02 08:43:33 UTC
  • mto: (1294.2.118 ui-the-third)
  • mto: This revision was merged to the branch mainline in revision 1353.
  • Revision ID: grantw@unimelb.edu.au-20090802084333-j733m80q8hkrluaz
req.router -> req.publisher

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
from ivle.webapp.base.rest import JSONRESTView, require_permission
21
21
from ivle.webapp.base.xhtml import XHTMLView
22
22
from ivle.webapp.base.plugins import ViewPlugin, MediaPlugin
23
 
from ivle.webapp.errors import NotFound, Unauthorized
 
23
from ivle.webapp.admin.publishing import root_to_user, user_url
24
24
import ivle.database
25
25
import ivle.util
26
26
 
36
36
    """
37
37
    A REST interface to the user object.
38
38
    """
39
 
    def __init__(self, req, login):
40
 
        super(UserRESTView, self).__init__(self, req, login)
41
 
        self.context = ivle.database.User.get_by_login(req.store, login)
42
 
        if self.context is None:
43
 
            raise NotFound()
44
39
 
45
40
    @require_permission('view')
46
41
    def GET(self, req):
55
50
        return user
56
51
 
57
52
class UserSettingsView(XHTMLView):
58
 
    template = 'user-settings.html'
 
53
    template = 'templates/user-settings.html'
59
54
    tab = 'settings'
60
55
    permission = 'edit'
61
56
 
62
 
    def __init__(self, req, login):
63
 
        self.context = ivle.database.User.get_by_login(req.store, login)
64
 
        if self.context is None:
65
 
            raise NotFound()
66
 
 
67
57
    def populate(self, req, ctx):
68
58
        self.plugin_scripts[Plugin] = ['settings.js']
69
 
        req.scripts_init = ['revert_settings']
 
59
        self.scripts_init = ['revert_settings']
70
60
 
71
61
        ctx['login'] = self.context.login
72
62
 
74
64
    """
75
65
    The Plugin class for the user plugin.
76
66
    """
77
 
    # Magic attribute: urls
78
 
    # Sequence of pairs/triples of
79
 
    # (regex str, handler class, kwargs dict)
80
 
    # The kwargs dict is passed to the __init__ of the view object
81
 
    urls = [
82
 
        ('~:login/+settings', UserSettingsView),
83
 
        ('api/~:login', UserRESTView),
84
 
    ]
 
67
 
 
68
    forward_routes = (root_to_user,)
 
69
    reverse_routes = (user_url,)
 
70
    views = [(ivle.database.User, '+settings', UserSettingsView),
 
71
             (ivle.database.User, '+index', UserRESTView, 'api'),
 
72
             ]
85
73
 
86
74
    media = 'user-media'