~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-12-08 03:50:24 UTC
  • mfrom: (1294.2.143 ui-the-third)
  • Revision ID: grantw@unimelb.edu.au-20091208035024-wjx8zp54gth15ph8
Merge ui-the-third. This is another UI revamp.

The header is now thin! Thin! The yellow bar is gone. The tabs are gone.
Breadcrumbs are here. Routes is replaced (with an object publishing
mechanism). Views are less repetitive. etc.

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
from ivle.webapp.base.rest import JSONRESTView, require_permission
25
25
from ivle.webapp.base.xhtml import XHTMLView
26
26
from ivle.webapp.base.plugins import ViewPlugin, MediaPlugin
27
 
from ivle.webapp.errors import NotFound, Unauthorized
 
27
from ivle.webapp.admin.publishing import root_to_user, user_url
28
28
import ivle.database
29
29
import ivle.date
30
30
import ivle.util
41
41
    """
42
42
    A REST interface to the user object.
43
43
    """
44
 
    def __init__(self, req, login):
45
 
        super(UserRESTView, self).__init__(self, req, login)
46
 
        self.context = ivle.database.User.get_by_login(req.store, login)
47
 
        if self.context is None:
48
 
            raise NotFound()
49
44
 
50
45
    @require_permission('view')
51
46
    def GET(self, req):
70
65
    tab = 'settings'
71
66
    permission = 'edit'
72
67
 
73
 
    def __init__(self, req, login):
74
 
        self.context = ivle.database.User.get_by_login(req.store, login)
75
 
        if self.context is None:
76
 
            raise NotFound()
77
 
 
78
68
    def filter(self, stream, ctx):
79
69
        return stream | HTMLFormFiller(data=ctx['data'])
80
70
 
117
107
    template = 'templates/user-admin.html'
118
108
    tab = 'settings'
119
109
 
120
 
    def __init__(self, req, login):
121
 
        self.context = ivle.database.User.get_by_login(req.store, login)
122
 
        if self.context is None:
123
 
            raise NotFound()
124
 
 
125
110
    def authorize(self, req):
126
111
        """Only allow access if the requesting user is an admin."""
127
112
        return req.user.admin
163
148
    tab = 'settings'
164
149
    permission = 'edit'
165
150
 
166
 
    def __init__(self, req, login):
167
 
        self.context = ivle.database.User.get_by_login(req.store, login)
168
 
        if self.context is None:
169
 
            raise NotFound()
170
 
 
171
151
    def authorize(self, req):
172
152
        """Only allow access if the requesting user holds the permission,
173
153
           and the target user has a password set. Otherwise we might be
201
181
    template = 'templates/user-password-reset.html'
202
182
    tab = 'settings'
203
183
 
204
 
    def __init__(self, req, login):
205
 
        self.context = ivle.database.User.get_by_login(req.store, login)
206
 
        if self.context is None:
207
 
            raise NotFound()
208
 
 
209
184
    def authorize(self, req):
210
185
        """Only allow access if the requesting user is an admin."""
211
186
        return req.user.admin
230
205
    """
231
206
    The Plugin class for the user plugin.
232
207
    """
233
 
    # Magic attribute: urls
234
 
    # Sequence of pairs/triples of
235
 
    # (regex str, handler class, kwargs dict)
236
 
    # The kwargs dict is passed to the __init__ of the view object
237
 
    urls = [
238
 
        ('~:login/+edit', UserEditView),
239
 
        ('~:login/+admin', UserAdminView),
240
 
        ('~:login/+changepassword', PasswordChangeView),
241
 
        ('~:login/+resetpassword', PasswordResetView),
242
 
        ('api/~:login', UserRESTView),
243
 
    ]
 
208
 
 
209
    forward_routes = (root_to_user,)
 
210
    reverse_routes = (user_url,)
 
211
    views = [(ivle.database.User, '+edit', UserEditView),
 
212
             (ivle.database.User, '+admin', UserAdminView),
 
213
             (ivle.database.User, '+changepassword', PasswordChangeView),
 
214
             (ivle.database.User, '+resetpassword', PasswordResetView),
 
215
             (ivle.database.User, '+index', UserRESTView, 'api'),
 
216
             ]
 
217
 
 
218
    public_forward_routes = forward_routes
 
219
    public_reverse_routes = reverse_routes
244
220
 
245
221
    media = 'user-media'