Code clean up

This commit is contained in:
Scott Idem
2022-01-18 14:16:43 -05:00
parent fab61f4e17
commit 037626cb76

View File

@@ -152,208 +152,6 @@ async def patch_person_obj(
# ### END ### API Person Routers ### patch_person_obj() ### # ### END ### API Person Routers ### patch_person_obj() ###
# # ### BEGIN ### API Person ### v3_post_person_obj_new() ###
# # Using create_update_person_obj_v4b() now
# # Updated 2021-09-08
# # Deprecated 2022-01-11
# @router.post('/v3/person/new', response_model=Resp_Body_Base)
# async def v3_post_person_obj_new(
# person_obj: Person_Base,
# process_contact: bool = False,
# process_organization: bool = False,
# process_user: bool = False,
# create_sub_obj: bool = False,
# fail_any: bool = True, # Fail if any thing goes wrong for sub objects
# inc_address: bool = False,
# inc_contact: bool = False,
# inc_organization: bool = False,
# inc_user: bool = False,
# return_obj: bool = True,
# commons: Common_Route_Params = Depends(common_route_params),
# ):
# log.setLevel(logging.INFO) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
# log.debug(locals())
# if create_update_person_obj_result := create_update_person_obj_v4b(
# account_id = commons.x_account_id,
# person_dict_obj = person_obj,
# person_id = None,
# # process_contact = process_contact,
# # process_organization = process_organization,
# # process_user = process_user,
# ): pass
# else: return mk_resp(data=False, status_code=400, response=commons.response, status_message='The person was not created. Check the field names and data types.')
# if isinstance(create_update_person_obj_result, int):
# person_id = create_update_person_obj_result
# if return_obj:
# if load_person_obj_result := load_person_obj(
# person_id = person_id,
# enabled = commons.enabled,
# inc_address = inc_address,
# inc_contact = inc_contact,
# inc_organization = inc_organization,
# inc_user = inc_user,
# ):
# data = load_person_obj_result
# else:
# data = False
# return mk_resp(data=data, response=commons.response, status_message='The person was probably created, but there was a problem returning the data.')
# else:
# person_id = create_update_person_obj_result
# person_id_random = get_id_random(record_id=person_id, table_name='person')
# data = {}
# data['person_id'] = person_id
# data['person_id_random'] = person_id_random
# return mk_resp(data=data, response=commons.response, status_message='The person was created.')
# else:
# return mk_resp(data=False, status_code=400, response=commons.response, status_message='The result from trying to create a person was unexpected.')
# # ### BEGIN ### API Person ### v3_post_person_obj_new() ###
# # ### BEGIN ### API Person ### v3_patch_person_obj_exist ###
# # Using create_update_person_obj_v4b() now
# # Updated 2021-09-08
# # Deprecated 2022-01-11
# @router.patch('/v3/person/{person_id}/exist', response_model=Resp_Body_Base)
# async def v3_patch_person_obj_exist(
# person_obj: Person_Base,
# person_id: str = Query(..., min_length=11, max_length=22),
# process_contact: bool = False,
# process_organization: bool = False,
# process_user: bool = False,
# create_sub_obj: bool = False,
# fail_any: bool = True, # Fail if any thing goes wrong for sub objects
# inc_address: bool = False,
# inc_contact: bool = False,
# inc_organization: bool = False,
# inc_user: bool = False,
# return_obj: bool = True,
# commons: Common_Route_Params = Depends(common_route_params),
# ):
# log.setLevel(logging.INFO) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
# log.debug(locals())
# if person_id := redis_lookup_id_random(record_id_random=person_id, table_name='person'): pass
# else: return mk_resp(data=None, status_code=404, response=commons.response, status_message='The person was not updated. The person ID was invalid or not found.')
# if create_update_person_obj_result := create_update_person_obj_v4b(
# account_id = commons.x_account_id,
# person_dict_obj = person_obj,
# person_id = person_id,
# # process_contact = process_contact,
# # process_organization = process_organization,
# # process_user = process_user,
# ): pass
# else: return mk_resp(data=False, status_code=400, response=commons.response, status_message='The person was not updated. Check the field names and data types.')
# if isinstance(create_update_person_obj_result, int):
# log.info('Create/Update successful')
# person_id = create_update_person_obj_result
# if return_obj:
# if load_person_obj_result := load_person_obj(
# person_id = person_id,
# enabled = commons.enabled,
# inc_address = inc_address,
# inc_contact = inc_contact,
# inc_organization = inc_organization,
# inc_user = inc_user,
# ):
# data = load_person_obj_result
# else:
# data = False
# return mk_resp(data=data, response=commons.response, status_message='The person was probably updated, but there was a problem returning the data.')
# else:
# person_id = create_update_person_obj_result
# person_id_random = get_id_random(record_id=person_id, table_name='person')
# data = {}
# data['person_id'] = person_id
# data['person_id_random'] = person_id_random
# return mk_resp(data=data, response=commons.response, status_message='The person was updated.')
# else:
# return mk_resp(data=False, status_code=400, response=commons.response, status_message='The result from trying to update the person was unexpected.')
# # ### END ### API Person ### v3_patch_person_obj_exist ###
# # ### BEGIN ### API Person ### post_person_json() ###
# # Updated 2021-09-08
# # Deprecated 2022-01-11
# @router.post('/person/json', response_model=Resp_Body_Base)
# async def post_person_json(
# person_obj: Person_Base,
# # person_id: str = Query(..., min_length=1, max_length=22),
# # create_sub_obj: bool = False,
# process_contact: bool = False,
# process_organization: bool = False,
# process_user: bool = False,
# return_obj: Optional[bool] = True,
# commons: Common_Route_Params = Depends(common_route_params),
# ):
# log.setLevel(logging.INFO) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
# log.debug(locals())
# if person_obj_in_result := create_update_person_obj_v4b(
# account_id = commons.x_account_id,
# person_dict_obj = person_obj,
# person_id = None,
# process_contact = process_contact,
# process_organization = process_organization,
# process_user = process_user,
# ):
# log.debug(person_obj_in_result)
# if return_obj:
# person_obj = load_person_obj(person_id=person_obj_in_result)
# person_dict = person_obj.dict(by_alias=commons.by_alias, exclude_unset=commons.exclude_unset)
# return mk_resp(data=person_dict, response=commons.response)
# else:
# return mk_resp(data=person_obj_in_result, response=commons.response)
# else:
# return mk_resp(data=False, status_code=400, response=commons.response) # Bad Request
# # ### END ### API Person ### post_person_json() ###
# # ### BEGIN ### API Person ### patch_person_json() ###
# # Updated 2021-06-25
# # Deprecated 2022-01-11
# @router.patch('/person/{person_id}/json', response_model=Resp_Body_Base)
# async def patch_person_json(
# person_obj: Person_Base,
# person_id: str = Query(..., min_length=11, max_length=22),
# process_contact: bool = False,
# process_organization: bool = False,
# process_user: bool = False,
# return_obj: Optional[bool] = True,
# commons: Common_Route_Params = Depends(common_route_params),
# ):
# log.setLevel(logging.INFO) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
# log.debug(locals())
# if person_id := redis_lookup_id_random(record_id_random=person_id, table_name='person'): pass
# else: return mk_resp(data=None, status_code=404, response=commons.response)
# if person_obj_up_result := create_update_person_obj_v4b(
# account_id = commons.x_account_id,
# person_dict_obj = person_obj,
# process_contact = process_contact,
# process_organization = process_organization,
# process_user = process_user,
# ):
# log.debug(person_obj_up_result)
# if return_obj:
# person_obj = load_person_obj(person_id=person_id)
# person_dict = person_obj.dict(by_alias=commons.by_alias, exclude_unset=commons.exclude_unset)
# return mk_resp(data=person_dict, response=commons.response)
# else:
# return mk_resp(data=person_obj_up_result, response=commons.response)
# else:
# return mk_resp(data=False, status_code=400, response=commons.response) # Bad Request
# # ### END ### API Person ### patch_person_json() ###
@router.get('/person/list', response_model=Resp_Body_Base) @router.get('/person/list', response_model=Resp_Body_Base)
async def get_person_obj_li( async def get_person_obj_li(
for_obj_type: Optional[str] = Query(None, min_length=2, max_length=50), for_obj_type: Optional[str] = Query(None, min_length=2, max_length=50),