Code clean up and standardize

This commit is contained in:
Scott Idem
2021-08-25 11:16:02 -04:00
parent 1369874dc2
commit 8ff404e534
7 changed files with 21 additions and 13 deletions

View File

@@ -24,6 +24,7 @@ from app.models.user_models import User_Base, User_New_Base, User_Out_Base
# Reviewed and updated 2021-08-21
# Reviewed and updated 2021-08-10
def create_user_obj(
account_id: int|str,
user_obj_new: User_New_Base,
allow_update: bool = False, # Allow updating the user account if one is found
avoid_dup_username: bool = False, # Avoid creating a duplicate by modifying the supplied username
@@ -38,7 +39,11 @@ def create_user_obj(
user_obj_data['password'] = user_obj_new.password # There has to be a better way to do this??? It thinks "password" is unset and so is excluded?
log.debug(user_obj_data)
account_id = user_obj_data.get('account_id', None)
if account_id := redis_lookup_id_random(record_id_random=account_id, table_name='account'): pass
elif account_id := user_obj_data.get('account_id', None): pass
else: return False
# account_id = user_obj_data.get('account_id', None)
username = user_obj_data.get('username', None)
log.info(f'Checking if the username is already in use for the account... Account: {account_id} Username: {username}')