439
439
##fullpowers = req.user.hasCap(caps.CAP_GETUSER)
442
login = fields.getfirst('login')
442
user = ivle.database.User.get_by_login(req.store,
443
fields.getfirst('login'))
444
445
raise AttributeError()
445
if not fullpowers and login != req.user.login:
446
if not fullpowers and user != req.user:
446
447
# Not allowed to edit other users
447
448
req.throw_error(req.HTTP_FORBIDDEN,
448
449
"You do not have permission to see another user's subjects.")
449
450
except AttributeError:
450
451
# If login not specified, update yourself
451
login = req.user.login
453
# Just talk direct to the DB
454
454
db = ivle.db.DB()
455
enrolments = db.get_enrolment(login)
457
e['groups'] = db.get_enrolment_groups(login, e['offeringid'])
456
for e in user.active_enrolments:
457
dict_enrolments.append({
458
'offeringid': e.offering.id,
459
'subj_code': e.offering.subject.code,
460
'subj_name': e.offering.subject.name,
461
'subj_short_name': e.offering.subject.short_name,
462
'url': e.offering.subject.url,
463
'year': e.offering.semester.year,
464
'semester': e.offering.semester.semester,
465
'groups': db.get_enrolment_groups(user.login,
459
response = cjson.encode(enrolments)
469
response = cjson.encode(dict_enrolments)
460
470
req.content_type = "text/plain"
461
471
req.write(response)