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".
38
# userservice/create_user
39
# Required cap: CAP_CREATEUSER
40
# Arguments are the same as the database columns for the "login" table.
42
# login, fullname, rolenm
44
# password, nick, email, studentid
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))
243
create_user_fields_required = [
246
create_user_fields_optional = [
247
'admin', 'password', 'nick', 'email', 'studentid'
250
@require_method('POST')
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.
257
login - used as a unix login name and svn repository name.
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).
263
email - the user's email address.
265
nick - the display name to use.
267
fullname - The name of the user for results and/or other official
270
admin - Whether the user is an admin.
272
studentid - If supplied and not None, the student id of the user for
273
results and/or other official purposes.
275
Return Value: the uid associated with the user. INT
277
# Make a dict of fields to create
279
for f in create_user_fields_required:
280
val = fields.getfirst(f)
284
raise BadRequest("Required field %s missing." % repr(f))
285
for f in create_user_fields_optional:
286
val = fields.getfirst(f)
292
user = ivle.database.User(**create)
294
ivle.pulldown_subj.enrol_user(req.config, req.store, user)
296
req.content_type = "text/plain"
297
req.write(str(user.unixid))
299
235
def handle_get_enrolments(req, fields):
301
237
Retrieve a user's enrolment details. Each enrolment includes any group
565
501
# to actual function objects
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,