A lot of work on event related modules

This commit is contained in:
Scott Idem
2021-06-04 16:01:23 -04:00
parent 735e50dc0f
commit 627bc8c4df
10 changed files with 554 additions and 200 deletions

View File

@@ -11,143 +11,185 @@ from app.methods.event_session_methods import load_event_session_obj
from app.methods.person_methods import load_person_obj from app.methods.person_methods import load_person_obj
from app.methods.user_methods import load_user_obj from app.methods.user_methods import load_user_obj
from app.models.event_models import Event_Base from app.models.event_models import Event_Base, Event_Cfg_Base
# ### BEGIN ### API Event Methods ### load_event_obj() ### # ### BEGIN ### API Event Methods ### load_event_obj() ###
def load_event_obj( def load_event_obj(
event_id: int|str, event_id: int|str,
enabled: str = 'enabled', # enabled, disabled, all enabled: str = 'enabled', # enabled, disabled, all
limit: int = 1000,
inc_contact_1: bool = False,
inc_contact_2: bool = False,
inc_contact_3: bool = False,
inc_event_abstract_list: bool = False, inc_event_abstract_list: bool = False,
inc_event_badge_list: bool = False, inc_event_badge_list: bool = False,
inc_event_cfg: bool = False,
inc_event_device_list: bool = False, inc_event_device_list: bool = False,
inc_event_exhibit_list: bool = False, inc_event_exhibit_list: bool = False,
inc_event_file_list: bool = False, inc_event_file_list: bool = False,
inc_event_location: bool = False, # For event_session child object
inc_event_location_list: bool = False, inc_event_location_list: bool = False,
inc_event_person_list: bool = False, inc_event_person_list: bool = False,
inc_event_presentation_list: bool = False, inc_event_presentation_list: bool = False,
inc_event_presenter_cat: bool = False, # For event_session child object
inc_event_presenter_list: bool = False, inc_event_presenter_list: bool = False,
inc_event_registration_cfg: bool = False,
inc_event_registration_list: bool = False, inc_event_registration_list: bool = False,
inc_event_session_list: bool = False, inc_event_session_list: bool = False,
inc_event_track: bool = False, # For event_session child object
inc_event_track_list: bool = False, inc_event_track_list: bool = False,
inc_event_cfg: bool = False, inc_location_address: bool = False,
inc_event_registration_cfg: bool = False,
inc_poc_event_person: bool = False, inc_poc_event_person: bool = False,
inc_poc_person: bool = False,
inc_user: bool = False,
) -> Event_Base|bool: ) -> Event_Base|bool:
log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL #log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.debug(locals()) log.debug(locals())
if event_id := redis_lookup_id_random(record_id_random=event_id, table_name='event'): pass if event_id := redis_lookup_id_random(record_id_random=event_id, table_name='event'): pass
else: return False else: return False
if event_rec := sql_select(table_name='v_event', record_id=event_id): if event_rec := sql_select(table_name='v_event', record_id=event_id): pass
#log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.debug(event_rec)
try:
event_obj = Event_Base(**event_rec)
log.debug(event_obj)
except ValidationError as e:
log.error(e.json())
return False
account_id = event_rec.get('account_id', None)
event_id = event_rec.get('event_id', None)
poc_event_person_id = event_rec.get('poc_event_person_id', None)
poc_person_id = event_rec.get('poc_person_id', None)
user_id = event_rec.get('user_id', None)
#if inc_event: pass
if inc_event_abstract_list: pass
if inc_event_badge_list: pass
if inc_event_device_list: pass
if inc_event_exhibit_list: pass
if inc_event_file_list: pass
if inc_event_location_list: pass
if inc_event_person_list: pass
if inc_event_presentation_list: pass
if inc_event_presenter_list: pass
if inc_event_registration_list: pass
if inc_event_session_list:
#log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
data = {}
data['event_id'] = event_id
if enabled in ['enabled', 'disabled', 'all']:
if enabled == 'enabled':
data['enable'] = True
sql_enabled = f'AND `event_session`.enable = :enable'
elif enabled == 'disabled':
data['enable'] = False
sql_enabled = f'AND `event_session`.enable = :enable'
elif enabled == 'all':
sql_enabled = ''
# else: event_obj['event_session'] = None
# if limit:
# data['limit'] = limit
# sql_limit = f'LIMIT :limit'
# else:
# sql_limit = ''
sql = f"""
SELECT `event_session`.id AS 'event_session_id', `event_session`.id_random AS 'event_session_id_random'
FROM `event_session` AS `event_session`
WHERE `event_session`.event_id = :event_id
{sql_enabled}
ORDER BY `event_session`.created_on DESC, `event_session`.updated_on DESC;
"""
#log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
if event_session_obj_li_result := sql_select(data=data, sql=sql, as_list=True):
#log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.debug(event_session_obj_li_result)
event_session_obj_li = []
for event_session_obj in event_session_obj_li_result:
event_session_id = event_session_obj.get('event_session_id', None)
if event_session_obj := load_event_session_obj(
event_session_id=event_session_id,
enabled=enabled,
inc_event_abstract_list=inc_event_abstract_list,
inc_event_device_list=inc_event_device_list,
inc_event_file_list=inc_event_file_list,
inc_event_person_list=inc_event_person_list,
inc_event_presentation_list=inc_event_presentation_list,
inc_event_presenter_list=inc_event_presenter_list,
#inc_event_track=inc_event_track,
):
data = event_session_obj.dict(by_alias=True, exclude_unset=True)
event_session_obj_li.append(data)
log.debug(event_session_obj_li)
#event_rec['event_session_list'] = event_session_obj_li
event_obj.event_session_list = event_session_obj_li
else:
#log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.debug(event_session_obj_li_result)
#log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
if inc_event_track_list: pass
if inc_event_cfg: pass
if inc_event_registration_cfg: pass
if inc_poc_event_person: pass
if inc_poc_person:
person_obj = load_person_obj(person_id=poc_person_id)
log.debug(person_obj)
#event_rec['poc_person'] = person_obj
#log.debug(event_rec)
event_obj.poc_person = person_obj
log.debug(event_obj)
if inc_user:
user_obj = load_user_obj(user_id=user_id)
log.debug(user_obj)
#event_rec['user'] = user_obj
#log.debug(event_rec)
event_obj.user = user_obj
log.debug(event_obj)
else: else:
return False return False
return event_obj #log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.debug(event_rec)
try:
event_obj = Event_Base(**event_rec)
log.debug(event_obj)
except ValidationError as e:
log.error(e.json())
return False
account_id = event_rec.get('account_id', None)
poc_event_person_id = event_rec.get('poc_event_person_id', None)
poc_person_id = event_rec.get('poc_person_id', None)
user_id = event_rec.get('user_id', None)
#if inc_event: pass
if inc_event_abstract_list: pass
if inc_event_badge_list: pass
if inc_event_cfg: # and event_cfg_id ???
#log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.debug(event_id)
if event_cfg_obj := load_event_cfg_obj(
event_id=event_id, # event_cfg_id ???
):
event_obj.event_cfg = event_cfg_obj.dict(by_alias=True, exclude_unset=True)
else:
event_obj.event_cfg = None
if inc_event_device_list: pass
if inc_event_exhibit_list: pass
if inc_event_file_list: pass
if inc_event_location_list: pass
if inc_event_person_list: pass
if inc_event_presentation_list: pass
if inc_event_presenter_list: pass
if inc_event_registration_cfg: pass
if inc_event_registration_list: pass
if inc_event_session_list:
#log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
data = {}
data['event_id'] = event_id
if enabled in ['enabled', 'disabled', 'all']:
if enabled == 'enabled':
data['enable'] = True
sql_enabled = f'AND `event_session`.enable = :enable'
elif enabled == 'disabled':
data['enable'] = False
sql_enabled = f'AND `event_session`.enable = :enable'
elif enabled == 'all':
sql_enabled = ''
else:
sql_enabled = f'AND `event_session`.enable = :enable'
# else: event_obj['event_session'] = None
if limit:
data['limit'] = limit
sql_limit = f'LIMIT :limit'
else:
sql_limit = ''
sql = f"""
SELECT `event_session`.id AS 'event_session_id', `event_session`.id_random AS 'event_session_id_random'
FROM `event_session` AS `event_session`
WHERE `event_session`.event_id = :event_id
{sql_enabled}
ORDER BY `event_session`.created_on DESC, `event_session`.updated_on DESC
{sql_limit};
"""
#log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
if event_session_obj_li_result := sql_select(data=data, sql=sql, as_list=True):
#log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.debug(event_session_obj_li_result)
event_session_obj_li = []
for event_session_obj in event_session_obj_li_result:
event_session_id = event_session_obj.get('event_session_id', None)
if event_session_obj := load_event_session_obj(
event_session_id=event_session_id,
enabled=enabled,
inc_event_abstract_list=inc_event_abstract_list,
inc_event_device_list=inc_event_device_list,
inc_event_file_list=inc_event_file_list,
inc_event_location=inc_event_location,
inc_event_person_list=inc_event_person_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,
#inc_event_track=inc_event_track,
):
data = event_session_obj.dict(by_alias=True, exclude_unset=True)
event_session_obj_li.append(data)
log.debug(event_session_obj_li)
#event_rec['event_session_list'] = event_session_obj_li
event_obj.event_session_list = event_session_obj_li
else:
#log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.debug(event_session_obj_li_result)
#log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
if inc_event_track_list: pass
if inc_poc_event_person:
poc_event_person_obj = load_person_obj(person_id=poc_event_person_id)
log.debug(poc_event_person_obj)
#event_rec['poc_event_person'] = poc_event_person_obj
#log.debug(event_rec)
event_obj.poc_event_person = poc_event_person_obj
log.debug(event_obj)
return event_obj
# ### END ### API Event Methods ### load_event_obj() ###
# ### BEGIN ### API Event Methods ### load_event_cfg_obj() ###
def load_event_cfg_obj(
event_id: int|str,
) -> Event_Cfg_Base|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
if event_cfg_rec := sql_select(table_name='v_event_cfg', record_id=event_id):
#log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.debug(event_cfg_rec)
try:
event_cfg_obj = Event_Cfg_Base(**event_cfg_rec)
log.debug(event_cfg_obj)
except ValidationError as e:
log.error(e.json())
return False
else: return False
return event_cfg_obj
# ### END ### API Event Methods ### load_event_cfg_obj() ###

View File

@@ -7,6 +7,15 @@ from pydantic import BaseModel, EmailStr, Field, PrivateAttr, ValidationError, v
from app.db_sql import redis_lookup_id_random, sql_insert, sql_select, sql_update from app.db_sql import redis_lookup_id_random, sql_insert, sql_select, sql_update
from app.lib_general import log, logging from app.lib_general import log, logging
# from app.methods.event_abstract_methods import load_event_abstract_obj
# from app.methods.event_badge_methods import load_event_badge_obj
# from app.methods.event_exhibit_methods import load_event_exhibit_obj
# from app.methods.event_file_methods import load_event_file_obj
from app.methods.event_presentation_methods import load_event_presentation_obj
from app.methods.event_presenter_methods import load_event_presenter_obj
# from app.methods.event_registration_methods import load_event_registration_obj
from app.methods.event_session_methods import load_event_session_obj
# from app.methods.event_track_methods import load_event_track_obj
from app.methods.person_methods import load_person_obj from app.methods.person_methods import load_person_obj
from app.methods.user_methods import load_user_obj from app.methods.user_methods import load_user_obj
@@ -40,13 +49,19 @@ def create_event_person_obj(event_person_obj_new:Event_Person_Base) -> int|bool:
# ### BEGIN ### API Event Person Methods ### load_event_person_obj() ### # ### BEGIN ### API Event Person Methods ### load_event_person_obj() ###
def load_event_person_obj( def load_event_person_obj(
event_person_id:int|str, event_person_id: int|str,
inc_event:bool=False, inc_event_abstract_list: bool = False,
inc_event_badge:bool=False, inc_event_badge: bool = False,
inc_event_person_detail:bool=False, inc_event_exhibit_list: bool = False,
inc_event_registration:bool=False, inc_event_file_list: bool = False,
inc_person:bool=False, #inc_event_person_detail: bool = False, # Should this be done differently?
inc_user:bool=False inc_event_presentation_list: bool = False,
inc_event_presenter_list: bool = False,
inc_event_registration: bool = False,
inc_event_session_list: bool = False,
inc_event_track_list: bool = False,
inc_person: bool = False,
inc_user: bool = False,
) -> Event_Person_Base|bool: ) -> Event_Person_Base|bool:
log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.debug(locals()) log.debug(locals())
@@ -54,35 +69,13 @@ def load_event_person_obj(
if event_person_id := redis_lookup_id_random(record_id_random=event_person_id, table_name='event_person'): pass if event_person_id := redis_lookup_id_random(record_id_random=event_person_id, table_name='event_person'): pass
else: return False else: return False
if event_person_rec := sql_select(table_name='v_event_person', record_id=event_person_id): if event_person_rec := sql_select(table_name='v_event_person', record_id=event_person_id): pass
#log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.debug(event_person_rec)
person_id = event_person_rec.get('person_id', None)
user_id = event_person_rec.get('user_id', None)
# event_person_obj = Event_Person_Base(**event_person_rec)
# person_id = event_person_obj.person_id
# user_id = event_person_obj.user_id
if inc_event: pass
if inc_event_badge: pass
if inc_event_person_detail: pass
if inc_event_registration: pass
if inc_person:
person_obj = load_person_obj(person_id=person_id)
log.debug(person_obj)
event_person_rec['person'] = person_obj
log.debug(event_person_rec)
if inc_user:
user_obj = load_user_obj(user_id=user_id)
log.debug(user_obj)
event_person_rec['user'] = user_obj
log.debug(event_person_rec)
else: else:
return False return False
#log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.debug(event_person_rec)
try: try:
event_person_obj = Event_Person_Base(**event_person_rec) event_person_obj = Event_Person_Base(**event_person_rec)
log.debug(event_person_obj) log.debug(event_person_obj)
@@ -90,4 +83,35 @@ def load_event_person_obj(
log.error(e.json()) log.error(e.json())
return False return False
return event_person_obj person_id = event_person_rec.get('person_id', None)
user_id = event_person_rec.get('user_id', None)
# event_person_obj = Event_Person_Base(**event_person_rec)
# person_id = event_person_obj.person_id
# user_id = event_person_obj.user_id
if inc_event_abstract_list: pass
if inc_event_badge: pass
if inc_event_exhibit_list: pass
if inc_event_file_list: pass
#if inc_event_person_detail: pass
if inc_event_presentation_list: pass
if inc_event_presenter_list: pass
if inc_event_registration: pass
if inc_event_session_list: pass
if inc_event_track_list: pass
if inc_person:
person_obj = load_person_obj(person_id=person_id)
log.debug(person_obj)
event_person_rec['person'] = person_obj
log.debug(event_person_rec)
if inc_user:
user_obj = load_user_obj(user_id=user_id)
log.debug(user_obj)
event_person_rec['user'] = user_obj
log.debug(event_person_rec)
return event_person_obj
# ### END ### API Event Person Methods ### load_event_person_obj() ###

View File

@@ -29,12 +29,13 @@ def load_event_session_obj(
inc_event_location: bool = False, inc_event_location: bool = False,
inc_event_person_list: bool = False, inc_event_person_list: bool = False,
inc_event_presentation_list: bool = False, inc_event_presentation_list: bool = False,
inc_event_presenter_cat: bool = False, # Concantinate presenter names
inc_event_presenter_list: bool = False, inc_event_presenter_list: bool = False,
inc_event_registration_list: bool = False, inc_event_registration_list: bool = False,
inc_event_track: bool = False, inc_event_track: bool = False,
inc_poc_event_person: bool = False, inc_poc_event_person: bool = False,
inc_poc_person: bool = False, inc_poc_person: bool = False,
inc_user: bool = False, # inc_user: bool = False,
) -> Event_Session_Base|bool: ) -> Event_Session_Base|bool:
log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.debug(locals()) log.debug(locals())
@@ -46,7 +47,7 @@ def load_event_session_obj(
else: else:
return False 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_session_rec) log.debug(event_session_rec)
try: try:
@@ -56,9 +57,6 @@ def load_event_session_obj(
log.error(e.json()) log.error(e.json())
return False return False
# event_session_obj = Event_Session_Base(**event_session_rec)
# log.debug(event_session_obj)
account_id = event_session_rec.get('account_id', None) account_id = event_session_rec.get('account_id', None)
event_id = event_session_rec.get('event_id', None) event_id = event_session_rec.get('event_id', None)
event_location_id = event_session_rec.get('event_location_id', None) event_location_id = event_session_rec.get('event_location_id', None)
@@ -80,10 +78,11 @@ def load_event_session_obj(
event_session_obj.event_location = event_location_obj.dict(by_alias=True, exclude_unset=True) event_session_obj.event_location = event_location_obj.dict(by_alias=True, exclude_unset=True)
else: else:
event_session_obj.event_location = None event_session_obj.event_location = None
else:
event_session_obj.event_location = None
if inc_event_person_list: pass if inc_event_person_list: pass
if inc_event_presentation_list: if inc_event_presentation_list:
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
@@ -115,9 +114,9 @@ def load_event_session_obj(
ORDER BY `event_presentation`.created_on DESC, `event_presentation`.updated_on DESC; ORDER BY `event_presentation`.created_on DESC, `event_presentation`.updated_on DESC;
""" """
log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL #log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
if event_presentation_rec_li_result := sql_select(data=data, sql=sql, as_list=True): if event_presentation_rec_li_result := sql_select(data=data, sql=sql, as_list=True):
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL #log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.debug(event_presentation_rec_li_result) log.debug(event_presentation_rec_li_result)
event_presentation_obj_li = [] event_presentation_obj_li = []
for event_presentation_rec in event_presentation_rec_li_result: for event_presentation_rec in event_presentation_rec_li_result:
@@ -140,15 +139,32 @@ def load_event_session_obj(
log.debug(event_presentation_rec_li_result) log.debug(event_presentation_rec_li_result)
log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
if inc_event_presenter_cat:
data = {}
data['event_session_id'] = event_session_id
sql = f"""
SELECT event_session_id, GROUP_CONCAT(given_name, ' ', family_name SEPARATOR '; ') AS 'event_presenter_names'
FROM event_presenter
WHERE event_session_id = :event_session_id
GROUP BY event_session_id
LIMIT 1
"""
if event_presenter_cat_rec_result := sql_select(data=data, sql=sql):
event_session_obj.event_presenter_cat = event_presenter_cat_rec_result.get('event_presenter_names', None)
else:
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.debug(event_presenter_cat_rec_result)
event_session_obj.event_presenter_cat = None
if inc_event_presenter_list: pass if inc_event_presenter_list: pass
if inc_poc_event_person: pass
if inc_poc_person: if inc_poc_event_person:
person_obj = load_person_obj(person_id=poc_person_id) poc_event_person_obj = load_person_obj(person_id=poc_person_id)
log.debug(person_obj) log.debug(poc_event_person_obj)
event_session_obj.poc_person = person_obj event_session_obj.poc_event_person = poc_event_person_obj
log.debug(event_session_obj) log.debug(event_session_obj)
#if inc_user: pass #if inc_user: pass
return event_session_obj return event_session_obj

View File

@@ -32,6 +32,7 @@ base_fields['event_file_id_random'] = xxx_id_random_field_schema
base_fields['event_id_random'] = xxx_id_random_field_schema base_fields['event_id_random'] = xxx_id_random_field_schema
base_fields['event_abstract_id_random'] = xxx_id_random_field_schema base_fields['event_abstract_id_random'] = xxx_id_random_field_schema
base_fields['event_badge_id_random'] = xxx_id_random_field_schema base_fields['event_badge_id_random'] = xxx_id_random_field_schema
base_fields['event_cfg_id_random'] = xxx_id_random_field_schema # Not really ready yet
base_fields['event_device_id_random'] = xxx_id_random_field_schema base_fields['event_device_id_random'] = xxx_id_random_field_schema
base_fields['event_location_id_random'] = xxx_id_random_field_schema base_fields['event_location_id_random'] = xxx_id_random_field_schema
base_fields['event_person_id_random'] = xxx_id_random_field_schema base_fields['event_person_id_random'] = xxx_id_random_field_schema

View File

@@ -106,9 +106,11 @@ class Event_Base(BaseModel):
contact_2: Optional[Contact_Base] contact_2: Optional[Contact_Base]
contact_3: Optional[Contact_Base] contact_3: Optional[Contact_Base]
event_abstract_list: Optional[list] # Optional[Event_Abstract_Base] event_abstract_list: Optional[list] # Optional[Event_Abstract_Base]
event_cfg: Optional[Event_Cfg_Base]
event_device_list: Optional[list] # Optional[Event_Device_Base] event_device_list: Optional[list] # Optional[Event_Device_Base]
event_file_list: Optional[list] # Optional[Event_File_Base] event_file_list: Optional[list] # Optional[Event_File_Base]
event_location_list: Optional[list] # Optional[Event_Location_Base] event_location_list: Optional[list] # Optional[Event_Location_Base]
event_person_list: Optional[list]
event_presentation_list: Optional[list] # Optional[Event_Presentation_Base] event_presentation_list: Optional[list] # Optional[Event_Presentation_Base]
event_presenter_list: Optional[list] # Optional[Event_Presenter_Base] event_presenter_list: Optional[list] # Optional[Event_Presenter_Base]
event_session_list: Optional[list] # Optional[Event_Session_Base] event_session_list: Optional[list] # Optional[Event_Session_Base]
@@ -179,4 +181,102 @@ class Event_Base(BaseModel):
underscore_attrs_are_private = True underscore_attrs_are_private = True
fields = base_fields fields = base_fields
Event_Base.update_forward_refs()
class Event_Cfg_Base(BaseModel):
log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.debug(locals())
# id_random: Optional[str] = Field(
# **base_fields['event_cfg_id_random'],
# alias='event_cfg_id_random',
# default_factory=lambda:secrets.token_urlsafe(default_num_bytes),
# )
# id: Optional[int] = Field(
# #alias='event_cfg_id'
# )
enable: Optional[bool]
enable_from: Optional[datetime.datetime]
enable_to: Optional[datetime.datetime]
enable_comments: Optional[bool]
disable_navigation: Optional[bool]
enable_event_file_upload_for_event: Optional[bool]
enable_event_file_upload_for_location: Optional[bool]
enable_event_file_upload_for_presentation: Optional[bool]
enable_event_file_upload_for_presenter: Optional[bool]
enable_event_file_upload_for_session: Optional[bool]
enable_event_file_upload_for_track: Optional[bool]
# enable_event_file_upload_for_event_track: Optional[bool] # Change to this pattern in the future?
# enable_file_upload_for_track: Optional[bool] # Change to this pattern in the future?
enable_event_file_upload_review_question: Optional[bool]
enable_event_file_upload_email_question: Optional[bool]
enable_event_file_upload_comments_question: Optional[bool]
enable_event_file_approval_option: Optional[bool]
enable_event_file_public_use_option: Optional[bool]
enable_event_file_member_use_option: Optional[bool]
enable_event_file_attendee_use_option: Optional[bool]
enable_event_file_publish_option: Optional[bool]
enable_event_file_purpose_option: Optional[bool]
enable_event_file_os_selection_option: Optional[bool]
enable_event_file_os_change_option: Optional[bool]
custom_event_file_upload_description: Optional[str]
custom_event_file_agreement_1_text: Optional[str]
custom_event_file_agreement_1_description: Optional[str]
ask_speaker_ready_room: Optional[bool]
ask_presentation_publish_optout: Optional[bool]
default_event_file_to_public_use: Optional[bool]
ask_for_public_version: Optional[bool]
file_approval_enabled: Optional[bool]
hide_file_upload_presentation_name: Optional[bool]
hide_file_upload_review_input: Optional[bool]
hide_file_upload_email_input: Optional[bool]
hide_file_upload_comments_input: Optional[bool]
hide_session_codes: Optional[bool]
unauthenticated_access: Optional[bool]
unauthenticated_access_public_endpoint: Optional[bool]
hide: Optional[bool]
status: Optional[int]
review: Optional[bool]
approve: Optional[bool]
ready: Optional[bool]
ready_on: Optional[datetime.datetime]
archive: Optional[bool]
archive_on: Optional[datetime.datetime]
priority: Optional[bool]
sort: Optional[int]
group: Optional[str]
notes: Optional[str]
_processed_at: datetime.datetime = PrivateAttr(default_factory=datetime.datetime.now)
#@validator('event_cfg_id_random', always=True)
# def event_cfg_id_random_copy(cls, v, values, **kwargs):
# log.setLevel(logging.WARNING)
# log.debug(locals())
# if values['id_random']:
# return values['id_random']
# return None
# @validator('id', always=True)
# def event_cfg_id_lookup(cls, v, values, **kwargs):
# log.setLevel(logging.WARNING)
# log.debug(locals())
# if values['id_random']:
# log.debug(values['id_random'])
# return redis_lookup_id_random(record_id_random=values['id_random'], table_name='event')
# return None
Event_Base.update_forward_refs() # NOTE: This is needed since Event_Cfg_Base is below Event_Base.

View File

@@ -11,7 +11,7 @@ from .common_field_schema import base_fields, default_num_bytes
#from .event_models import Event_Base #from .event_models import Event_Base
from .event_badge_models import Event_Badge_Base from .event_badge_models import Event_Badge_Base
from .event_person_detail_models import Event_Person_Detail_Base #from .event_person_detail_models import Event_Person_Detail_Base
from .event_registration_models import Event_Registration_Base from .event_registration_models import Event_Registration_Base
from .person_models import Person_Base from .person_models import Person_Base
from .user_models import User_Base, User_Out_Base from .user_models import User_Base, User_Out_Base
@@ -33,10 +33,10 @@ class Event_Person_Base(BaseModel):
account_id: Optional[int] account_id: Optional[int]
event_id_random: Optional[str] event_id_random: Optional[str]
event_id: Optional[int] event_id: Optional[int]
event_registration_id_random: Optional[str]
event_registration_id: Optional[int]
event_badge_id_random: Optional[str] event_badge_id_random: Optional[str]
event_badge_id: Optional[int] event_badge_id: Optional[int]
event_registration_id_random: Optional[str]
event_registration_id: Optional[int]
person_id_random: Optional[str] person_id_random: Optional[str]
person_id: Optional[int] person_id: Optional[int]
user_id_random: Optional[str] user_id_random: Optional[str]
@@ -51,18 +51,17 @@ class Event_Person_Base(BaseModel):
updated_on: Optional[datetime.datetime] = None updated_on: Optional[datetime.datetime] = None
# Including other related objects # Including other related objects
#event: Optional[Event_Base] event_abstract_list: Optional[list] # Use event_person_detail table. An event_person record can be linked to one or more abstracts
event_abstract: Optional[list] # Use event_person_detail table. An event_person record can be linked to one or more abstracts
event_badge: Optional[Event_Badge_Base] event_badge: Optional[Event_Badge_Base]
event_exhibit: Optional[list] # Use event_person_detail table. An event_person record can be linked to one or more exhibits event_exhibit_list: Optional[list] # Use event_person_detail table. An event_person record can be linked to one or more exhibits
event_file: Optional[list] # Use event_person_detail table. An event_person record can be linked to one or more files event_file_list: Optional[list] # Use event_person_detail table. An event_person record can be linked to one or more files
event_location: Optional[list] # Use event_person_detail table. An event_person record can be linked to one or more locations (but unlikely?) event_location_list: Optional[list] # Use event_person_detail table. An event_person record can be linked to one or more locations (but unlikely?)
event_presentation: Optional[list] # Use event_person_detail table. An event_person record can be linked to one or more presentations #event_person_detail_list: Optional[list] # list of Event_Person_Detail
event_presenter: Optional[list] # Use event_person_detail table. An event_person record can be linked to one or more presenters (part of multiple presentations) event_presentation_list: Optional[list] # Use event_person_detail table. An event_person record can be linked to one or more presentations
event_presenter_list: Optional[list] # Use event_person_detail table. An event_person record can be linked to one or more presenters (part of multiple presentations)
event_registration: Optional[Event_Registration_Base]
event_session: Optional[list] # Use event_person_detail table. An event_person record can be linked to one or more sessions event_session: Optional[list] # Use event_person_detail table. An event_person record can be linked to one or more sessions
event_track: Optional[list] # Use event_person_detail table. An event_person record can be linked to one or more tracks event_track: Optional[list] # Use event_person_detail table. An event_person record can be linked to one or more tracks
#event_person_detail_list: Optional[list] # list of Event_Person_Detail
event_registration: Optional[Event_Registration_Base]
person: Optional[Person_Base] person: Optional[Person_Base]
user: Optional[User_Base] user: Optional[User_Base]
@@ -105,15 +104,6 @@ class Event_Person_Base(BaseModel):
return redis_lookup_id_random(record_id_random=values['event_id_random'], table_name='event') return redis_lookup_id_random(record_id_random=values['event_id_random'], table_name='event')
return None return None
@validator('event_registration_id', always=True)
def event_registration_id_lookup(cls, v, values, **kwargs):
log.setLevel(logging.WARNING)
log.debug(locals())
if values['event_registration_id_random']:
return redis_lookup_id_random(record_id_random=values['event_registration_id_random'], table_name='event_registration')
return None
@validator('event_badge_id', always=True) @validator('event_badge_id', always=True)
def event_badge_id_lookup(cls, v, values, **kwargs): def event_badge_id_lookup(cls, v, values, **kwargs):
log.setLevel(logging.WARNING) log.setLevel(logging.WARNING)
@@ -123,6 +113,15 @@ class Event_Person_Base(BaseModel):
return redis_lookup_id_random(record_id_random=values['event_badge_id_random'], table_name='event_badge') return redis_lookup_id_random(record_id_random=values['event_badge_id_random'], table_name='event_badge')
return None return None
@validator('event_registration_id', always=True)
def event_registration_id_lookup(cls, v, values, **kwargs):
log.setLevel(logging.WARNING)
log.debug(locals())
if values['event_registration_id_random']:
return redis_lookup_id_random(record_id_random=values['event_registration_id_random'], table_name='event_registration')
return None
@validator('person_id', always=True) @validator('person_id', always=True)
def person_id_lookup(cls, v, values, **kwargs): def person_id_lookup(cls, v, values, **kwargs):
log.setLevel(logging.WARNING) log.setLevel(logging.WARNING)

View File

@@ -11,7 +11,7 @@ from .common_field_schema import base_fields, default_num_bytes
#from .event_models import Event_Base #from .event_models import Event_Base
from .event_location_models import Event_Location_Base from .event_location_models import Event_Location_Base
#from .event_person_models import Event_Person_Base #from .event_person_models import Event_Person_Base # NOTE: Using thi will probably create an import loop
from .event_track_models import Event_Track_Base from .event_track_models import Event_Track_Base
from .person_models import Person_Base from .person_models import Person_Base
@@ -89,15 +89,16 @@ class Event_Session_Base(BaseModel):
# Including other related objects # Including other related objects
#event: Optional[Event_Base] #event: Optional[Event_Base]
event_abstract_list: Optional[list] # Optional[Event_Abstract_Base] event_abstract_list: Optional[list] # Optional[Event_Abstract_Base]
event_badge_list: Optional[list] # Optional[Event_Abstract_Base]
event_device_list: Optional[list] # Optional[Event_Device_Base] event_device_list: Optional[list] # Optional[Event_Device_Base]
event_file_list: Optional[list] # Optional[Event_File_Base] event_file_list: Optional[list] # Optional[Event_File_Base]
event_location: Optional[Event_Location_Base] event_location: Optional[Union[Event_Location_Base, None]]
event_person_list: Optional[list]
event_presenter_cat: Optional[Union[str, None]]
event_presentation_list: Optional[list] # Optional[Event_Presentation_Base] event_presentation_list: Optional[list] # Optional[Event_Presentation_Base]
event_presenter_list: Optional[list] # Optional[Event_Presenter_Base] event_presenter_list: Optional[list] # Optional[Event_Presenter_Base]
event_track: Optional[Event_Track_Base] event_track: Optional[Event_Track_Base]
#poc_event_person: Optional[Event_Person_Base] # NOTE: Using thi will probably create an import loop
#poc_event_person: Optional[Event_Person_Base]
poc_person: Optional[Person_Base]
_processed_at: datetime.datetime = PrivateAttr(default_factory=datetime.datetime.now) _processed_at: datetime.datetime = PrivateAttr(default_factory=datetime.datetime.now)

View File

@@ -211,24 +211,80 @@ async def get_event_obj_li(
return mk_resp(data=False, status_code=404) return mk_resp(data=False, status_code=404)
@router.get('/{obj_id}', response_model=Resp_Body_Base) # ### BEGIN ### API Event ### get_event_obj() ###
# Working well as of 2021-06-04. Using as a template for other routes.
@router.get('/{event_id}', response_model=Resp_Body_Base)
async def get_event_obj( async def get_event_obj(
obj_id: str = Query(..., min_length=1, max_length=22), event_id: str = Query(..., min_length=1, max_length=22),
enabled: str = 'enabled', # For now this covers any included objects or object lists
limit: int = 500, # For now this covers any included objects or object lists
inc_contact_1: bool = False,
inc_contact_2: bool = False,
inc_contact_3: bool = False,
inc_event_abstract_list: bool = False,
inc_event_badge_list: bool = False,
inc_event_device_list: bool = False,
inc_event_exhibit_list: bool = False,
inc_event_file_list: bool = False,
inc_event_location: bool = False,
inc_event_location_list: bool = False,
inc_event_person_list: bool = False,
inc_event_presentation_list: bool = False,
inc_event_presenter_cat: bool = False,
inc_event_presenter_list: bool = False,
inc_event_registration_list: bool = False,
inc_event_session_list: bool = False,
inc_event_track: bool = False,
inc_event_track_list: bool = False,
inc_event_cfg: bool = False,
inc_event_registration_cfg: bool = False,
inc_location_address: bool = False,
inc_poc_event_person: bool = False,
x_account_id: str = Header(...), x_account_id: str = Header(...),
by_alias: Optional[bool] = True, by_alias: Optional[bool] = True,
exclude_unset: Optional[bool] = True, exclude_unset: Optional[bool] = True,
): ):
log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.debug(locals()) log.debug(locals())
obj_type = 'event' if event_id := redis_lookup_id_random(record_id_random=event_id, table_name='event'): pass
result = get_obj_template( else:
obj_type=obj_type, return mk_resp(data=None, status_code=404)
obj_id=obj_id,
by_alias=True, if event_obj := load_event_obj(
exclude_unset=True, event_id=event_id,
) enabled=enabled,
return result limit=limit,
inc_contact_1=inc_contact_1,
inc_contact_2=inc_contact_2,
inc_contact_3=inc_contact_3,
inc_event_abstract_list=inc_event_abstract_list,
inc_event_badge_list=inc_event_badge_list,
inc_event_device_list=inc_event_device_list,
inc_event_exhibit_list=inc_event_exhibit_list,
inc_event_file_list=inc_event_file_list,
inc_event_location=inc_event_location,
inc_event_location_list=inc_event_location_list,
inc_event_person_list=inc_event_person_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,
inc_event_registration_list=inc_event_registration_list,
inc_event_session_list=inc_event_session_list,
inc_event_track=inc_event_track,
inc_event_track_list=inc_event_track_list,
inc_event_cfg=inc_event_cfg,
inc_event_registration_cfg=inc_event_registration_cfg,
inc_location_address=inc_location_address,
inc_poc_event_person=inc_poc_event_person,
):
# event_dict = event_obj.dict(by_alias=by_alias, exclude_unset=exclude_unset)
pass
else:
return mk_resp(data=False, status_code=400) # Bad Request
return mk_resp(data=event_obj)
# ### END ### API Event ### get_event_obj() ###
@router.delete('/{obj_id}', response_model=Resp_Body_Base) @router.delete('/{obj_id}', response_model=Resp_Body_Base)

View File

@@ -158,4 +158,63 @@ async def post_event_person_new(
return mk_resp(data=False) return mk_resp(data=False)
log.debug(event_person_obj) log.debug(event_person_obj)
return mk_resp(data=event_person_obj) return mk_resp(data=event_person_obj)
# ### BEGIN ### API Event Person ### get_event_person_obj() ###
# Working well as of 2021-06-04. Using as a template for other routes.
@router.get('/{event_person_id}', response_model=Resp_Body_Base)
async def get_event_person_obj(
event_person_id: str = Query(..., min_length=1, max_length=22),
enabled: str = 'enabled', # For now this covers any included objects or object lists
limit: int = 500, # For now this covers any included objects or object lists
inc_event_abstract_list: bool = False,
inc_event_badge: bool = False,
#inc_event_device_list: bool = False,
#inc_event_exhibit_list: bool = False,
inc_event_file_list: bool = False,
#inc_event_location_list: bool = False,
#inc_event_person_list: bool = False,
inc_event_presentation_list: bool = False,
#inc_event_presenter_list: bool = False,
inc_event_registration: bool = False,
#inc_event_track: bool = False,
inc_person: bool = False,
inc_user: bool = False,
x_account_id: str = Header(...),
by_alias: Optional[bool] = True,
exclude_unset: Optional[bool] = True,
):
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:
return mk_resp(data=None, status_code=404)
if event_person_obj := load_event_person_obj(
event_person_id=event_person_id,
enabled=enabled,
limit=limit,
inc_event_abstract_list=inc_event_abstract_list,
inc_event_badge=inc_event_badge,
#inc_event_device_list=inc_event_device_list,
#inc_event_exhibit_list=inc_event_exhibit_list,
inc_event_file_list=inc_event_file_list,
#inc_event_location=inc_event_location,
#inc_event_person_list=inc_event_person_list,
inc_event_presentation_list=inc_event_presentation_list,
#inc_event_presenter_list=inc_event_presenter_list,
inc_event_registration=inc_event_registration,
#inc_event_track=inc_event_track,
inc_poc_event_person=inc_poc_event_person,
inc_person=inc_person,
inc_user=inc_user,
):
# event_dict = event_person_obj.dict(by_alias=by_alias, exclude_unset=exclude_unset)
pass
else:
return mk_resp(data=False, status_code=400) # Bad Request
return mk_resp(data=event_person_obj)
# ### END ### API Event ### get_event_person_obj() ###

View File

@@ -228,6 +228,62 @@ async def get_event_session_obj(
return result return result
# ### BEGIN ### API Event Session ### get_event_session_obj() ###
# Working well as of 2021-06-04. Using as a template for other routes.
@router.get('/{event_session_id}', response_model=Resp_Body_Base)
async def get_event_session_obj(
event_session_id: str = Query(..., min_length=1, max_length=22),
enabled: str = 'enabled', # For now this covers any included objects or object lists
limit: int = 500, # For now this covers any included objects or object lists
inc_event_abstract_list: bool = False,
inc_event_badge_list: bool = False,
inc_event_device_list: bool = False,
inc_event_file_list: bool = False,
inc_event_location: bool = False,
inc_event_person_list: bool = False,
inc_event_presentation_list: bool = False,
inc_event_presenter_cat: bool = False,
inc_event_presenter_list: bool = False,
inc_event_registration_list: bool = False,
inc_event_track: bool = False,
inc_poc_event_person: bool = False,
x_account_id: str = Header(...),
by_alias: Optional[bool] = True,
exclude_unset: Optional[bool] = True,
):
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)
if event_session_obj := load_event_session_obj(
event_session_id=event_session_id,
enabled=enabled,
limit=limit,
inc_event_abstract_list=inc_event_abstract_list,
inc_event_badge_list=inc_event_badge_list,
inc_event_device_list=inc_event_device_list,
inc_event_file_list=inc_event_file_list,
inc_event_location=inc_event_location,
inc_event_person_list=inc_event_person_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,
inc_event_registration_list=inc_event_registration_list,
inc_event_track=inc_event_track,
inc_poc_event_person=inc_poc_event_person,
):
# event_dict = event_session_obj.dict(by_alias=by_alias, exclude_unset=exclude_unset)
pass
else:
return mk_resp(data=False, status_code=400) # Bad Request
return mk_resp(data=event_session_obj)
# ### END ### API Event ### get_event_session_obj() ###
@router.delete('/{obj_id}', response_model=Resp_Body_Base) @router.delete('/{obj_id}', response_model=Resp_Body_Base)
async def delete_event_session_obj( async def delete_event_session_obj(
obj_id: str = Query(..., min_length=1, max_length=22), obj_id: str = Query(..., min_length=1, max_length=22),