Try stepping through fas users alphabetically in badges cronjob.
This commit is contained in:
parent
785dcf8604
commit
6eeaecd1d7
1 changed files with 12 additions and 8 deletions
|
@ -6,6 +6,7 @@ __main__.__requires__ = __requires__ = ["tahrir-api", "sqlalchemy>=0.7"];
|
||||||
import pkg_resources
|
import pkg_resources
|
||||||
pkg_resources.require(__requires__)
|
pkg_resources.require(__requires__)
|
||||||
|
|
||||||
|
import itertools
|
||||||
import time
|
import time
|
||||||
import urllib
|
import urllib
|
||||||
import socket
|
import socket
|
||||||
|
@ -63,10 +64,7 @@ def user_in_group(user, group_name):
|
||||||
# They must be actually 'approved' in that group for this to count
|
# They must be actually 'approved' in that group for this to count
|
||||||
return relevant_role.role_status == 'approved'
|
return relevant_role.role_status == 'approved'
|
||||||
|
|
||||||
|
def get_all_fas_users(creds)
|
||||||
def get_fas_groupings(fas_credentials, lookup, **config):
|
|
||||||
creds = fas_credentials
|
|
||||||
|
|
||||||
fasclient = fedora.client.fas2.AccountSystem(
|
fasclient = fedora.client.fas2.AccountSystem(
|
||||||
username=creds['username'],
|
username=creds['username'],
|
||||||
password=creds['password'],
|
password=creds['password'],
|
||||||
|
@ -76,17 +74,23 @@ def get_fas_groupings(fas_credentials, lookup, **config):
|
||||||
socket.setdefaulttimeout(600)
|
socket.setdefaulttimeout(600)
|
||||||
try:
|
try:
|
||||||
log.info("Downloading FAS cache")
|
log.info("Downloading FAS cache")
|
||||||
request = fasclient.send_request('/user/list',
|
for a, b in itertools.product(string.lowercase, string.lowercase):
|
||||||
req_params={'search': '*'},
|
term = a + b + '*'
|
||||||
auth=True)
|
log.info(" Querying FAS for %r" % term)
|
||||||
|
request = fasclient.send_request('/user/list',
|
||||||
|
req_params={'search': term},
|
||||||
|
auth=True)
|
||||||
|
for person in request['people']:
|
||||||
|
yield person
|
||||||
finally:
|
finally:
|
||||||
socket.setdefaulttimeout(timeout)
|
socket.setdefaulttimeout(timeout)
|
||||||
|
|
||||||
mega_list = request['people']
|
|
||||||
|
|
||||||
|
def get_fas_groupings(fas_credentials, lookup, **config):
|
||||||
results = {}
|
results = {}
|
||||||
packager_id, ambassadors_id = None, None
|
packager_id, ambassadors_id = None, None
|
||||||
sponsor_types = ['sponsor', 'administrator']
|
sponsor_types = ['sponsor', 'administrator']
|
||||||
|
mega_list = get_all_fas_users(fas_credentials)
|
||||||
for user in mega_list:
|
for user in mega_list:
|
||||||
# This is the main check.
|
# This is the main check.
|
||||||
for group_name, badge_id in lookup.iteritems():
|
for group_name, badge_id in lookup.iteritems():
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue