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

« back to all changes in this revision

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

  • Committer: Nick Chadwick
  • Date: 2009-03-03 01:48:48 UTC
  • mto: (1099.1.227 exercise-ui)
  • mto: This revision was merged to the branch mainline in revision 1162.
  • Revision ID: chadnickbok@gmail.com-20090303014848-dyurvmtmbneohd7f
Modified the setup script to include '.txt' files.

This allows the automatic inclusion of definitions.txt from the rst
code, as it is needed by all worksheets.

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.admin.traversal import root_to_user, user_url
 
23
from ivle.webapp.errors import NotFound, Unauthorized
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()
39
44
 
40
45
    @require_permission('view')
41
46
    def GET(self, req):
50
55
        return user
51
56
 
52
57
class UserSettingsView(XHTMLView):
53
 
    template = 'templates/user-settings.html'
 
58
    template = 'user-settings.html'
54
59
    tab = 'settings'
55
60
    permission = 'edit'
56
61
 
 
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
 
57
67
    def populate(self, req, ctx):
58
68
        self.plugin_scripts[Plugin] = ['settings.js']
59
 
        self.scripts_init = ['revert_settings']
 
69
        req.scripts_init = ['revert_settings']
60
70
 
61
71
        ctx['login'] = self.context.login
62
72
 
64
74
    """
65
75
    The Plugin class for the user plugin.
66
76
    """
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
 
             ]
 
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
    ]
73
85
 
74
86
    media = 'user-media'