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

« back to all changes in this revision

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

Began implementing new dispatch framework (with Will Grant and Nick Chadwick).
Added package: ivle.webapp. This contains 'base', with some base class
    implementations for the new Plugins and Views, and 'admin', with 'user'
    (part of 'userservice') re-implemented for the new framework in a RESTful
    way.
dispatch: Added code to partly handle the new plugin system, then fall back to
    the old one.

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
21
 
from ivle.webapp.base.xhtml import XHTMLView
 
20
from ivle.webapp.base.views import JSONRESTView
22
21
from ivle.webapp.base.plugins import BasePlugin
23
22
import ivle.database
24
23
import ivle.util
64
63
            except KeyError:
65
64
                continue
66
65
 
67
 
class UserSettingsView(XHTMLView):
68
 
    template = 'user-settings.html'
69
 
    appname = 'settings'
70
 
 
71
 
    def __init__(self, req, login):
72
 
        self.context = ivle.database.User.get_by_login(req.store, login)
73
 
 
74
 
    def populate(self, req, ctx):
75
 
        if not self.context:
76
 
            raise NotFound()
77
 
 
78
 
        req.scripts = [
79
 
            "/media/settings/settings.js",
80
 
            "/media/common/json2.js",
81
 
            "/media/common/util.js",
82
 
        ]
83
 
        req.scripts_init = [
84
 
            "revert_settings"
85
 
        ]
86
 
        ctx['login'] = self.context.login
87
 
 
88
66
class Plugin(BasePlugin):
89
67
    """
90
68
    The Plugin class for the user plugin.
94
72
    # (regex str, handler class, kwargs dict)
95
73
    # The kwargs dict is passed to the __init__ of the view object
96
74
    urls = [
97
 
        ('users/:login/+settings', UserSettingsView),
98
 
        ('api/users/:login', UserRESTView),
 
75
        ('api/user/:login', UserRESTView)
99
76
    ]