A lot of code clean up! Also adding in Response everywhere...

This commit is contained in:
Scott Idem
2021-08-10 18:09:34 -04:00
parent 73466456ee
commit d933395a9f
57 changed files with 290 additions and 147 deletions

View File

@@ -27,6 +27,7 @@ async def post_order_cart_obj(
return_obj: Optional[bool] = True,
by_alias: Optional[bool] = True,
exclude_unset: Optional[bool] = True,
response: Response = Response,
):
log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.debug(locals())
@@ -56,6 +57,7 @@ async def patch_order_cart_obj(
inc_order_cfg: Optional[bool] = True,
by_alias: Optional[bool] = True,
exclude_unset: Optional[bool] = True,
response: Response = Response,
):
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.debug(locals())
@@ -85,7 +87,7 @@ async def patch_order_cart_obj(
data = order_cart_obj.dict(by_alias=True, exclude_unset=False)
return mk_resp(data=data)
else:
return mk_resp(data=False, status_code=404) # Not Found
return mk_resp(data=False, status_code=404, response=response) # Not Found
else:
return mk_resp(data=True)
@@ -97,6 +99,7 @@ async def get_order_cart_obj_li(
x_account_id: str = Header(...),
by_alias: Optional[bool] = True,
exclude_unset: Optional[bool] = True,
response: Response = Response,
):
log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.debug(locals())
@@ -115,7 +118,6 @@ async def get_order_cart_obj_li(
# Look up is only for account, order, person, or user records
@router.get('/lookup', response_model=Resp_Body_Base)
async def lookup_order_cart_obj(
response: Response,
for_obj_type: Optional[str] = Query(None, min_length=2, max_length=50),
for_obj_id: Optional[Union[int,str]] = None,
inc_order_cart_line_list: Optional[bool] = True,
@@ -123,6 +125,7 @@ async def lookup_order_cart_obj(
x_account_id: str = Header(...),
by_alias: Optional[bool] = True,
exclude_unset: Optional[bool] = True,
response: Response = Response,
):
log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.debug(locals())
@@ -131,7 +134,7 @@ async def lookup_order_cart_obj(
base_name = Order_Cart_Base
if for_obj_id := redis_lookup_id_random(record_id_random=for_obj_id, table_name=for_obj_type): pass
else: return mk_resp(data=False, status_code=404) # Not Found
else: return mk_resp(data=False, status_code=404, response=response) # Not Found
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
data = {}
@@ -178,7 +181,7 @@ async def lookup_order_cart_obj(
data = order_cart_obj.dict(by_alias=True, exclude_unset=False)
return mk_resp(data=data)
else:
return mk_resp(data=False, status_code=404) # Not Found
return mk_resp(data=False, status_code=404, response=response) # Not Found
elif isinstance(order_cart_obj_result, list):
order_cart_obj_li = []
for order_cart_obj in order_cart_obj_result:
@@ -209,6 +212,7 @@ async def get_order_cart_obj(
x_account_id: str = Header(...),
by_alias: bool = True,
exclude_unset: bool = True,
response: Response = Response,
):
log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.debug(locals())
@@ -226,7 +230,7 @@ async def get_order_cart_obj(
data = order_cart_obj.dict(by_alias=by_alias, exclude_unset=exclude_unset)
return mk_resp(data=data)
else:
return mk_resp(data=False, status_code=404) # Not Found
return mk_resp(data=False, status_code=404, response=response) # Not Found
# ### END ### API Order Cart Routes ### get_order_cart_obj() ###
@@ -234,6 +238,7 @@ async def get_order_cart_obj(
async def delete_order_cart_obj(
obj_id: str = Query(..., min_length=1, max_length=22),
x_account_id: str = Header(...),
response: Response = Response,
):
log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.debug(locals())