sync-cut: add argument to control synchronisation delta
This commit is contained in:
parent
de7997f1b1
commit
fab734b7e0
|
@ -27,8 +27,14 @@ from authentic2_auth_oidc.models import OIDCProvider, OIDCAccount
|
||||||
|
|
||||||
|
|
||||||
class Command(BaseCommand):
|
class Command(BaseCommand):
|
||||||
|
|
||||||
|
def add_arguments(self, parser):
|
||||||
|
parser.add_argument(
|
||||||
|
'--delta', metavar='DELTA', type=int, default=300)
|
||||||
|
|
||||||
def handle(self, *args, **options):
|
def handle(self, *args, **options):
|
||||||
verbose = int(options['verbosity']) > 0
|
verbose = int(options['verbosity']) > 0
|
||||||
|
delta = options['delta']
|
||||||
|
|
||||||
# check all existing users
|
# check all existing users
|
||||||
def chunks(l, n):
|
def chunks(l, n):
|
||||||
|
@ -56,7 +62,7 @@ class Command(BaseCommand):
|
||||||
|
|
||||||
# update recently modified users
|
# update recently modified users
|
||||||
url = settings.CUT_API_BASE_URL + 'users/?modified__gt=%s' % (
|
url = settings.CUT_API_BASE_URL + 'users/?modified__gt=%s' % (
|
||||||
datetime.datetime.now() - datetime.timedelta(seconds=300)).strftime('%Y-%m-%dT%H:%M:%S')
|
datetime.datetime.now() - datetime.timedelta(seconds=delta)).strftime('%Y-%m-%dT%H:%M:%S')
|
||||||
resp = requests.get(url, auth=settings.CUT_API_CREDENTIALS)
|
resp = requests.get(url, auth=settings.CUT_API_CREDENTIALS)
|
||||||
resp.raise_for_status()
|
resp.raise_for_status()
|
||||||
for user_dict in resp.json()['results']:
|
for user_dict in resp.json()['results']:
|
||||||
|
|
Reference in New Issue