Working on the cart and other related things

This commit is contained in:
Scott Idem
2021-05-12 15:25:59 -04:00
parent 9a46b755bf
commit ee863face2
3 changed files with 58 additions and 34 deletions

View File

@@ -46,6 +46,7 @@ async def post_order_cart_obj(
async def patch_order_cart_obj(
order_cart_id: str = Query(..., min_length=1, max_length=22),
order_cart_obj: Order_Cart_Base = None,
repl_order_cart_line_li: Optional[bool] = False,
x_account_id: Optional[str] = Header(..., ),
return_obj: Optional[bool] = True,
inc_order_cart_line_li: Optional[bool] = True,
@@ -53,10 +54,12 @@ async def patch_order_cart_obj(
by_alias: Optional[bool] = True,
exclude_unset: Optional[bool] = True,
):
log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.debug(locals())
order_cart_obj_up_result = update_order_cart_obj(order_cart_obj)
log.debug(order_cart_obj)
order_cart_obj_up_result = update_order_cart_obj(order_cart_obj=order_cart_obj, repl_order_cart_line_li=repl_order_cart_line_li)
if isinstance(order_cart_obj_up_result, int):
log.info(f'Order cart update and the result was an int: {order_cart_obj_up_result}')
pass
@@ -67,26 +70,14 @@ async def patch_order_cart_obj(
log.error(f'Order cart update and the result was an bool: {order_cart_obj_up_result}')
return mk_resp(data=False, status_code=500) # Internal Server Error
if order_cart_obj := load_order_cart_obj(order_cart_id=order_cart_id, inc_order_cart_line_li=inc_order_cart_line_li, inc_order_cart_cfg=inc_order_cart_cfg):
data = order_cart_obj.dict(by_alias=True, exclude_unset=False)
return mk_resp(data=data)
if return_obj:
if order_cart_obj := load_order_cart_obj(order_cart_id=order_cart_id, inc_order_cart_line_li=inc_order_cart_line_li, inc_order_cart_cfg=inc_order_cart_cfg):
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
else:
return mk_resp(data=False, status_code=404) # Not Found
# obj_type = 'order_cart'
# obj_data_dict = obj.dict(by_alias=False, exclude_unset=True)
# obj_data_dict['id'] = redis_lookup_id_random(record_id_random=obj_id, table_name=obj_type)
# obj_data_dict['id_random'] = obj_id
# result = patch_obj_template(
# obj_type=obj_type,
# data=obj_data_dict,
# obj_id=order_cart_id,
# return_obj=True,
# by_alias=True,
# exclude_unset=True,
# )
# return result
return mk_resp(data=True)
@router.get('/list', response_model=Resp_Body_Base)