Code clean up. Better debugging. Work on event session, presentation, and presenter.
This commit is contained in:
@@ -22,11 +22,15 @@ from app.models.event_location_models import Event_Location_Base
|
||||
def load_event_location_obj(
|
||||
event_location_id: int|str,
|
||||
enabled: str = 'enabled', # enabled, disabled, all
|
||||
limit: int = 1000,
|
||||
inc_event_device_list: bool = False,
|
||||
inc_event_file_list: bool = False,
|
||||
inc_event_presentation_list: bool = False,
|
||||
inc_event_presenter_list: bool = False,
|
||||
inc_event_session_list: bool = False,
|
||||
limit: int = 1000,
|
||||
by_alias: bool = True,
|
||||
exclude_unset: bool = True,
|
||||
model_as_dict: bool = False,
|
||||
) -> Event_Location_Base|bool:
|
||||
log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
log.debug(locals())
|
||||
@@ -35,22 +39,19 @@ def load_event_location_obj(
|
||||
else: return False
|
||||
|
||||
if event_location_rec := sql_select(table_name='v_event_location', record_id=event_location_id): pass
|
||||
else:
|
||||
return False
|
||||
else: return False
|
||||
|
||||
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
# log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
log.debug(event_location_rec)
|
||||
|
||||
try:
|
||||
log.info('Try to apply event location record data to Event_Location_Base...')
|
||||
event_location_obj = Event_Location_Base(**event_location_rec)
|
||||
log.debug(event_location_obj)
|
||||
except ValidationError as e:
|
||||
log.error(e.json())
|
||||
return False
|
||||
|
||||
# event_location_obj = Event_Location_Base(**event_location_rec)
|
||||
# log.debug(event_location_obj)
|
||||
|
||||
#account_id = event_location_rec.get('account_id', None)
|
||||
event_id = event_location_rec.get('event_id', None)
|
||||
|
||||
@@ -116,4 +117,80 @@ def load_event_location_obj(
|
||||
|
||||
if inc_event_presenter_list: pass
|
||||
|
||||
return event_location_obj
|
||||
if model_as_dict:
|
||||
return event_location_obj.dict(by_alias=by_alias, exclude_unset=exclude_unset) # pylint: disable=no-member
|
||||
else:
|
||||
return event_location_obj
|
||||
|
||||
return event_location_obj
|
||||
|
||||
|
||||
# ### BEGIN ### API Event Location Methods ### get_event_location_rec_list() ###
|
||||
def get_event_location_rec_list(
|
||||
event_id: str,
|
||||
enabled: str = 'enabled', # enabled, disabled, all
|
||||
hidden: str = 'hidden', # hidden, not_hidden, all
|
||||
limit: int = 100,
|
||||
) -> list|bool:
|
||||
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
log.debug(locals())
|
||||
|
||||
if event_id := redis_lookup_id_random(record_id_random=event_id, table_name='event'): pass
|
||||
else: return False
|
||||
|
||||
data = {}
|
||||
data['event_id'] = event_id
|
||||
|
||||
if event_id:
|
||||
sql_where_event_id = f'`event_location`.event_id = :event_id'
|
||||
else: sql_where_event_id = ''
|
||||
|
||||
if enabled in ['enabled', 'disabled', 'all']:
|
||||
if enabled == 'enabled':
|
||||
data['enable'] = True
|
||||
sql_enabled = f'AND `event_location`.enable = :enable'
|
||||
elif enabled == 'disabled':
|
||||
data['enable'] = False
|
||||
sql_enabled = f'AND `event_location`.enable = :enable'
|
||||
elif enabled == 'all':
|
||||
sql_enabled = ''
|
||||
|
||||
if hidden in ['hidden', 'not_hidden', 'all']:
|
||||
if hidden == 'hidden':
|
||||
data['hide'] = True
|
||||
sql_hidden = f'AND `event_location`.hide = :hide'
|
||||
elif hidden == 'not_hidden':
|
||||
data['hide'] = False
|
||||
sql_hidden = f'AND `event_location`.hide = :hide'
|
||||
elif hidden == 'all':
|
||||
sql_hidden = ''
|
||||
|
||||
if limit:
|
||||
data['limit'] = limit
|
||||
sql_limit = f'LIMIT :limit'
|
||||
else:
|
||||
sql_limit = ''
|
||||
|
||||
sql = f"""
|
||||
SELECT `event_location`.id AS 'event_location_id', `event_location`.id_random AS 'event_location_id_random'
|
||||
FROM `event_location` AS `event_location`
|
||||
WHERE
|
||||
{sql_where_event_id}
|
||||
{sql_enabled}
|
||||
{sql_hidden}
|
||||
ORDER BY `event_location`.created_on DESC, `event_location`.updated_on DESC
|
||||
{sql_limit};
|
||||
"""
|
||||
|
||||
if event_location_rec_li_result := sql_select(data=data, sql=sql, as_list=True):
|
||||
|
||||
event_location_rec_li = event_location_rec_li_result
|
||||
else:
|
||||
event_location_rec_li = []
|
||||
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
log.debug(event_location_rec_li_result)
|
||||
log.debug(type(event_location_rec_li))
|
||||
log.debug(len(event_location_rec_li))
|
||||
|
||||
return event_location_rec_li
|
||||
# ### END ### API Event Location Methods ### get_event_location_rec_list() ###
|
||||
|
||||
Reference in New Issue
Block a user