Code clean up and standardize
This commit is contained in:
@@ -649,7 +649,7 @@ def create_person_obj_v3(
|
||||
# Updated 2021-08-24
|
||||
def update_person_obj_v3(
|
||||
person_id: int|str,
|
||||
person_obj_exist: Event_Person_Base,
|
||||
person_obj_exist: Person_Base,
|
||||
create_sub_obj: bool = False,
|
||||
fail_any: bool = False, # Fail if any thing goes wrong for sub objects
|
||||
) -> bool:
|
||||
@@ -659,6 +659,8 @@ def update_person_obj_v3(
|
||||
if person_id := redis_lookup_id_random(record_id_random=person_id, table_name='person'): pass
|
||||
else: return False
|
||||
|
||||
account_id = get_account_id_w_person_id(person_id=person_id)
|
||||
|
||||
# Can't update the person_id alias if the .id was never set.
|
||||
# person_obj_exist.person_id = person_id
|
||||
if not person_obj_exist.id:
|
||||
@@ -823,7 +825,7 @@ def update_person_obj_v3(
|
||||
log.info(f'No User ID found.')
|
||||
# from app.methods.user_methods import create_user_obj_v3
|
||||
if create_user_obj_result := create_user_obj(
|
||||
person_id = person_id,
|
||||
account_id = account_id,
|
||||
user_obj_new = user_obj_unknown,
|
||||
create_sub_obj = create_sub_obj,
|
||||
fail_any = fail_any,
|
||||
@@ -867,6 +869,8 @@ def update_person_obj(
|
||||
if person_id := redis_lookup_id_random(record_id_random=person_id, table_name='person'): pass
|
||||
else: return False
|
||||
|
||||
account_id = get_account_id_w_person_id(person_id=person_id)
|
||||
|
||||
person_obj_up.id = person_id
|
||||
|
||||
log.debug(person_obj_up)
|
||||
@@ -950,7 +954,7 @@ def update_person_obj(
|
||||
# NOTE: This will blindly create a new user even if there was one associated but the person.user_id was not found.
|
||||
user_obj_in = person_obj_up.user
|
||||
log.debug(user_obj_in)
|
||||
if user_obj_in_result := create_user_obj(user_obj_new=user_obj_in):
|
||||
if user_obj_in_result := create_user_obj(account_id=account_id, user_obj_new=user_obj_in):
|
||||
# log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
log.debug(user_obj_in_result)
|
||||
# Need to update the person with the new user_id
|
||||
|
||||
Reference in New Issue
Block a user