250
249
# Try and contact the usrmgt server
252
response = chat.chat(usrmgt_host, usrmgt_port, msg, usrmgt_magic)
251
response = chat.chat(req.config['usrmgt']['host'],
252
req.config['usrmgt']['port'],
254
req.config['usrmgt']['magic'],
253
256
except cjson.DecodeError:
254
257
# Gave back rubbish - set the response to failure
255
258
response = {'response': 'usrmgt-failure'}
565
568
# Contact the usrmgt server
567
usrmgt = chat.chat(usrmgt_host, usrmgt_port, msg, usrmgt_magic)
570
usrmgt = chat.chat(req.config['usrmgt']['host'],
571
req.config['usrmgt']['port'],
573
req.config['usrmgt']['magic'],
568
575
except cjson.DecodeError, e:
569
576
raise Exception("Could not understand usrmgt server response:" +
649
656
# Contact the usrmgt server
650
657
msg = {'rebuild_svn_group_config': {}}
652
usrmgt = chat.chat(usrmgt_host, usrmgt_port, msg, usrmgt_magic)
659
usrmgt = chat.chat(req.config['usrmgt']['host'],
660
req.config['usrmgt']['port'],
662
req.config['usrmgt']['magic'],
664
except cjson.DecodeError, e:
665
raise Exception("Could not understand usrmgt server response: %s" +
668
if 'response' not in usrmgt or usrmgt['response']=='failure':
669
raise Exception("Failure creating repository: " + str(usrmgt))
671
return(cjson.encode({'response': 'okay'}))
673
@require_method('POST')
674
@require_role_anywhere('tutor', 'lecturer')
675
def handle_unassign_group(req, fields):
676
"""Remove a user from a project group.
678
The user is removed from the group in the database, and access to the
679
group Subversion repository is revoked.
681
Note that any checkouts will remain, although they will be unusable.
684
# Get required fields
685
login = fields.getfirst('login')
686
groupid = fields.getfirst('groupid')
687
if login is None or groupid is None:
688
raise BadRequest("Required: login, groupid")
690
group = req.store.get(ivle.database.ProjectGroup, int(groupid))
691
user = ivle.database.User.get_by_login(req.store, login)
693
# Remove membership from the database
694
# We can't keep a transaction open until the end here, as usrmgt-server
695
# needs to see the changes!
696
group.members.remove(user)
699
# Rebuild the svn config file
700
# Contact the usrmgt server
701
msg = {'rebuild_svn_group_config': {}}
703
usrmgt = chat.chat(req.config['usrmgt']['host'],
704
req.config['usrmgt']['port'],
706
req.config['usrmgt']['magic'],
653
708
except cjson.DecodeError, e:
654
709
raise Exception("Could not understand usrmgt server response: %s" +
672
727
"get_group_membership": handle_get_group_membership,
673
728
"create_group": handle_create_group,
674
729
"assign_group": handle_assign_group,
730
"unassign_group": handle_unassign_group,