Code clean up and standardize

This commit is contained in:
Scott Idem
2021-08-25 10:58:39 -04:00
parent 7859d1d2b2
commit 1369874dc2
32 changed files with 479 additions and 195 deletions

View File

@@ -78,7 +78,7 @@ async def patch_address_obj(
async def patch_address_json(
address_obj: Address_Base,
address_id: str = Query(..., min_length=1, max_length=22),
create_missing_obj: bool = False,
create_sub_obj: bool = False,
x_account_id: Optional[str] = Header(..., ),
return_obj: Optional[bool] = True,
by_alias: Optional[bool] = True,
@@ -98,7 +98,7 @@ async def patch_address_json(
if address_obj_up_result := update_address_obj(
address_id=address_id,
address_obj_up=address_obj,
create_missing_obj=create_missing_obj,
create_sub_obj=create_sub_obj,
):
log.debug(address_obj_up_result)

View File

@@ -75,7 +75,7 @@ async def patch_cont_edu_cert_obj(
async def patch_cont_edu_cert_json(
cont_edu_cert_obj: Cont_Edu_Cert_Base,
cont_edu_cert_id: str = Query(..., min_length=1, max_length=22),
create_missing_obj: bool = False,
create_sub_obj: bool = False,
x_account_id: Optional[str] = Header(..., ),
return_obj: Optional[bool] = True,
by_alias: Optional[bool] = True,
@@ -95,7 +95,7 @@ async def patch_cont_edu_cert_json(
if cont_edu_cert_obj_up_result := update_cont_edu_cert_obj(
cont_edu_cert_id=cont_edu_cert_id,
cont_edu_cert_obj_up=cont_edu_cert_obj,
create_missing_obj=create_missing_obj,
create_sub_obj=create_sub_obj,
):
log.debug(cont_edu_cert_obj_up_result)

View File

@@ -75,7 +75,7 @@ async def patch_cont_edu_cert_person_obj(
async def patch_cont_edu_cert_person_json(
cont_edu_cert_person_obj: Cont_Edu_Cert_Person_Base,
cont_edu_cert_person_id: str = Query(..., min_length=1, max_length=22),
create_missing_obj: bool = False,
create_sub_obj: bool = False,
x_account_id: Optional[str] = Header(..., ),
return_obj: Optional[bool] = True,
by_alias: Optional[bool] = True,
@@ -95,7 +95,7 @@ async def patch_cont_edu_cert_person_json(
if cont_edu_cert_person_obj_up_result := update_cont_edu_cert_person_obj(
cont_edu_cert_person_id=cont_edu_cert_person_id,
cont_edu_cert_person_obj_up=cont_edu_cert_person_obj,
create_missing_obj=create_missing_obj,
create_sub_obj=create_sub_obj,
):
log.debug(cont_edu_cert_person_obj_up_result)

View File

@@ -75,7 +75,7 @@ async def patch_contact_obj(
async def patch_contact_json(
contact_obj: Contact_Base,
contact_id: str = Query(..., min_length=1, max_length=22),
create_missing_obj: bool = False,
create_sub_obj: bool = False,
x_account_id: Optional[str] = Header(..., ),
return_obj: Optional[bool] = True,
by_alias: Optional[bool] = True,
@@ -95,7 +95,7 @@ async def patch_contact_json(
if contact_obj_up_result := update_contact_obj(
contact_id=contact_id,
contact_obj_up=contact_obj,
create_missing_obj=create_missing_obj,
create_sub_obj=create_sub_obj,
):
log.debug(contact_obj_up_result)

View File

@@ -75,7 +75,7 @@ async def patch_event_obj(
async def patch_event_json(
event_obj: Event_Base,
event_id: str = Query(..., min_length=1, max_length=22),
create_missing_obj: bool = False,
create_sub_obj: bool = False,
x_account_id: Optional[str] = Header(..., ),
return_obj: Optional[bool] = True,
by_alias: Optional[bool] = True,
@@ -95,7 +95,7 @@ async def patch_event_json(
if event_obj_up_result := update_event_obj(
event_id=event_id,
event_obj_up=event_obj,
create_missing_obj=create_missing_obj,
create_sub_obj=create_sub_obj,
):
log.debug(event_obj_up_result)

View File

@@ -308,7 +308,7 @@ async def post_event_person_new(
async def patch_event_person_json(
event_person_obj: Event_Person_Base,
event_person_id: str = Query(..., min_length=1, max_length=22),
create_missing_obj: bool = False,
create_sub_obj: bool = False,
x_account_id: Optional[str] = Header(..., ),
return_obj: Optional[bool] = True,
by_alias: Optional[bool] = True,
@@ -328,7 +328,7 @@ async def patch_event_person_json(
if event_person_obj_up_result := update_event_person_obj(
event_person_id=event_person_id,
event_person_obj_up=event_person_obj,
create_missing_obj=create_missing_obj,
create_sub_obj=create_sub_obj,
):
log.debug(event_person_obj_up_result)

View File

@@ -75,7 +75,7 @@ async def patch_event_presentation_obj(
async def patch_event_presentation_json(
event_presentation_obj: Event_Presentation_Base,
event_presentation_id: str = Query(..., min_length=1, max_length=22),
create_missing_obj: bool = False,
create_sub_obj: bool = False,
x_account_id: Optional[str] = Header(..., ),
return_obj: Optional[bool] = True,
by_alias: Optional[bool] = True,
@@ -95,7 +95,7 @@ async def patch_event_presentation_json(
if event_presentation_obj_up_result := update_event_presentation_obj(
event_presentation_id=event_presentation_id,
event_presentation_obj_up=event_presentation_obj,
create_missing_obj=create_missing_obj,
create_sub_obj=create_sub_obj,
):
log.debug(event_presentation_obj_up_result)

View File

@@ -75,7 +75,7 @@ async def patch_event_presenter_obj(
async def patch_event_presenter_json(
event_presenter_obj: Event_Presenter_Base,
event_presenter_id: str = Query(..., min_length=1, max_length=22),
create_missing_obj: bool = False,
create_sub_obj: bool = False,
x_account_id: Optional[str] = Header(..., ),
return_obj: Optional[bool] = True,
by_alias: Optional[bool] = True,
@@ -95,7 +95,7 @@ async def patch_event_presenter_json(
if event_presenter_obj_up_result := update_event_presenter_obj(
event_presenter_id=event_presenter_id,
event_presenter_obj_up=event_presenter_obj,
create_missing_obj=create_missing_obj,
create_sub_obj=create_sub_obj,
):
log.debug(event_presenter_obj_up_result)

View File

@@ -173,7 +173,7 @@ async def patch_event_session_obj(
async def patch_event_session_json(
event_session_obj: Event_Session_Base,
event_session_id: str = Query(..., min_length=1, max_length=22),
create_missing_obj: bool = False,
create_sub_obj: bool = False,
x_account_id: Optional[str] = Header(..., ),
return_obj: Optional[bool] = True,
by_alias: Optional[bool] = True,
@@ -193,7 +193,7 @@ async def patch_event_session_json(
if event_session_obj_up_result := update_event_session_obj(
event_session_id=event_session_id,
event_session_obj_up=event_session_obj,
create_missing_obj=create_missing_obj,
create_sub_obj=create_sub_obj,
):
log.debug(event_session_obj_up_result)

View File

@@ -76,7 +76,7 @@ async def patch_organization_obj(
async def post_organization_json(
organization_obj: Organization_Base,
# organization_id: str = Query(..., min_length=1, max_length=22),
# create_missing_obj: bool = False,
# create_sub_obj: bool = False,
process_contact: bool = False,
x_account_id: Optional[str] = Header(..., ),
return_obj: Optional[bool] = True,

View File

@@ -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(..., ),