Work on event patch and list, account list, and minor changes
This commit is contained in:
@@ -56,3 +56,71 @@ def load_event_cfg_obj(
|
||||
else:
|
||||
return event_cfg_obj
|
||||
# ### END ### API Event Cfg Methods ### load_event_cfg_obj() ###
|
||||
|
||||
|
||||
# ### BEGIN ### API Event Cfg Methods ### create_update_event_cfg_obj_v4() ###
|
||||
# Updated 2021-09-28
|
||||
def create_update_event_cfg_obj_v4(
|
||||
event_cfg_dict_obj: Event_Base|dict,
|
||||
event_cfg_id: int|str|None = None,
|
||||
event_id: int|str|None = None,
|
||||
create_sub_obj: bool = False, # Is this needed for a config?
|
||||
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 event_id := redis_lookup_id_random(record_id_random=event_id, table_name='event'): pass
|
||||
else: return False
|
||||
|
||||
log.debug(type(event_cfg_dict_obj))
|
||||
if isinstance(event_cfg_dict_obj, dict):
|
||||
event_cfg_dict = event_cfg_dict_obj
|
||||
if event_id:
|
||||
event_cfg_dict['event_id'] = event_id
|
||||
# if event_cfg_id:
|
||||
# event_cfg_dict['event_cfg_id'] = event_cfg_id
|
||||
try:
|
||||
event_cfg_obj = Event_Cfg_Base(**event_cfg_dict)
|
||||
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
log.debug(event_cfg_obj)
|
||||
except ValidationError as e:
|
||||
log.error(e.json())
|
||||
return False
|
||||
else:
|
||||
event_cfg_obj = event_cfg_dict_obj
|
||||
if event_id:
|
||||
# NOTE: Can't update the ID alias if it was never set.
|
||||
event_cfg_obj.id = event_id
|
||||
|
||||
event_cfg_dict = event_cfg_obj.dict(by_alias=False, exclude_defaults=False, exclude_unset=True, exclude={'registration_cfg', 'created_on', 'updated_on'}) # NOTE this exclude list should be reviewed again
|
||||
|
||||
if event_id:
|
||||
if event_cfg_dict_up_result := sql_update(data=event_cfg_dict, table_name='event', rm_id_random=True): pass # NOTE: This is not using the event_cfg table at this time. -STI 2021-09-28
|
||||
else:
|
||||
log.warning(f'Event (Cfg) not updated. Event ID: {event_id}')
|
||||
log.debug(event_cfg_dict_up_result)
|
||||
return False
|
||||
log.debug(event_cfg_dict_up_result)
|
||||
else: # NOTE NOTE NOTE NOTE: This section is for future use NOTE NOTE NOTE NOTE
|
||||
if event_cfg_dict_in_result := sql_insert(data=event_cfg_dict, table_name='event', rm_id_random=True, id_random_length=default_num_bytes): pass # NOTE: This is not using the event_cfg table at this time. -STI 2021-09-28
|
||||
else:
|
||||
log.warning(f'Event (Cfg) not created.')
|
||||
log.debug(event_cfg_dict_in_result)
|
||||
return False
|
||||
log.debug(event_cfg_dict_in_result)
|
||||
|
||||
event_id = event_cfg_dict_in_result
|
||||
|
||||
event_outline = {}
|
||||
event_outline['event_id'] = event_id
|
||||
|
||||
if return_outline:
|
||||
log.debug(f'Returning the Event Cfg Outline: {event_cfg_outline}')
|
||||
return event_cfg_outline
|
||||
else:
|
||||
log.debug(f'Returning the Event (Cfg) ID: {event_id}')
|
||||
return event_id
|
||||
# ### END ### API Event Cfg Methods ### create_update_event_cfg_obj_v4() ###
|
||||
|
||||
Reference in New Issue
Block a user