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

« back to all changes in this revision

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

Port www/apps/settings to new framework. It now appears under
/users/$LOGIN/+settings. Templates are updated to link to there, and it is
modified slightly to allow users to edit other users.

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