Working on products and carts
This commit is contained in:
@@ -43,25 +43,29 @@ async def post_order_cart_obj(
|
||||
return result
|
||||
|
||||
|
||||
# Update 2021-08-02 (partially)
|
||||
@router.patch('/{order_cart_id}', response_model=Resp_Body_Base)
|
||||
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_list: Optional[bool] = False, # Replace all the lines instead of trying to update
|
||||
# was repl_order_cart_line_li # NOTE: It was with out _list, just _li
|
||||
# was repl_order_cart_line_list # NOTE: It was with out _list, just _li
|
||||
x_account_id: Optional[str] = Header(..., ),
|
||||
return_obj: Optional[bool] = True,
|
||||
inc_order_cart_line_li: Optional[bool] = True,
|
||||
inc_order_cart_line_list: Optional[bool] = True,
|
||||
inc_order_cart_cfg: Optional[bool] = True,
|
||||
by_alias: Optional[bool] = True,
|
||||
exclude_unset: Optional[bool] = True,
|
||||
):
|
||||
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
log.debug(locals())
|
||||
|
||||
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)
|
||||
order_cart_obj_up_result = update_order_cart_obj(
|
||||
order_cart_obj = order_cart_obj,
|
||||
repl_order_cart_line_list = repl_order_cart_line_list,
|
||||
)
|
||||
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
|
||||
@@ -73,7 +77,11 @@ async def patch_order_cart_obj(
|
||||
return mk_resp(data=False, status_code=500) # Internal Server Error
|
||||
|
||||
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):
|
||||
if order_cart_obj := load_order_cart_obj(
|
||||
order_cart_id = order_cart_id,
|
||||
inc_order_cart_line_list = inc_order_cart_line_list,
|
||||
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:
|
||||
@@ -110,13 +118,13 @@ 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_li: Optional[bool] = True,
|
||||
inc_order_cart_line_list: Optional[bool] = True,
|
||||
inc_order_cart_cfg: Optional[bool] = True,
|
||||
x_account_id: str = Header(...),
|
||||
by_alias: Optional[bool] = True,
|
||||
exclude_unset: Optional[bool] = True,
|
||||
):
|
||||
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
log.debug(locals())
|
||||
|
||||
obj_type = 'order_cart'
|
||||
@@ -162,7 +170,11 @@ async def lookup_order_cart_obj(
|
||||
order_cart_id = order_cart_obj_result.get('order_cart_id', None)
|
||||
order_cart_id_random = order_cart_obj_result.get('order_cart_id_random', None)
|
||||
|
||||
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):
|
||||
if order_cart_obj := load_order_cart_obj(
|
||||
order_cart_id = order_cart_id,
|
||||
inc_order_cart_line_list = inc_order_cart_line_list,
|
||||
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:
|
||||
@@ -173,7 +185,9 @@ async def lookup_order_cart_obj(
|
||||
order_cart_id = order_cart_obj.get('order_cart_id', None)
|
||||
order_cart_obj_li.append(
|
||||
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
|
||||
order_cart_id = order_cart_id,
|
||||
inc_order_cart_line_list = inc_order_cart_line_list,
|
||||
inc_order_cart_cfg = inc_order_cart_cfg,
|
||||
)
|
||||
)
|
||||
data = order_cart_obj_li
|
||||
@@ -183,10 +197,11 @@ async def lookup_order_cart_obj(
|
||||
return mk_resp(data=False, status_code=404, response=response) # Not Found
|
||||
|
||||
|
||||
# Update 2021-08-02 (partially)
|
||||
@router.get('/{order_cart_id}', response_model=Resp_Body_Base)
|
||||
async def get_order_cart_obj(
|
||||
order_cart_id: str = Query(..., min_length=1, max_length=22),
|
||||
inc_order_cart_line_li: bool = False,
|
||||
inc_order_cart_line_list: bool = False,
|
||||
inc_order_cart_cfg: bool = False,
|
||||
x_account_id: str = Header(...),
|
||||
by_alias: bool = True,
|
||||
@@ -195,7 +210,11 @@ async def get_order_cart_obj(
|
||||
log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
log.debug(locals())
|
||||
|
||||
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):
|
||||
if order_cart_obj := load_order_cart_obj(
|
||||
order_cart_id = order_cart_id,
|
||||
inc_order_cart_line_list = inc_order_cart_line_list,
|
||||
inc_order_cart_cfg = inc_order_cart_cfg,
|
||||
):
|
||||
data = order_cart_obj.dict(by_alias=by_alias, exclude_unset=exclude_unset)
|
||||
return mk_resp(data=data)
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user