660
660
return(cjson.encode({'response': 'okay'}))
662
@require_method('POST')
663
@require_role_anywhere('tutor', 'lecturer')
664
def handle_unassign_group(req, fields):
665
"""Remove a user from a project group.
667
The user is removed from the group in the database, and access to the
668
group Subversion repository is revoked.
670
Note that any checkouts will remain, although they will be unusable.
673
# Get required fields
674
login = fields.getfirst('login')
675
groupid = fields.getfirst('groupid')
676
if login is None or groupid is None:
677
raise BadRequest("Required: login, groupid")
679
group = req.store.get(ivle.database.ProjectGroup, int(groupid))
680
user = ivle.database.User.get_by_login(req.store, login)
682
# Remove membership from the database
683
# We can't keep a transaction open until the end here, as usrmgt-server
684
# needs to see the changes!
685
group.members.remove(user)
688
# Rebuild the svn config file
689
# Contact the usrmgt server
690
msg = {'rebuild_svn_group_config': {}}
692
usrmgt = chat.chat(usrmgt_host, usrmgt_port, msg, usrmgt_magic)
693
except cjson.DecodeError, e:
694
raise Exception("Could not understand usrmgt server response: %s" +
697
if 'response' not in usrmgt or usrmgt['response']=='failure':
698
raise Exception("Failure creating repository: " + str(usrmgt))
700
return(cjson.encode({'response': 'okay'}))
662
702
# Map action names (from the path)
663
703
# to actual function objects
672
712
"get_group_membership": handle_get_group_membership,
673
713
"create_group": handle_create_group,
674
714
"assign_group": handle_assign_group,
715
"unassign_group": handle_unassign_group,