From e02045c9acf4aceff6756345a25c5b88c5b5885d Mon Sep 17 00:00:00 2001 From: Tanner Collin Date: Wed, 6 Apr 2022 20:53:34 +0000 Subject: [PATCH] Strip member names whitespace, alert about test users --- apiserver/apiserver/api/utils.py | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/apiserver/apiserver/api/utils.py b/apiserver/apiserver/api/utils.py index 22cbd37..76d11f7 100644 --- a/apiserver/apiserver/api/utils.py +++ b/apiserver/apiserver/api/utils.py @@ -299,12 +299,26 @@ def create_new_member(data, user): models.Member.objects.create( user=user, - first_name=data['first_name'].title().strip(), - last_name=data['last_name'].title().strip(), - preferred_name=data['first_name'].title().strip(), + first_name=data['first_name'], + last_name=data['last_name'], + preferred_name=data['first_name'], ) def register_user(data, user): + data = data.copy() + data['first_name'] = data['first_name'].title().strip() + data['last_name'] = data['last_name'].title().strip() + + if 'test' in data['username']: + msg = 'Someone created a test account: {} {} {} {}'.format( + data['username'], + data['first_name'], + data['last_name'], + data['email'], + ) + logger.info(msg) + alert_tanner(msg) + try: logger.info('Creating new member...') create_new_member(data, user) @@ -351,6 +365,7 @@ def register_user(data, user): logger.exception(msg) alert_tanner(msg) + if data['request_id']: utils_stats.set_progress(data['request_id'], 'Done!') time.sleep(1)