Minor changes

This commit is contained in:
Scott Idem
2022-11-28 12:42:31 -05:00
parent 5ebb725532
commit 856e2a2891
3 changed files with 97 additions and 2 deletions

View File

@@ -325,6 +325,99 @@ async def get_obj(
return mk_resp(data=False, status_code=404, response=response)
# @router.patch('/{obj_type_l1}/{obj_id}')
# @router.patch('/{obj_type_l1}/{obj_type_l2}/{obj_id}')
# @router.patch('/{obj_type_l1}/{obj_type_l2}/{obj_type_l3}/{obj_id}')
# async def patch_obj(
# obj_type_l1: Optional[str] = Query(..., max_length=50),
# obj_type_l2: str=None,
# obj_type_l3: str=None,
# obj_id: str = Query(..., min_length=11, max_length=22),
# for_obj_type: Optional[str] = Query(None, max_length=50),
# for_obj_id: Optional[str] = Query(None, max_length=22),
# x_account_id: str = Header(...),
# qry_str: Optional[str] = Query(None, max_length=50),
# qry_int: Optional[int] = None,
# by_alias: Optional[bool] = True,
# include: Optional[list] = [],
# exclude: Optional[list] = [],
# exclude_unset: Optional[bool] = True,
# exclude_none: Optional[bool] = True,
# response: Response = Response,
# commons: Common_Route_Params = Depends(common_route_params),
# ):
# """
# Simple select object type with an ID:
# - **obj_type_l1, obj_type_l2, obj_type_l3**:
# - Examples:
# - /account = account
# - /user = user
# - /user/role = user_role
# - /event = event
# - /event/exhibit = event_exhibit
# - /order = order
# - /order/cart = order_cart
# - /order/cart/line = order_cart_line
# - /lu/some_lookup = lu_some_lookup
# """
# log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
# log.debug(locals())
# debug_data = {}
# debug_data['obj_type_l1'] = obj_type_l1
# debug_data['obj_type_l2'] = obj_type_l2
# debug_data['obj_type_l3'] = obj_type_l3
# debug_data['obj_id'] = obj_id
# debug_data['for_obj_type'] = for_obj_type
# debug_data['for_obj_id'] = for_obj_id
# log.debug(debug_data)
# if obj_type_l1 and obj_type_l2 and obj_type_l3:
# obj_name = f'{obj_type_l1}_{obj_type_l2}_{obj_type_l3}'
# if obj_name in obj_type_li:
# #table_name = obj_type_li[obj_name]
# #table_name = obj_type_li[obj_name]['table_name']
# pass
# else:
# return mk_resp(data=False, status_code=400, response=commons.response)
# elif obj_type_l1 and obj_type_l2:
# obj_name = f'{obj_type_l1}_{obj_type_l2}'
# if obj_name in obj_type_li:
# #table_name = obj_type_li[obj_name]['table_name']
# pass
# else:
# return mk_resp(data=False, status_code=400, response=commons.response)
# elif obj_type_l1:
# obj_name = f'{obj_type_l1}'
# if obj_name in obj_type_li:
# #table_name = obj_type_li[obj_name]['table_name']
# pass
# else:
# return mk_resp(data=False, status_code=400, response=commons.response)
# else:
# log.warning('We should not be here')
# return mk_resp(data=False, status_code=400, response=commons.response)
# table_name = obj_type_li[obj_name]['table_name']
# # NOTE: Add a check for the object ID... assuming it is a random ID string for now.
# if sql_result := sql_select(table_name=table_name, record_id_random=obj_id):
# log.debug(sql_result)
# base_name = obj_type_li[obj_name]['base_name']
# resp_data = base_name(**sql_result).dict(by_alias=commons.by_alias, exclude_unset=commons.exclude_unset)
# return mk_resp(data=resp_data, response=response) #, details=debug_data)
# else:
# log.debug(sql_result)
# return mk_resp(data=False, status_code=404, response=response)
@router.delete('/{obj_type_l1}/{obj_id}')
@router.delete('/{obj_type_l1}/{obj_type_l2}/{obj_id}')
@router.delete('/{obj_type_l1}/{obj_type_l2}/{obj_type_l3}/{obj_id}')