Code clean up and standardize
This commit is contained in:
@@ -116,6 +116,54 @@ async def post_person_obj_new_v3(
|
||||
# ### BEGIN ### API Person ### post_person_obj_new_v3() ###
|
||||
|
||||
|
||||
# ### BEGIN ### API Person ### patch_person_obj_exist_v3() ###
|
||||
# Updated 2021-08-24
|
||||
@router.patch('/{person_id}/exist_v3', response_model=Resp_Body_Base)
|
||||
async def patch_person_obj_exist_v3(
|
||||
person_obj: Person_Base,
|
||||
person_id: str = Query(..., min_length=11, max_length=22),
|
||||
create_sub_obj: bool = False,
|
||||
fail_any: bool = True, # Fail if any thing goes wrong for sub objects
|
||||
x_account_id: Optional[str] = Header(..., ),
|
||||
return_obj: Optional[bool] = True,
|
||||
by_alias: Optional[bool] = True,
|
||||
exclude_unset: Optional[bool] = True,
|
||||
exclude_none: Optional[bool] = True,
|
||||
response: Response = Response,
|
||||
):
|
||||
log.setLevel(logging.WARNING) # 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)
|
||||
|
||||
if update_person_obj_result := update_person_obj_v3(
|
||||
person_id = person_id,
|
||||
person_obj_exist = person_obj,
|
||||
create_sub_obj = create_sub_obj,
|
||||
fail_any = fail_any,
|
||||
): pass
|
||||
else: return mk_resp(data=False, status_code=400, response=response, status_message='The event person was not created. Check the field names and data types.')
|
||||
|
||||
if update_person_obj_result:
|
||||
if return_obj:
|
||||
if load_person_obj_result := load_person_obj(person_id=person_id):
|
||||
data = load_person_obj_result
|
||||
else:
|
||||
data = False
|
||||
else:
|
||||
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=response, status_message='The event person was created.')
|
||||
else:
|
||||
return mk_resp(data=False, status_code=400, response=response, status_message='The result from trying to create an event person was unexpected.')
|
||||
# ### END ### API Person ### patch_person_obj_exist_v3() ###
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# ### BEGIN ### API Person ### post_person_json() ###
|
||||
@@ -124,7 +172,7 @@ async def post_person_obj_new_v3(
|
||||
async def post_person_json(
|
||||
person_obj: Person_Base,
|
||||
# person_id: str = Query(..., min_length=1, max_length=22),
|
||||
# create_missing_obj: bool = False,
|
||||
# create_sub_obj: bool = False,
|
||||
process_contact: bool = False,
|
||||
process_organization: bool = False,
|
||||
x_account_id: Optional[str] = Header(..., ),
|
||||
|
||||
Reference in New Issue
Block a user