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

« back to all changes in this revision

Viewing changes to ivle/webapp/userservice/__init__.py

  • Committer: William Grant
  • Date: 2010-02-16 03:29:52 UTC
  • Revision ID: grantw@unimelb.edu.au-20100216032952-isshp9k5utsjubft
Kill off userservice's create_user as well. It has never been used.

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
# Activate the currently-logged-in user's account. Requires that "declaration"
36
36
# is as above, and that the user's state is "no_agreement".
37
37
 
38
 
# userservice/create_user
39
 
# Required cap: CAP_CREATEUSER
40
 
# Arguments are the same as the database columns for the "login" table.
41
 
# Required:
42
 
#   login, fullname, rolenm
43
 
# Optional:
44
 
#   password, nick, email, studentid
45
 
 
46
38
# TODO
47
39
# userservice/enable_user
48
40
# Required cap: CAP_UPDATEUSER
240
232
    req.content_type = "text/plain"
241
233
    req.write(cjson.encode(response))
242
234
 
243
 
create_user_fields_required = [
244
 
    'login', 'fullname',
245
 
]
246
 
create_user_fields_optional = [
247
 
    'admin', 'password', 'nick', 'email', 'studentid'
248
 
]
249
 
 
250
 
@require_method('POST')
251
 
@require_admin
252
 
def handle_create_user(req, fields):
253
 
    """Create a new user, whose state is no_agreement.
254
 
    This does not create the user's jail, just an entry in the database which
255
 
    allows the user to accept an agreement.
256
 
       Expected fields:
257
 
        login       - used as a unix login name and svn repository name.
258
 
                      STRING REQUIRED 
259
 
        password    - the clear-text password for the user. If this property is
260
 
                      absent or None, this is an indication that external
261
 
                      authentication should be used (i.e. LDAP).
262
 
                      STRING OPTIONAL
263
 
        email       - the user's email address.
264
 
                      STRING OPTIONAL
265
 
        nick        - the display name to use.
266
 
                      STRING REQUIRED
267
 
        fullname    - The name of the user for results and/or other official
268
 
                      purposes.
269
 
                      STRING REQUIRED
270
 
        admin       - Whether the user is an admin.
271
 
                      BOOLEAN REQUIRED
272
 
        studentid   - If supplied and not None, the student id of the user for
273
 
                      results and/or other official purposes.
274
 
                      STRING OPTIONAL
275
 
       Return Value: the uid associated with the user. INT
276
 
    """
277
 
    # Make a dict of fields to create
278
 
    create = {}
279
 
    for f in create_user_fields_required:
280
 
        val = fields.getfirst(f)
281
 
        if val is not None:
282
 
            create[f] = val
283
 
        else:
284
 
            raise BadRequest("Required field %s missing." % repr(f))
285
 
    for f in create_user_fields_optional:
286
 
        val = fields.getfirst(f)
287
 
        if val is not None:
288
 
            create[f] = val
289
 
        else:
290
 
            pass
291
 
 
292
 
    user = ivle.database.User(**create)
293
 
    req.store.add(user)
294
 
    ivle.pulldown_subj.enrol_user(req.config, req.store, user)
295
 
 
296
 
    req.content_type = "text/plain"
297
 
    req.write(str(user.unixid))
298
 
 
299
235
def handle_get_enrolments(req, fields):
300
236
    """
301
237
    Retrieve a user's enrolment details. Each enrolment includes any group
565
501
# to actual function objects
566
502
actions_map = {
567
503
    "activate_me": handle_activate_me,
568
 
    "create_user": handle_create_user,
569
504
    "get_enrolments": handle_get_enrolments,
570
505
    "get_project_groups": handle_get_project_groups,
571
506
    "get_group_membership": handle_get_group_membership,