Work on a lot of things. Mainly cleaning up person and profile related fields in multiple tables.

This commit is contained in:
Scott Idem
2021-09-10 18:12:24 -04:00
parent 72820f08ae
commit 15fd32b252
20 changed files with 558 additions and 219 deletions

View File

@@ -23,6 +23,10 @@ def load_event_presenter_obj(
by_alias: bool = True,
exclude_unset: bool = True,
model_as_dict: bool = False,
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,
inc_contact: bool = False,
inc_event_abstract_list: bool = False, # For event_presenter and using load_event_person_obj
@@ -32,8 +36,9 @@ def load_event_presenter_obj(
inc_event_person: bool = False, # Using load_event_person_obj
inc_event_person_profile: bool = False, # Using load_event_person_obj
inc_event_presentation: bool = False,
inc_event_presentation_list: bool = False, # Using load_event_session_obj
inc_event_registration: bool = False, # Using load_event_person_obj
# inc_event_session: bool = False,
inc_event_session: bool = False,
inc_person: bool = False, # Using load_event_person_obj
inc_user: bool = False, # Using load_event_person_obj
) -> Event_Presenter_Base|bool:
@@ -72,22 +77,58 @@ def load_event_presenter_obj(
# if inc_event: pass
if inc_event_abstract_list: pass
if inc_event_device_list: pass
if inc_event_file_list: pass
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_presenter',
for_id = event_presenter_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,
# by_alias = by_alias,
# exclude_unset = exclude_unset,
model_as_dict = model_as_dict,
):
event_file_result_list.append(load_event_file_result)
else:
event_file_result_list.append(None)
log.debug(event_file_result_list)
event_presenter_obj.event_file_list = event_file_result_list
elif isinstance(event_file_rec_list_result, list):
event_presenter_obj.event_file_list = []
else:
event_presenter_obj.event_file_list = None
if inc_event_person:
log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.info('Need to include event person...')
if event_person_obj := load_event_person_obj(
event_person_id = event_person_id,
enabled = enabled,
inc_address = inc_address,
inc_contact = inc_contact,
inc_event_badge = inc_event_badge,
inc_event_person_profile = inc_event_person_profile,
inc_event_registration = inc_event_registration,
inc_person = inc_person,
inc_user = inc_user,
):
event_person_id = event_person_id,
enabled = enabled,
inc_address = inc_address,
inc_contact = inc_contact,
inc_event_badge = inc_event_badge,
inc_event_person_profile = inc_event_person_profile,
inc_event_registration = inc_event_registration,
inc_person = inc_person,
inc_user = inc_user,
):
log.debug(event_person_obj)
event_presenter_obj.event_person = event_person_obj
else:
@@ -98,11 +139,14 @@ def load_event_presenter_obj(
if inc_event_presentation:
log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.info('Need to include event presentation...')
from app.methods.event_presentation_methods import load_event_presentation_obj
if event_presentation_obj := load_event_presentation_obj(
event_presentation_id = event_presentation_id,
):
event_presentation_id = event_presentation_id,
# Don't append the session, presentation list, and things
):
log.debug(event_presentation_obj)
event_presenter_obj.event_presentation = event_presentation_obj
else:
@@ -111,6 +155,24 @@ def load_event_presenter_obj(
event_presenter_obj.event_presentation = None
log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
if inc_event_session:
log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.info('Need to include event session...')
from app.methods.event_session_methods import load_event_session_obj
if event_session_obj := load_event_session_obj(
event_session_id = event_session_id,
inc_event_presentation_list = inc_event_presentation_list,
):
log.debug(event_session_obj)
event_presenter_obj.event_session = event_session_obj
else:
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.debug(event_session_obj)
event_presenter_obj.event_session = None
log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
if model_as_dict:
return event_presenter_obj.dict(by_alias=by_alias, exclude_unset=exclude_unset) # pylint: disable=no-member
else:
@@ -132,8 +194,8 @@ def get_event_presenter_rec_list(
else: return False
data = {}
data[f'event_person_id'] = event_person_id
data[f'event_presentation_id'] = event_presentation_id
data['event_person_id'] = event_person_id
data['event_presentation_id'] = event_presentation_id
if event_person_id:
sql_where_event_person_id = f'`event_presenter`.event_person_id = :event_person_id'