90
90
# userservice/create_project_set
91
91
# Required cap: CAP_MANAGEPROJECTS
92
# Creates a project set for a offering - returns the projectsetid
92
# Creates a project set for a offering
94
94
# offeringid, max_students_per_group
96
98
# userservice/create_project
97
99
# Required cap: CAP_MANAGEPROJECTS
102
# synopsys, url, deadline
104
# synopsis, url, deadline
104
108
# userservice/create_group
105
109
# Required cap: CAP_MANAGEGROUPS
445
449
req.write(response)
447
451
def handle_create_project_set(req, fields):
448
"""Creates a project set for a offering - returns the projectsetid"""
452
"""Required cap: CAP_MANAGEPROJECTS
453
Creates a project set for a offering - returns the projectsetid
455
offeringid, max_students_per_group
450
458
if req.method != "POST":
451
459
req.throw_error(req.HTTP_METHOD_NOT_ALLOWED,
480
487
req.content_type = "text/plain"
481
488
req.write(response)
483
# TODO: write userservice/create_project
484
# Required cap: CAP_MANAGEPROJECTS
485
# Creates a project in a specific project set
489
# synopsys, url, deadline
490
def handle_create_project(req, fields):
491
"""Required cap: CAP_MANAGEPROJECTS
492
Creates a project in a specific project set
496
synopsis, url, deadline
501
if req.method != "POST":
502
req.throw_error(req.HTTP_METHOD_NOT_ALLOWED,
503
"Only POST requests are valid methods to create_user.")
504
# Check if this user has CAP_MANAGEPROJECTS
505
if not req.user.hasCap(caps.CAP_MANAGEPROJECTS):
506
req.throw_error(req.HTTP_FORBIDDEN,
507
"You do not have permission to manage projects.")
508
# Get required fields
509
projectsetid = fields.getfirst('projectsetid')
510
if projectsetid is None:
511
req.throw_error(req.HTTP_BAD_REQUEST,
512
"Required: projectsetid")
513
# Get optional fields
514
synopsis = fields.getfirst('synopsis')
515
url = fields.getfirst('url')
516
deadline = fields.getfirst('deadline')
517
if deadline is not None:
519
deadline = util.parse_iso8601(deadline).timetuple()
520
except ValueError, e:
521
req.throw_error(req.HTTP_BAD_REQUEST, e.message)
525
dbquery = db.return_insert(
527
'projectsetid': projectsetid,
528
'synopsis': synopsis,
530
'deadline': deadline,
533
frozenset(["projectsetid", "synopsis", "url", "deadline"]), # fields
534
["projectid"], # returns
538
response = cjson.encode(dbquery.dictresult()[0])
540
req.content_type = "text/plain"
491
544
# TODO: write userservice/create_group
492
545
# Required cap: CAP_MANAGEGROUPS
510
563
"get_user": handle_get_user,
511
564
"get_enrolments": handle_get_enrolments,
512
565
"create_project_set": handle_create_project_set,
566
"create_project": handle_create_project,