Updates related to abstracts
This commit is contained in:
@@ -9,7 +9,7 @@ from app.db_sql import sql_insert, sql_update, sql_insert_or_update, sql_select,
|
||||
|
||||
from app.routers.api_crud import delete_obj_template, get_obj_template, get_obj_li_template, patch_obj_template, post_obj_template
|
||||
|
||||
from app.methods.grant_methods import load_grant_obj, get_grant_rec_list
|
||||
from app.methods.grant_methods import create_update_grant_obj, load_grant_obj, get_grant_rec_list
|
||||
# from app.methods.grant_methods import create_update_grant_obj, load_grant_obj, get_grant_rec_list, remove_grant_obj
|
||||
|
||||
from app.models.grant_models import Grant_In
|
||||
@@ -73,49 +73,49 @@ router = APIRouter()
|
||||
# # ### END ### API Grant ### post_grant_obj() ###
|
||||
|
||||
|
||||
# # ### BEGIN ### API Grant ### patch_grant_obj() ###
|
||||
# # Updated 2023-03-22
|
||||
# @router.patch('/grant/{grant_id}', response_model=Resp_Body_Base)
|
||||
# async def patch_grant_obj(
|
||||
# grant_obj: Grant_In,
|
||||
# grant_id: str = Query(..., min_length=11, max_length=22),
|
||||
# ### BEGIN ### API Grant ### patch_grant_obj() ###
|
||||
# Updated 2023-06-28
|
||||
@router.patch('/grant/{grant_id}', response_model=Resp_Body_Base)
|
||||
async def patch_grant_obj(
|
||||
grant_obj: Grant_In,
|
||||
grant_id: str = Query(..., min_length=11, max_length=22),
|
||||
|
||||
# return_obj: bool = True,
|
||||
# inc_event_abstract: bool = False,
|
||||
return_obj: bool = True,
|
||||
inc_event_abstract: bool = False,
|
||||
|
||||
# commons: Common_Route_Params = Depends(common_route_params),
|
||||
# ):
|
||||
# log.setLevel(logging.INFO) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
# log.debug(locals())
|
||||
commons: Common_Route_Params = Depends(common_route_params),
|
||||
):
|
||||
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
log.debug(locals())
|
||||
|
||||
# if grant_id := redis_lookup_id_random(record_id_random=grant_id, table_name='grant'): pass
|
||||
# else: return mk_resp(data=None, status_code=404, response=commons.response, status_message='The Grant ID was invalid or not found.')
|
||||
if grant_id := redis_lookup_id_random(record_id_random=grant_id, table_name='grant'): pass
|
||||
else: return mk_resp(data=None, status_code=404, response=commons.response, status_message='The Grant ID was invalid or not found.')
|
||||
|
||||
# if update_grant_obj_result := create_update_grant_obj(
|
||||
# grant_obj = grant_obj,
|
||||
# grant_id = grant_id,
|
||||
# return_outline = False,
|
||||
# ): pass
|
||||
# else: return mk_resp(data=False, status_code=400, response=commons.response, status_message='The grant was not created. Check the field names and data types.')
|
||||
if update_grant_obj_result := create_update_grant_obj(
|
||||
grant_obj = grant_obj,
|
||||
grant_id = grant_id,
|
||||
return_outline = False,
|
||||
): pass
|
||||
else: return mk_resp(data=False, status_code=400, response=commons.response, status_message='The grant was not created. Check the field names and data types.')
|
||||
|
||||
# if update_grant_obj_result:
|
||||
# if return_obj:
|
||||
# if load_grant_obj_result := load_grant_obj(
|
||||
# grant_id = grant_id,
|
||||
# inc_event_abstract = inc_event_abstract,
|
||||
# ):
|
||||
# data = load_grant_obj_result
|
||||
# else:
|
||||
# data = False
|
||||
# else:
|
||||
# grant_id_random = get_id_random(record_id=grant_id, table_name='grant')
|
||||
# data = {}
|
||||
# data['grant_id'] = grant_id
|
||||
# data['grant_id_random'] = grant_id_random
|
||||
# return mk_resp(data=data, response=commons.response, status_message='The grant was created or updated.')
|
||||
# else:
|
||||
# return mk_resp(data=False, status_code=400, response=commons.response, status_message='The result from trying to create an grant was unexpected.')
|
||||
# # ### END ### API Grant ### patch_grant_obj() ###
|
||||
if update_grant_obj_result:
|
||||
if return_obj:
|
||||
if load_grant_obj_result := load_grant_obj(
|
||||
grant_id = grant_id,
|
||||
inc_event_abstract = inc_event_abstract,
|
||||
):
|
||||
data = load_grant_obj_result
|
||||
else:
|
||||
data = False
|
||||
else:
|
||||
grant_id_random = get_id_random(record_id=grant_id, table_name='grant')
|
||||
data = {}
|
||||
data['grant_id'] = grant_id
|
||||
data['grant_id_random'] = grant_id_random
|
||||
return mk_resp(data=data, response=commons.response, status_message='The grant was created or updated.')
|
||||
else:
|
||||
return mk_resp(data=False, status_code=400, response=commons.response, status_message='The result from trying to create an grant was unexpected.')
|
||||
# ### END ### API Grant ### patch_grant_obj() ###
|
||||
|
||||
|
||||
# ### BEGIN ### API Grant ### get_grant_obj() ###
|
||||
|
||||
Reference in New Issue
Block a user