Updates related to abstracts
This commit is contained in:
@@ -11,6 +11,7 @@ from app.methods.event_person_methods import load_event_person_obj
|
|||||||
|
|
||||||
from app.models.common_field_schema import default_num_bytes
|
from app.models.common_field_schema import default_num_bytes
|
||||||
from app.models.event_abstract_models import Event_Abstract_Ext, Event_Abstract_In
|
from app.models.event_abstract_models import Event_Abstract_Ext, Event_Abstract_In
|
||||||
|
from app.methods.event_cfg_methods import load_event_cfg_obj
|
||||||
|
|
||||||
|
|
||||||
# ### BEGIN ### API Event Abstract Methods ### load_event_abstract_obj() ###
|
# ### BEGIN ### API Event Abstract Methods ### load_event_abstract_obj() ###
|
||||||
@@ -24,6 +25,7 @@ def load_event_abstract_obj(
|
|||||||
hidden: str = 'not_hidden', # hidden, not_hidden, all
|
hidden: str = 'not_hidden', # hidden, not_hidden, all
|
||||||
review: str = 'all', # ready, not_ready, all
|
review: str = 'all', # ready, not_ready, all
|
||||||
|
|
||||||
|
inc_event_cfg: bool = False,
|
||||||
inc_event_file_list: bool = False,
|
inc_event_file_list: bool = False,
|
||||||
inc_event_person: bool = False,
|
inc_event_person: bool = False,
|
||||||
inc_event_person_profile: bool = False,
|
inc_event_person_profile: bool = False,
|
||||||
@@ -53,6 +55,19 @@ def load_event_abstract_obj(
|
|||||||
log.error(e.json())
|
log.error(e.json())
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
# Updated 2023-06-28
|
||||||
|
if inc_event_cfg:
|
||||||
|
log.info('Need to include event configuration...')
|
||||||
|
if event_cfg_result := load_event_cfg_obj(
|
||||||
|
event_id = event_abstract_obj.event_id,
|
||||||
|
by_alias = by_alias,
|
||||||
|
exclude_unset = exclude_unset,
|
||||||
|
model_as_dict = model_as_dict,
|
||||||
|
):
|
||||||
|
event_abstract_obj.event_cfg = event_cfg_result
|
||||||
|
else: event_abstract_obj.event_cfg = {} # None
|
||||||
|
log.debug(event_abstract_obj.event_cfg)
|
||||||
|
|
||||||
# Updated 2023-03-20
|
# Updated 2023-03-20
|
||||||
if inc_event_file_list:
|
if inc_event_file_list:
|
||||||
# log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
# log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||||
|
|||||||
@@ -150,79 +150,69 @@ def get_grant_rec_list(
|
|||||||
# ### END ### API Grant Methods ### get_grant_rec_list() ###
|
# ### END ### API Grant Methods ### get_grant_rec_list() ###
|
||||||
|
|
||||||
|
|
||||||
# # ### BEGIN ### API Grant Methods ### create_update_grant_obj() ###
|
# ### BEGIN ### API Grant Methods ### create_update_grant_obj() ###
|
||||||
# # Updated 2023-03-22
|
# Updated 2023-06-28
|
||||||
# @logger_reset
|
@logger_reset
|
||||||
# def create_update_grant_obj(
|
def create_update_grant_obj(
|
||||||
# grant_obj: Grant_In,
|
grant_obj: Grant_In,
|
||||||
# grant_id: int = None,
|
grant_id: int = None,
|
||||||
# event_id: int = None,
|
event_id: int = None,
|
||||||
# event_person_id: int = None,
|
# event_person_id: int = None,
|
||||||
|
|
||||||
# create_sub_obj: bool = False,
|
create_sub_obj: bool = False,
|
||||||
# fail_any: bool = False, # Fail if any thing goes wrong for sub objects
|
fail_any: bool = False, # Fail if any thing goes wrong for sub objects
|
||||||
# return_outline: bool = False,
|
return_outline: bool = False,
|
||||||
# ) -> int|bool:
|
) -> int|bool:
|
||||||
# log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||||
# log.debug(locals())
|
log.debug(locals())
|
||||||
|
|
||||||
# log.info('Checking requirements...')
|
log.info('Checking requirements...')
|
||||||
# if grant_id:
|
if grant_id:
|
||||||
# log.info(f'Got: grant_id={grant_id}; Update existing Grant')
|
log.info(f'Got: grant_id={grant_id}; Update existing Grant')
|
||||||
# grant_obj.id = grant_id
|
grant_obj.id = grant_id
|
||||||
# elif event_id and event_person_id:
|
elif event_id:
|
||||||
# log.info(f'Got: event_id={event_id}; event_person_id={event_person_id}; Create Grant')
|
log.info(f'Got: event_id={event_id}; Create Grant')
|
||||||
# grant_obj.event_id = event_id
|
grant_obj.event_id = event_id
|
||||||
# grant_obj.event_person_id = event_person_id
|
else:
|
||||||
# else:
|
return False
|
||||||
# return False
|
|
||||||
|
|
||||||
# log.debug(type(grant_obj))
|
log.debug(type(grant_obj))
|
||||||
# log.debug(grant_obj
|
log.debug(grant_obj
|
||||||
# )
|
)
|
||||||
|
|
||||||
# grant_dict = grant_obj.dict(by_alias=False, exclude_defaults=False, exclude_unset=True, exclude={'event_file_list', 'event_person', 'event_person_list', 'event_presenter_list', 'created_on', 'updated_on'})
|
grant_dict = grant_obj.dict(by_alias=False, exclude_defaults=False, exclude_unset=True, exclude={'event_abstract', 'event_person', 'created_on', 'updated_on'})
|
||||||
|
|
||||||
# # log.debug(type(grant_dict.get('topics_json', None)))
|
if grant_id:
|
||||||
# # if 'topics_json' in grant_dict and (isinstance(grant_dict['topics_json'], dict) or isinstance(grant_dict['topics_json'], list)):
|
if grant_dict_up_result := sql_update(data=grant_dict, table_name='grant', rm_id_random=True):
|
||||||
# # log.debug('Need to convert to JSON string')
|
log.info(f'Grant updated. grant_id={grant_id}')
|
||||||
# # grant_dict['topics_json'] = json.dumps(grant_dict['topics_json'])
|
pass
|
||||||
# # log.debug(grant_dict)
|
else:
|
||||||
|
log.warning(f'Grant not updated. grant_id={grant_id}')
|
||||||
|
log.debug(grant_dict_up_result)
|
||||||
|
return False
|
||||||
|
log.debug(grant_dict_up_result)
|
||||||
|
else:
|
||||||
|
if grant_dict_in_result := sql_insert(data=grant_dict, table_name='grant', rm_id_random=True, id_random_length=None):
|
||||||
|
log.info(f'Grant created. grant_id={grant_dict_in_result}')
|
||||||
|
else:
|
||||||
|
log.warning(f'Grant not created.')
|
||||||
|
log.debug(grant_dict_in_result)
|
||||||
|
return False
|
||||||
|
log.debug(grant_dict_in_result)
|
||||||
|
|
||||||
|
grant_id = grant_dict_in_result # False, None, integer
|
||||||
|
|
||||||
# if grant_id:
|
grant_outline = {}
|
||||||
# if grant_dict_up_result := sql_update(data=grant_dict, table_name='grant', rm_id_random=True):
|
grant_outline['event_id'] = event_id
|
||||||
# log.info(f'Grant updated. grant_id={grant_id}')
|
grant_outline['grant_id'] = grant_id
|
||||||
# pass
|
|
||||||
# else:
|
|
||||||
# log.warning(f'Grant not updated. grant_id={grant_id}')
|
|
||||||
# log.debug(grant_dict_up_result)
|
|
||||||
# return False
|
|
||||||
# log.debug(grant_dict_up_result)
|
|
||||||
# else:
|
|
||||||
# if grant_dict_in_result := sql_insert(data=grant_dict, table_name='grant', rm_id_random=True, id_random_length=None):
|
|
||||||
# log.info(f'Grant created. grant_id={grant_dict_in_result}')
|
|
||||||
# else:
|
|
||||||
# log.warning(f'Grant not created.')
|
|
||||||
# log.debug(grant_dict_in_result)
|
|
||||||
# return False
|
|
||||||
# log.debug(grant_dict_in_result)
|
|
||||||
|
|
||||||
# grant_id = grant_dict_in_result # False, None, integer
|
if return_outline:
|
||||||
|
log.debug(f'Returning the Grant Outline: {grant_outline}')
|
||||||
# grant_outline = {}
|
return grant_outline
|
||||||
# grant_outline['event_id'] = event_id
|
else:
|
||||||
# grant_outline['grant_id'] = grant_id
|
log.debug(f'Returning the Grant ID: {grant_id}')
|
||||||
# grant_outline['event_person_id'] = event_person_id
|
return grant_id
|
||||||
# # grant_outline['event_file_count'] = event_file_count
|
# ### END ### API Grant Methods ### create_update_grant_obj() ###
|
||||||
|
|
||||||
# if return_outline:
|
|
||||||
# log.debug(f'Returning the Grant Outline: {grant_outline}')
|
|
||||||
# return grant_outline
|
|
||||||
# else:
|
|
||||||
# log.debug(f'Returning the Grant ID: {grant_id}')
|
|
||||||
# return grant_id
|
|
||||||
# # ### END ### API Grant Methods ### create_update_grant_obj() ###
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ from app.models.common_field_schema import base_fields, default_num_bytes
|
|||||||
|
|
||||||
from app.models.core_object_models import Core_Std_Obj_Base
|
from app.models.core_object_models import Core_Std_Obj_Base
|
||||||
# from app.models.event_models import Event_Base
|
# from app.models.event_models import Event_Base
|
||||||
|
from app.models.event_cfg_models import Event_Cfg_Base
|
||||||
# from app.models.event_person_models import Event_Person_Base
|
# from app.models.event_person_models import Event_Person_Base
|
||||||
# from app.models.event_presentation_models import Event_Presentation_Base
|
# from app.models.event_presentation_models import Event_Presentation_Base
|
||||||
#from app.models.event_presenter_models import Event_Presenter_Base # This creates an import loop
|
#from app.models.event_presenter_models import Event_Presenter_Base # This creates an import loop
|
||||||
@@ -308,6 +309,7 @@ class Event_Abstract_Ext(Event_Abstract_Base_New):
|
|||||||
|
|
||||||
# Including other related objects
|
# Including other related objects
|
||||||
# event: Optional[Event_Base]
|
# event: Optional[Event_Base]
|
||||||
|
event_cfg: Optional[Event_Cfg_Base]
|
||||||
event_file_list: Optional[list] # Optional[Event_File_Base]
|
event_file_list: Optional[list] # Optional[Event_File_Base]
|
||||||
# from app.models.event_person_models import Event_Person_Base
|
# from app.models.event_person_models import Event_Person_Base
|
||||||
# event_person: Optional[Event_Person_Base]
|
# event_person: Optional[Event_Person_Base]
|
||||||
|
|||||||
@@ -66,6 +66,13 @@ class Event_Cfg_Base(BaseModel):
|
|||||||
default_event_file_to_public_use: Optional[bool]
|
default_event_file_to_public_use: Optional[bool]
|
||||||
ask_for_public_version: Optional[bool]
|
ask_for_public_version: Optional[bool]
|
||||||
|
|
||||||
|
mod_abstracts_json: Optional[Union[Json, None]]
|
||||||
|
# mod_badges_json: Optional[Union[Json, None]] # NOTE: Not used yet
|
||||||
|
# mod_exhibits_json: Optional[Union[Json, None]] # NOTE: Not used yet
|
||||||
|
# mod_launcher_json: Optional[Union[Json, None]] # NOTE: Not used yet
|
||||||
|
# mod_logistics_json: Optional[Union[Json, None]] # NOTE: Not used yet
|
||||||
|
# mod_pres_mgmt_json: Optional[Union[Json, None]] # NOTE: Not used yet
|
||||||
|
|
||||||
# file_approval_enabled: Optional[bool] # no longer used; use enable_event_file_approval_option 2022-08-23
|
# file_approval_enabled: Optional[bool] # no longer used; use enable_event_file_approval_option 2022-08-23
|
||||||
|
|
||||||
hide_file_upload_presentation_name: Optional[bool] # is this needed?
|
hide_file_upload_presentation_name: Optional[bool] # is this needed?
|
||||||
|
|||||||
@@ -144,6 +144,7 @@ async def patch_event_abstract_obj(
|
|||||||
async def get_event_abstract_obj(
|
async def get_event_abstract_obj(
|
||||||
event_abstract_id: str = Query(..., min_length=11, max_length=22),
|
event_abstract_id: str = Query(..., min_length=11, max_length=22),
|
||||||
|
|
||||||
|
inc_event_cfg: bool = False,
|
||||||
inc_event_file_list: bool = False,
|
inc_event_file_list: bool = False,
|
||||||
inc_event_person: bool = False,
|
inc_event_person: bool = False,
|
||||||
inc_event_person_profile: bool = True,
|
inc_event_person_profile: bool = True,
|
||||||
@@ -174,6 +175,7 @@ async def get_event_abstract_obj(
|
|||||||
hidden = hidden, # hidden, not_hidden, all
|
hidden = hidden, # hidden, not_hidden, all
|
||||||
review = review, # ready, not_ready, all
|
review = review, # ready, not_ready, all
|
||||||
|
|
||||||
|
inc_event_cfg = inc_event_cfg,
|
||||||
inc_event_file_list = inc_event_file_list,
|
inc_event_file_list = inc_event_file_list,
|
||||||
inc_event_person = inc_event_person,
|
inc_event_person = inc_event_person,
|
||||||
inc_event_person_profile = inc_event_person_profile,
|
inc_event_person_profile = inc_event_person_profile,
|
||||||
|
|||||||
@@ -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.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.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
|
from app.models.grant_models import Grant_In
|
||||||
@@ -73,49 +73,49 @@ router = APIRouter()
|
|||||||
# # ### END ### API Grant ### post_grant_obj() ###
|
# # ### END ### API Grant ### post_grant_obj() ###
|
||||||
|
|
||||||
|
|
||||||
# # ### BEGIN ### API Grant ### patch_grant_obj() ###
|
# ### BEGIN ### API Grant ### patch_grant_obj() ###
|
||||||
# # Updated 2023-03-22
|
# Updated 2023-06-28
|
||||||
# @router.patch('/grant/{grant_id}', response_model=Resp_Body_Base)
|
@router.patch('/grant/{grant_id}', response_model=Resp_Body_Base)
|
||||||
# async def patch_grant_obj(
|
async def patch_grant_obj(
|
||||||
# grant_obj: Grant_In,
|
grant_obj: Grant_In,
|
||||||
# grant_id: str = Query(..., min_length=11, max_length=22),
|
grant_id: str = Query(..., min_length=11, max_length=22),
|
||||||
|
|
||||||
# return_obj: bool = True,
|
return_obj: bool = True,
|
||||||
# inc_event_abstract: bool = False,
|
inc_event_abstract: bool = False,
|
||||||
|
|
||||||
# commons: Common_Route_Params = Depends(common_route_params),
|
commons: Common_Route_Params = Depends(common_route_params),
|
||||||
# ):
|
):
|
||||||
# log.setLevel(logging.INFO) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||||
# log.debug(locals())
|
log.debug(locals())
|
||||||
|
|
||||||
# if grant_id := redis_lookup_id_random(record_id_random=grant_id, table_name='grant'): pass
|
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.')
|
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(
|
if update_grant_obj_result := create_update_grant_obj(
|
||||||
# grant_obj = grant_obj,
|
grant_obj = grant_obj,
|
||||||
# grant_id = grant_id,
|
grant_id = grant_id,
|
||||||
# return_outline = False,
|
return_outline = False,
|
||||||
# ): pass
|
): 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.')
|
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 update_grant_obj_result:
|
||||||
# if return_obj:
|
if return_obj:
|
||||||
# if load_grant_obj_result := load_grant_obj(
|
if load_grant_obj_result := load_grant_obj(
|
||||||
# grant_id = grant_id,
|
grant_id = grant_id,
|
||||||
# inc_event_abstract = inc_event_abstract,
|
inc_event_abstract = inc_event_abstract,
|
||||||
# ):
|
):
|
||||||
# data = load_grant_obj_result
|
data = load_grant_obj_result
|
||||||
# else:
|
else:
|
||||||
# data = False
|
data = False
|
||||||
# else:
|
else:
|
||||||
# grant_id_random = get_id_random(record_id=grant_id, table_name='grant')
|
grant_id_random = get_id_random(record_id=grant_id, table_name='grant')
|
||||||
# data = {}
|
data = {}
|
||||||
# data['grant_id'] = grant_id
|
data['grant_id'] = grant_id
|
||||||
# data['grant_id_random'] = grant_id_random
|
data['grant_id_random'] = grant_id_random
|
||||||
# return mk_resp(data=data, response=commons.response, status_message='The grant was created or updated.')
|
return mk_resp(data=data, response=commons.response, status_message='The grant was created or updated.')
|
||||||
# else:
|
else:
|
||||||
# return mk_resp(data=False, status_code=400, response=commons.response, status_message='The result from trying to create an grant was unexpected.')
|
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() ###
|
# ### END ### API Grant ### patch_grant_obj() ###
|
||||||
|
|
||||||
|
|
||||||
# ### BEGIN ### API Grant ### get_grant_obj() ###
|
# ### BEGIN ### API Grant ### get_grant_obj() ###
|
||||||
|
|||||||
Reference in New Issue
Block a user