Updates related to abstracts
This commit is contained in:
@@ -150,79 +150,69 @@ def get_grant_rec_list(
|
||||
# ### END ### API Grant Methods ### get_grant_rec_list() ###
|
||||
|
||||
|
||||
# # ### BEGIN ### API Grant Methods ### create_update_grant_obj() ###
|
||||
# # Updated 2023-03-22
|
||||
# @logger_reset
|
||||
# def create_update_grant_obj(
|
||||
# grant_obj: Grant_In,
|
||||
# grant_id: int = None,
|
||||
# event_id: int = None,
|
||||
# event_person_id: int = None,
|
||||
# ### BEGIN ### API Grant Methods ### create_update_grant_obj() ###
|
||||
# Updated 2023-06-28
|
||||
@logger_reset
|
||||
def create_update_grant_obj(
|
||||
grant_obj: Grant_In,
|
||||
grant_id: int = None,
|
||||
event_id: int = None,
|
||||
# event_person_id: int = None,
|
||||
|
||||
# create_sub_obj: bool = False,
|
||||
# fail_any: bool = False, # Fail if any thing goes wrong for sub objects
|
||||
# return_outline: bool = False,
|
||||
# ) -> int|bool:
|
||||
# log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
# log.debug(locals())
|
||||
create_sub_obj: bool = False,
|
||||
fail_any: bool = False, # Fail if any thing goes wrong for sub objects
|
||||
return_outline: bool = False,
|
||||
) -> int|bool:
|
||||
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
log.debug(locals())
|
||||
|
||||
# log.info('Checking requirements...')
|
||||
# if grant_id:
|
||||
# log.info(f'Got: grant_id={grant_id}; Update existing Grant')
|
||||
# grant_obj.id = grant_id
|
||||
# elif event_id and event_person_id:
|
||||
# log.info(f'Got: event_id={event_id}; event_person_id={event_person_id}; Create Grant')
|
||||
# grant_obj.event_id = event_id
|
||||
# grant_obj.event_person_id = event_person_id
|
||||
# else:
|
||||
# return False
|
||||
log.info('Checking requirements...')
|
||||
if grant_id:
|
||||
log.info(f'Got: grant_id={grant_id}; Update existing Grant')
|
||||
grant_obj.id = grant_id
|
||||
elif event_id:
|
||||
log.info(f'Got: event_id={event_id}; Create Grant')
|
||||
grant_obj.event_id = event_id
|
||||
else:
|
||||
return False
|
||||
|
||||
# log.debug(type(grant_obj))
|
||||
# log.debug(grant_obj
|
||||
# )
|
||||
log.debug(type(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 'topics_json' in grant_dict and (isinstance(grant_dict['topics_json'], dict) or isinstance(grant_dict['topics_json'], list)):
|
||||
# # log.debug('Need to convert to JSON string')
|
||||
# # grant_dict['topics_json'] = json.dumps(grant_dict['topics_json'])
|
||||
# # log.debug(grant_dict)
|
||||
if grant_id:
|
||||
if grant_dict_up_result := sql_update(data=grant_dict, table_name='grant', rm_id_random=True):
|
||||
log.info(f'Grant updated. 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 grant_id:
|
||||
# if grant_dict_up_result := sql_update(data=grant_dict, table_name='grant', rm_id_random=True):
|
||||
# log.info(f'Grant updated. 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_outline = {}
|
||||
grant_outline['event_id'] = event_id
|
||||
grant_outline['grant_id'] = grant_id
|
||||
|
||||
# grant_id = grant_dict_in_result # False, None, integer
|
||||
|
||||
# grant_outline = {}
|
||||
# grant_outline['event_id'] = event_id
|
||||
# grant_outline['grant_id'] = grant_id
|
||||
# grant_outline['event_person_id'] = event_person_id
|
||||
# # grant_outline['event_file_count'] = event_file_count
|
||||
|
||||
# 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() ###
|
||||
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() ###
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user