Skip to content

Instantly share code, notes, and snippets.

@oevans
Last active December 19, 2015 15:39
Show Gist options
  • Select an option

  • Save oevans/5978035 to your computer and use it in GitHub Desktop.

Select an option

Save oevans/5978035 to your computer and use it in GitHub Desktop.
Draft utility functions for ago-tools
def findNewUsers(users,daysToCheck):
newUsers = []
for user in users:
if date.fromtimestamp(float(user['created'])/1000) > date.today()-timedelta(days=daysToCheck):
newUsers.append(user)
return newUsers
def addUsersToGroups(users,groups):
params = urllib.urlencode({'token' : self.user.token,
'f' : 'json'})
for groupID in groups:
for user in users:
user = users['username']
print 'Attempting to add ' + user + ' to groupID ' + groupID
# Add Users - REQUIRES POST method
response = urllib.urlopen(myAgol.portalUrl + '/sharing/rest/community/groups/' + groupID + '/addUsers?', 'users=' + user + "&" + parameters).read()
print response
# Error checking - print to console
if not 'success' in json.loads(response):
print 'ERROR: ' + user + ' was NOT added to groupID ' + groupID
def findAdmins(users):
adminUsers[]
for user in users:
if users['role'] = 'org_admin':
adminUsers.append(user)
return adminUsers
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment