Work on event launcher and related
This commit is contained in:
@@ -159,7 +159,7 @@ app.include_router(
|
||||
)
|
||||
app.include_router(
|
||||
event_presentation.router,
|
||||
prefix='/event/presentation',
|
||||
# prefix='/event/presentation',
|
||||
tags=['Event Presentation'],
|
||||
)
|
||||
app.include_router(
|
||||
|
||||
@@ -25,6 +25,11 @@ def load_event_location_obj(
|
||||
inc_event_presentation_list: bool = False,
|
||||
inc_event_presenter_list: bool = False,
|
||||
inc_event_session_list: bool = False,
|
||||
inc_file_count: bool = False, # NOTE: file counts are from separate views
|
||||
event_file_file_purpose_id: int = None,
|
||||
event_file_file_purpose: str = None,
|
||||
event_file_priority: bool = None,
|
||||
event_file_group: str = None,
|
||||
enabled: str = 'enabled', # enabled, disabled, all
|
||||
hidden: str = 'hidden', # hidden, not_hidden, all
|
||||
limit: int = 1000,
|
||||
@@ -58,6 +63,43 @@ def load_event_location_obj(
|
||||
# if inc_event_device_list: pass
|
||||
# if inc_event_file_list: pass
|
||||
|
||||
# Updated 2021-10-21
|
||||
if inc_event_file_list:
|
||||
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
log.info('Need to include event file list...')
|
||||
|
||||
from app.methods.event_file_methods import get_event_file_rec_list, load_event_file_obj
|
||||
if event_file_rec_list_result := get_event_file_rec_list(
|
||||
for_type = 'event_location',
|
||||
for_id = event_location_id,
|
||||
file_purpose_id = event_file_file_purpose_id,
|
||||
file_purpose = event_file_file_purpose,
|
||||
priority = event_file_priority,
|
||||
group = event_file_group,
|
||||
enabled = enabled,
|
||||
limit = limit,
|
||||
):
|
||||
event_file_result_list = []
|
||||
for event_file_rec in event_file_rec_list_result:
|
||||
if load_event_file_result := load_event_file_obj(
|
||||
event_file_id = event_file_rec.get('event_file_id', None),
|
||||
enabled = enabled,
|
||||
limit = limit,
|
||||
# inc_hosted_file = inc_hosted_file,
|
||||
# model_as_dict = True,
|
||||
# by_alias = by_alias,
|
||||
# exclude_unset = False,
|
||||
):
|
||||
event_file_result_list.append(load_event_file_result)
|
||||
else:
|
||||
event_file_result_list.append(None)
|
||||
log.debug(event_file_result_list)
|
||||
event_location_obj.event_file_list = event_file_result_list
|
||||
elif isinstance(event_file_rec_list_result, list):
|
||||
event_location_obj.event_file_list = []
|
||||
else:
|
||||
event_location_obj.event_file_list = None
|
||||
|
||||
if inc_event_presentation_list:
|
||||
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
|
||||
@@ -129,7 +171,7 @@ def load_event_location_obj(
|
||||
event_session_id = event_session_rec.get('event_session_id', None),
|
||||
enabled = enabled,
|
||||
limit = limit,
|
||||
# inc_event_file_list = inc_event_file_list,
|
||||
inc_event_file_list = inc_event_file_list,
|
||||
# inc_event_presentation_list = inc_event_presentation_list,
|
||||
# inc_event_presenter_cat = inc_event_presenter_cat,
|
||||
# inc_event_presenter_list = inc_event_presenter_list,
|
||||
|
||||
@@ -27,6 +27,11 @@ def load_event_obj(
|
||||
approved: str = 'all', # approved, not_approved, all
|
||||
hidden: str = 'not_hidden', # hidden, not_hidden, all
|
||||
review: str = 'all', # ready, not_ready, all
|
||||
inc_file_count: bool = False, # NOTE: file counts are from separate views
|
||||
event_file_file_purpose_id: int = None,
|
||||
event_file_file_purpose: str = None,
|
||||
event_file_priority: bool = None,
|
||||
event_file_group: str = None,
|
||||
inc_address: bool = False, # Loads address_location and under contact(s)
|
||||
# inc_address_location: bool = False,
|
||||
inc_contact: bool = False, # Loads all 3 contacts
|
||||
@@ -168,7 +173,43 @@ def load_event_obj(
|
||||
|
||||
if inc_event_device_list: pass
|
||||
if inc_event_exhibit_list: pass
|
||||
if inc_event_file_list: pass
|
||||
|
||||
# Updated 2021-10-21
|
||||
if inc_event_file_list:
|
||||
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
log.info('Need to include event file list...')
|
||||
|
||||
from app.methods.event_file_methods import get_event_file_rec_list, load_event_file_obj
|
||||
if event_file_rec_list_result := get_event_file_rec_list(
|
||||
for_type = 'event',
|
||||
for_id = event_id,
|
||||
file_purpose_id = event_file_file_purpose_id,
|
||||
file_purpose = event_file_file_purpose,
|
||||
priority = event_file_priority,
|
||||
group = event_file_group,
|
||||
enabled = enabled,
|
||||
limit = limit,
|
||||
):
|
||||
event_file_result_list = []
|
||||
for event_file_rec in event_file_rec_list_result:
|
||||
if load_event_file_result := load_event_file_obj(
|
||||
event_file_id = event_file_rec.get('event_file_id', None),
|
||||
enabled = enabled,
|
||||
limit = limit,
|
||||
# inc_hosted_file = inc_hosted_file,
|
||||
# model_as_dict = True,
|
||||
# by_alias = by_alias,
|
||||
# exclude_unset = False,
|
||||
):
|
||||
event_file_result_list.append(load_event_file_result)
|
||||
else:
|
||||
event_file_result_list.append(None)
|
||||
log.debug(event_file_result_list)
|
||||
event_obj.event_file_list = event_file_result_list
|
||||
elif isinstance(event_file_rec_list_result, list):
|
||||
event_obj.event_file_list = []
|
||||
else:
|
||||
event_obj.event_file_list = None
|
||||
|
||||
# Updated 2021-09-29
|
||||
if inc_event_location_list:
|
||||
|
||||
@@ -189,6 +189,91 @@ def load_event_presentation_obj(
|
||||
# ### END ### API Event Presentation Methods ### load_event_presentation_obj() ###
|
||||
|
||||
|
||||
# ### BEGIN ### API Event Presenter Methods ### get_event_presentation_rec_list() ###
|
||||
def get_event_presentation_rec_list(
|
||||
event_person_id: str = None,
|
||||
event_session_id: str = None,
|
||||
enabled: str = 'enabled', # enabled, disabled, all
|
||||
approved: str = 'all', # approved, not_approved, all
|
||||
hidden: str = 'not_hidden', # hidden, not_hidden, all
|
||||
review: str = 'all', # ready, not_ready, all
|
||||
limit: int = 100,
|
||||
) -> list|bool:
|
||||
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
log.debug(locals())
|
||||
|
||||
if event_person_id := redis_lookup_id_random(record_id_random=event_person_id, table_name='event_person'): pass
|
||||
else: pass
|
||||
|
||||
if event_session_id := redis_lookup_id_random(record_id_random=event_session_id, table_name='event_session'): pass
|
||||
else: pass
|
||||
|
||||
if event_person_id or event_session_id: pass
|
||||
else: return False
|
||||
|
||||
data = {}
|
||||
data['event_person_id'] = event_person_id
|
||||
data['event_session_id'] = event_session_id
|
||||
|
||||
if event_person_id:
|
||||
sql_where_event_person_id = f'`event_presentation`.event_person_id = :event_person_id'
|
||||
else: sql_where_event_person_id = ''
|
||||
if event_session_id:
|
||||
sql_where_event_session_id = f'`event_presentation`.event_session_id = :event_session_id'
|
||||
else: sql_where_event_session_id = ''
|
||||
|
||||
if hidden in ['hidden', 'not_hidden', 'all']:
|
||||
if hidden == 'hidden':
|
||||
data['hide'] = True
|
||||
sql_hidden = f'AND `event_presentation`.hide = :hide'
|
||||
elif hidden == 'not_hidden':
|
||||
data['hide'] = False
|
||||
sql_hidden = f'AND `event_presentation`.hide = :hide'
|
||||
elif hidden == 'all':
|
||||
sql_hidden = ''
|
||||
|
||||
if enabled in ['enabled', 'disabled', 'all']:
|
||||
if enabled == 'enabled':
|
||||
data['enable'] = True
|
||||
sql_enabled = f'AND `event_presentation`.enable = :enable'
|
||||
elif enabled == 'disabled':
|
||||
data['enable'] = False
|
||||
sql_enabled = f'AND `event_presentation`.enable = :enable'
|
||||
elif enabled == 'all':
|
||||
sql_enabled = ''
|
||||
|
||||
if limit:
|
||||
data['limit'] = limit
|
||||
sql_limit = f'LIMIT :limit'
|
||||
else:
|
||||
sql_limit = ''
|
||||
|
||||
sql = f"""
|
||||
SELECT `event_presentation`.id AS 'event_presentation_id', `event_presentation`.id_random AS 'event_presentation_id_random'
|
||||
FROM `event_presentation` AS `event_presentation`
|
||||
WHERE
|
||||
{sql_where_event_person_id}
|
||||
{sql_where_event_session_id}
|
||||
{sql_hidden}
|
||||
{sql_enabled}
|
||||
ORDER BY `event_presentation`.start_datetime ASC, `event_presentation`.sort ASC, `event_presentation`.created_on DESC, `event_presentation`.updated_on DESC
|
||||
{sql_limit};
|
||||
"""
|
||||
|
||||
if event_presentation_rec_li_result := sql_select(data=data, sql=sql, as_list=True):
|
||||
|
||||
event_presentation_rec_li = event_presentation_rec_li_result
|
||||
else:
|
||||
event_presentation_rec_li = []
|
||||
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
log.debug(event_presentation_rec_li_result)
|
||||
log.debug(type(event_presentation_rec_li))
|
||||
log.debug(len(event_presentation_rec_li))
|
||||
|
||||
return event_presentation_rec_li
|
||||
# ### END ### API Event Presenter Methods ### get_event_presentation_rec_list() ###
|
||||
|
||||
|
||||
# ### BEGIN ### API Event Presentation Methods ### get_event_id_w_event_session_id() ###
|
||||
# Updated 2021-08-23
|
||||
def get_event_id_w_event_session_id(
|
||||
|
||||
@@ -9,7 +9,7 @@ from app.db_sql import *
|
||||
|
||||
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.event_presentation_methods import load_event_presentation_obj
|
||||
from app.methods.event_presentation_methods import get_event_presentation_rec_list, load_event_presentation_obj
|
||||
|
||||
from app.models.event_presentation_models import Event_Presentation_Base
|
||||
from app.models.response_models import *
|
||||
@@ -18,7 +18,7 @@ from app.models.response_models import *
|
||||
router = APIRouter()
|
||||
|
||||
|
||||
@router.post('', response_model=Resp_Body_Base)
|
||||
@router.post('/event/presentation', response_model=Resp_Body_Base)
|
||||
async def post_event_presentation_obj(
|
||||
obj: Event_Presentation_Base,
|
||||
x_account_id: str = Header(...),
|
||||
@@ -42,7 +42,7 @@ async def post_event_presentation_obj(
|
||||
return result
|
||||
|
||||
|
||||
@router.patch('/{obj_id}', response_model=Resp_Body_Base)
|
||||
@router.patch('/event/presentation/{obj_id}', response_model=Resp_Body_Base)
|
||||
async def patch_event_presentation_obj(
|
||||
obj: Event_Presentation_Base,
|
||||
obj_id: str = Query(..., min_length=1, max_length=22),
|
||||
@@ -71,7 +71,7 @@ async def patch_event_presentation_obj(
|
||||
|
||||
|
||||
# ### BEGIN ### API Event Presentation ### patch_event_presentation_json() ###
|
||||
@router.patch('/{event_presentation_id}/json', response_model=Resp_Body_Base)
|
||||
@router.patch('/event/presentation/{event_presentation_id}/json', response_model=Resp_Body_Base)
|
||||
async def patch_event_presentation_json(
|
||||
event_presentation_obj: Event_Presentation_Base,
|
||||
event_presentation_id: str = Query(..., min_length=1, max_length=22),
|
||||
@@ -112,7 +112,7 @@ async def patch_event_presentation_json(
|
||||
|
||||
# ### BEGIN ### API Event Presentation ### get_event_presentation_obj() ###
|
||||
# Working well as of 2021-06-07. Using as a template for other routes.
|
||||
@router.get('/{event_presentation_id}', response_model=Resp_Body_Base)
|
||||
@router.get('/event/presentation/{event_presentation_id}', response_model=Resp_Body_Base)
|
||||
async def get_event_presentation_obj(
|
||||
event_presentation_id: str = Query(..., min_length=1, max_length=22),
|
||||
enabled: str = 'enabled', # enabled, disabled, all; For now this covers any included objects or object lists
|
||||
@@ -179,7 +179,75 @@ async def get_event_presentation_obj(
|
||||
# ### END ### API Event Presentation ### get_event_presentation_obj() ###
|
||||
|
||||
|
||||
@router.delete('/{obj_id}', response_model=Resp_Body_Base)
|
||||
# ### BEGIN ### API Event Presentation ### get_event_session_event_presentation_li() ###
|
||||
# Updated 2021-10-20
|
||||
@router.get('/event/session/{event_session_id}/event/presentation/list', response_model=Resp_Body_Base)
|
||||
async def get_event_session_event_presentation_li(
|
||||
event_session_id: str = Query(..., min_length=11, max_length=22),
|
||||
enabled: str = 'enabled', # enabled, disabled, all
|
||||
limit: int = 50,
|
||||
# inc_address: bool = False,
|
||||
# inc_contact: bool = False,
|
||||
inc_event_file_list: bool = False,
|
||||
inc_event_presenter_list: bool = False,
|
||||
inc_event_person: bool = False, # Intended for event_presenter
|
||||
# inc_event_person_list: bool = False,
|
||||
inc_person: bool = False, # Intended for event_presenter > event_person
|
||||
review: str = 'ready', # ready, not_ready, all
|
||||
approved: str = 'approved', # approved, not_approved, all
|
||||
hidden: str = 'not_hidden', # hidden, not_hidden, all
|
||||
inc_file_count: bool = False, # NOTE: file counts are from separate views
|
||||
x_account_id: str = Header(...),
|
||||
by_alias: Optional[bool] = True,
|
||||
exclude_unset: Optional[bool] = True,
|
||||
response: Response = Response,
|
||||
):
|
||||
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
log.debug(locals())
|
||||
|
||||
if event_session_id := redis_lookup_id_random(record_id_random=event_session_id, table_name='event_session'): pass
|
||||
else: return mk_resp(data=None, status_code=404, response=response)
|
||||
|
||||
# Updated 2021-10-20
|
||||
if event_presentation_rec_list_result := get_event_presentation_rec_list(
|
||||
event_session_id = event_session_id,
|
||||
review = review, # ready, not_ready, all
|
||||
approved = approved, # approve(d), not_approved, all
|
||||
hidden = hidden, # hidden, not_hidden, all
|
||||
enabled = enabled,
|
||||
limit = limit,
|
||||
):
|
||||
event_presentation_result_list = []
|
||||
for event_presentation_rec in event_presentation_rec_list_result:
|
||||
if load_event_presentation_result := load_event_presentation_obj(
|
||||
event_presentation_id = event_presentation_rec.get('event_presentation_id', None),
|
||||
enabled = enabled,
|
||||
# review = review,
|
||||
# approved = approved,
|
||||
hidden = hidden,
|
||||
inc_file_count = inc_file_count,
|
||||
inc_event_file_list = inc_event_file_list,
|
||||
inc_event_presenter_list = inc_event_presenter_list,
|
||||
inc_person = inc_person,
|
||||
limit = limit,
|
||||
by_alias = by_alias,
|
||||
exclude_unset = exclude_unset,
|
||||
# model_as_dict = model_as_dict,
|
||||
):
|
||||
event_presentation_result_list.append(load_event_presentation_result)
|
||||
else:
|
||||
event_presentation_result_list.append(None)
|
||||
response_data = event_presentation_result_list
|
||||
elif isinstance(event_presentation_rec_list_result, list):
|
||||
return mk_resp(data=False, status_code=404, response=response) # Not Found
|
||||
else:
|
||||
return mk_resp(data=False, status_code=400, response=response) # Bad Request
|
||||
|
||||
return mk_resp(data=response_data, response=response)
|
||||
# ### END ### API Event Presentation ### get_event_session_event_presentation_li() ###
|
||||
|
||||
|
||||
@router.delete('/event/presentation/{obj_id}', response_model=Resp_Body_Base)
|
||||
async def delete_event_presentation_obj(
|
||||
obj_id: str = Query(..., min_length=1, max_length=22),
|
||||
x_account_id: str = Header(...),
|
||||
@@ -193,4 +261,4 @@ async def delete_event_presentation_obj(
|
||||
obj_type=obj_type,
|
||||
obj_id=obj_id,
|
||||
)
|
||||
return result
|
||||
return result
|
||||
|
||||
@@ -538,7 +538,7 @@ async def get_event_session_obj(
|
||||
# ### END ### API Event Session ### get_event_session_obj() ###
|
||||
|
||||
|
||||
# ### BEGIN ### API Event Session Methods ### get_event_event_session_obj_li() ###
|
||||
# ### BEGIN ### API Event Session ### get_event_event_session_obj_li() ###
|
||||
# Updated 2021-08-26
|
||||
@router.get('/event/{event_id}/session/list', response_model=Resp_Body_Base)
|
||||
async def get_event_event_session_obj_li(
|
||||
@@ -609,7 +609,7 @@ async def get_event_event_session_obj_li(
|
||||
return mk_resp(data=False, status_code=400, response=response) # Bad Request
|
||||
|
||||
return mk_resp(data=response_data, response=response)
|
||||
# ### END ### API Event Session Methods ### get_event_event_session_obj_li() ###
|
||||
# ### END ### API Event Session ### get_event_event_session_obj_li() ###
|
||||
|
||||
|
||||
# ### BEGIN ### API Event Session ### search_event_session_obj_li() ###
|
||||
|
||||
Reference in New Issue
Block a user