A LOT of code clean up. More changes to membership tables, views, routes, methods, and models renamed.

This commit is contained in:
Scott Idem
2022-01-11 19:45:55 -05:00
parent 6e764b21e1
commit 55063d0f94
8 changed files with 328 additions and 186 deletions

View File

@@ -452,7 +452,7 @@ def create_person_kiss(
contact_id: int|None = None,
organization_id: int|None = None,
user_id: int|None = None,
):
) -> int|bool:
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.debug(locals())
@@ -469,13 +469,14 @@ def create_person_kiss(
return False
else:
person_obj = person_dict_obj
person_obj.account_id = account_id
# person_obj.account_id = account_id
person_dict = person_obj.dict(by_alias=False, exclude_defaults=False, exclude_unset=True, exclude={'contact', 'contact_id', 'contact_id_random', 'email', 'cc_email', 'membership_person_id', 'membership_person_id_random', 'organization', 'user', 'created_on', 'updated_on'})
# ### SECTION ### Process data# Look for an account_id in the user_obj
if account_id: pass
elif account_id := person_obj.account_id: pass
# ### SECTION ### Process data
# Look for an account_id in the person_obj
# if account_id: pass
# elif account_id := person_obj.account_id: pass
person_obj.account_id = account_id # Is this needed?
person_dict['account_id'] = account_id
@@ -493,7 +494,12 @@ def create_person_kiss(
# person_obj.user_id = user_id # Is this needed?
# person_dict['user_id'] = user_id
if person_dict_in_result := sql_insert(data=person_dict, table_name='person', rm_id_random=True, id_random_length=default_num_bytes): pass
if person_dict_in_result := sql_insert(
data = person_dict,
table_name = 'person',
rm_id_random = True,
id_random_length = default_num_bytes
): pass
else:
log.warning(f'Person not created.')
log.debug(person_dict_in_result)
@@ -548,7 +554,7 @@ def create_person_kiss(
else: return False
else: pass
log.info(f'Returning the new person_id: {person_id}')
log.info(f'Returning the Person ID: {person_id}')
return person_id
# ### END ### API Person Methods ### create_person_kiss() ###
@@ -573,7 +579,6 @@ def update_person_kiss(
person_dict = person_dict_obj
try:
person_obj = Person_Base(**person_dict)
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.debug(person_obj)
except ValidationError as e:
log.error(e.json())
@@ -600,7 +605,12 @@ def update_person_kiss(
# person_obj.user_id = user_id # Is this needed?
# person_dict['user_id'] = user_id
if person_dict_up_result := sql_update(data=person_dict, table_name='person', rm_id_random=True, id_random_length=default_num_bytes): pass
if person_dict_up_result := sql_update(
data = person_dict,
table_name = 'person',
rm_id_random = True,
id_random_length = default_num_bytes
): pass
else:
log.warning(f'Person not updated.')
log.debug(person_dict_up_result)