Work on event meeting list end point, methods, and models
This commit is contained in:
@@ -322,7 +322,8 @@ def get_event_rec_list(
|
||||
user_id: str = None,
|
||||
limit: int = 500,
|
||||
enabled: str = 'enabled', # enabled, disabled, all
|
||||
archived: str = 'archived', # archived, not_archived, all
|
||||
hidden: str = 'not_hidden', # hidden, not_hidden, all
|
||||
archived: str = 'not_archived', # archived, not_archived, all
|
||||
conference: bool = False, # If it is a conference then organization, person, and user are queried as participants (not the owner/organizer)
|
||||
) -> list|bool:
|
||||
log.setLevel(logging.INFO) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
@@ -362,6 +363,18 @@ def get_event_rec_list(
|
||||
else:
|
||||
sql_archived = f'AND `event`.archive = :archive'
|
||||
|
||||
if hidden in ['hidden', 'not_hidden', 'all']:
|
||||
if hidden == 'hidden':
|
||||
data['hide'] = True
|
||||
sql_hidden = f'AND `event`.hide = :hide'
|
||||
elif hidden == 'not_hidden':
|
||||
data['hide'] = False
|
||||
sql_hidden = f'AND (`event`.hide = :hide OR `event`.hide IS NULL)'
|
||||
elif hidden == 'all':
|
||||
sql_hidden = ''
|
||||
else:
|
||||
sql_hidden = f'AND `event`.hide = :hide'
|
||||
|
||||
if conference:
|
||||
data['conference'] = True
|
||||
sql_conference = f'AND `event`.conference = :conference'
|
||||
@@ -402,8 +415,9 @@ def get_event_rec_list(
|
||||
FROM `event` AS `event`
|
||||
WHERE
|
||||
{sql_where_type_id}
|
||||
{sql_enabled}
|
||||
{sql_archived}
|
||||
{sql_hidden}
|
||||
{sql_enabled}
|
||||
{sql_conference}
|
||||
ORDER BY `event`.created_on DESC, `event`.updated_on DESC
|
||||
{sql_limit};
|
||||
@@ -423,16 +437,21 @@ def get_event_rec_list(
|
||||
/*INNER JOIN `person` ON event_person.person_id = person.id*/
|
||||
INNER JOIN {sql_inner_join}
|
||||
WHERE 1=1
|
||||
{sql_enabled}
|
||||
{sql_archived}
|
||||
{sql_hidden}
|
||||
{sql_enabled}
|
||||
{sql_conference}
|
||||
ORDER BY `event`.created_on DESC, `event`.updated_on DESC
|
||||
{sql_limit};
|
||||
"""
|
||||
log.debug(sql)
|
||||
|
||||
if event_rec_li_result := sql_select(data=data, sql=sql, as_list=True):
|
||||
log.info('Got a list of events')
|
||||
log.debug(event_rec_li_result)
|
||||
event_rec_li = event_rec_li_result
|
||||
else:
|
||||
log.info('No events were found')
|
||||
event_rec_li = []
|
||||
log.debug(event_rec_li_result)
|
||||
|
||||
@@ -440,6 +459,149 @@ def get_event_rec_list(
|
||||
# ### END ### API Event Methods ### get_event_rec_list() ###
|
||||
|
||||
|
||||
# ### BEGIN ### API Event Methods ### get_event_meeting_rec_list() ###
|
||||
# Updated 2021-12-13
|
||||
def get_event_meeting_rec_list(
|
||||
account_id: str = None,
|
||||
organization_id: str = None,
|
||||
person_id: str = None,
|
||||
user_id: str = None,
|
||||
limit: int = 500,
|
||||
enabled: str = 'enabled', # enabled, disabled, all
|
||||
hidden: str = 'not_hidden', # hidden, not_hidden, all
|
||||
archived: str = 'not_archived', # archived, not_archived, all
|
||||
) -> list|bool:
|
||||
log.setLevel(logging.INFO) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
log.debug(locals())
|
||||
|
||||
if account_id or organization_id or person_id or user_id: pass
|
||||
else: return False
|
||||
|
||||
if account_id := redis_lookup_id_random(record_id_random=account_id, table_name='account'): pass
|
||||
else: pass
|
||||
|
||||
if organization_id := redis_lookup_id_random(record_id_random=organization_id, table_name='organization'): pass
|
||||
else: pass
|
||||
|
||||
if person_id := redis_lookup_id_random(record_id_random=person_id, table_name='person'): pass
|
||||
else: pass
|
||||
|
||||
if user_id := redis_lookup_id_random(record_id_random=user_id, table_name='user'): pass
|
||||
else: pass
|
||||
|
||||
data = {}
|
||||
data['account_id'] = account_id
|
||||
data['organization_id'] = organization_id
|
||||
data['person_id'] = person_id
|
||||
data['user_id'] = user_id
|
||||
# data['conference'] = conference
|
||||
|
||||
if archived in ['archived', 'not_archived', 'all']:
|
||||
if archived == 'archived':
|
||||
data['archive'] = True
|
||||
sql_archived = f'AND `event`.archive = :archive'
|
||||
elif archived == 'not_archived':
|
||||
data['archive'] = False
|
||||
sql_archived = f'AND (`event`.archive = :archive OR `event`.archive IS NULL)'
|
||||
elif archived == 'all':
|
||||
sql_archived = ''
|
||||
else:
|
||||
sql_archived = f'AND `event`.archive = :archive'
|
||||
|
||||
if hidden in ['hidden', 'not_hidden', 'all']:
|
||||
if hidden == 'hidden':
|
||||
data['hide'] = True
|
||||
sql_hidden = f'AND `event`.hide = :hide'
|
||||
elif hidden == 'not_hidden':
|
||||
data['hide'] = False
|
||||
sql_hidden = f'AND (`event`.hide = :hide OR `event`.hide IS NULL)'
|
||||
elif hidden == 'all':
|
||||
sql_hidden = ''
|
||||
else:
|
||||
sql_hidden = f'AND `event`.hide = :hide'
|
||||
|
||||
# if conference:
|
||||
# data['conference'] = True
|
||||
# sql_conference = f'AND `event`.conference = :conference'
|
||||
# else:
|
||||
# data['conference'] = False
|
||||
# sql_conference = f'AND `event`.conference = :conference'
|
||||
|
||||
if enabled in ['enabled', 'disabled', 'all']:
|
||||
if enabled == 'enabled':
|
||||
data['enable'] = True
|
||||
sql_enabled = f'AND `event`.enable = :enable'
|
||||
elif enabled == 'disabled':
|
||||
data['enable'] = False
|
||||
sql_enabled = f'AND `event`.enable = :enable'
|
||||
elif enabled == 'all':
|
||||
sql_enabled = ''
|
||||
else:
|
||||
sql_enabled = f'AND `event`.enable = :enable'
|
||||
|
||||
if limit:
|
||||
data['limit'] = limit
|
||||
sql_limit = f'LIMIT :limit'
|
||||
else:
|
||||
sql_limit = ''
|
||||
|
||||
if account_id or not conference and (organization_id or person_id or user_id):
|
||||
if account_id:
|
||||
sql_where_type_id = f'`event`.account_id = :account_id'
|
||||
elif organization_id:
|
||||
sql_where_type_id = f'`event`.organization_id = :organization_id'
|
||||
elif person_id:
|
||||
sql_where_type_id = f'`event`.person_id = :person_id'
|
||||
elif user_id:
|
||||
sql_where_type_id = f'`event`.user_id = :user_id'
|
||||
|
||||
sql = f"""
|
||||
SELECT *
|
||||
FROM `v_event` AS `event`
|
||||
WHERE
|
||||
{sql_where_type_id}
|
||||
{sql_archived}
|
||||
{sql_hidden}
|
||||
{sql_enabled}
|
||||
ORDER BY `event`.priority DESC, `event`.sort ASC, `event`.updated_on DESC, `event`.created_on DESC
|
||||
{sql_limit};
|
||||
"""
|
||||
elif conference and (organization_id or person_id or user_id): # If it is a conference then organization, person, and user are queried as participants (not the owner/organizer)
|
||||
if organization_id: # Not sure if this makes sense?
|
||||
sql_inner_join = f'`organization` ON event_person.organization_id = organization.id AND organization.id AND organization.id = :organization_id'
|
||||
elif person_id:
|
||||
sql_inner_join = f'`person` ON event_person.person_id = person.id AND person.id AND person.id = :person_id'
|
||||
elif user_id:
|
||||
sql_inner_join = f'`user` ON event_person.user_id = user.id AND user.id AND user.id = :user_id'
|
||||
|
||||
sql = f"""
|
||||
SELECT `event`.id AS 'event_id', `event`.id_random AS 'event_id_random'
|
||||
FROM `v_event` AS `event`
|
||||
INNER JOIN `event_person` ON event.id = event_person.event_id
|
||||
/*INNER JOIN `person` ON event_person.person_id = person.id*/
|
||||
INNER JOIN {sql_inner_join}
|
||||
WHERE 1=1
|
||||
{sql_archived}
|
||||
{sql_hidden}
|
||||
{sql_enabled}
|
||||
ORDER BY `event`.priority DESC, `event`.sort ASC, `event`.updated_on DESC, `event`.created_on DESC
|
||||
{sql_limit};
|
||||
"""
|
||||
log.debug(sql)
|
||||
|
||||
if event_rec_li_result := sql_select(data=data, sql=sql, as_list=True):
|
||||
log.info('Got a list of events')
|
||||
log.debug(event_rec_li_result)
|
||||
event_rec_li = event_rec_li_result
|
||||
else:
|
||||
log.info('No events were found')
|
||||
event_rec_li = []
|
||||
log.debug(event_rec_li_result)
|
||||
|
||||
return event_rec_li
|
||||
# ### END ### API Event Methods ### get_event_meeting_rec_list() ###
|
||||
|
||||
|
||||
# ### BEGIN ### API Event Methods ### load_event_obj_list() ###
|
||||
def load_event_obj_list(
|
||||
account_id: int|str|None = None,
|
||||
|
||||
Reference in New Issue
Block a user