Skip to content

Commit

Permalink
update admin.py to include removeUsersFromGroups
Browse files Browse the repository at this point in the history
  • Loading branch information
slibby committed Oct 14, 2016
1 parent 2ad09ab commit 41aafa3
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions agoTools/admin.py
Expand Up @@ -206,6 +206,28 @@ def addUsersToGroups(self, users, groups):
toolSummary.append({group: json.loads(response)})

return toolSummary

def removeUsersFromGroups(self, users, groups):
'''
REQUIRES ADMIN ACCESS
Remove organization users from multiple groups and return a list of the status
'''
# Provide one or more usernames in a list.
# e.g. ['user_1', 'user_2']
# Provide one or more group IDs in a list.
# e.g. ['d93aabd856f8459a8905a5bd434d4d4a', 'f84c841a3dfc4591b1ff83281ea5025f']

toolSummary = []

# Assign users to the specified group(s).
parameters = urllib.urlencode({'token': self.user.token, 'f': 'json'})
for group in groups:
# Add Users - REQUIRES POST method (undocumented operation as of 2013-11-12).
response = urllib.urlopen(self.user.portalUrl + '/sharing/rest/community/groups/' + group + '/removeUsers?', 'users=' + ','.join(users) + "&" + parameters).read()
# Users not removed will be reported back with each group.
toolSummary.append({group: json.loads(response)})

return toolSummary

def reassignAllUser1ItemsToUser2(self, userFrom, userTo):
'''
Expand Down

0 comments on commit 41aafa3

Please sign in to comment.