Work on Impexium, exhibit, and badge related
This commit is contained in:
@@ -94,13 +94,12 @@ def get_event_person_id_w_event_person_profile_id(
|
||||
|
||||
|
||||
# ### BEGIN ### API Event Person Profile Methods ### create_update_event_person_profile_obj_v4() ###
|
||||
# NOTE: This will create or update a event_person_profile.
|
||||
# Rewrite and updated 2021-09-07
|
||||
# Updated 2022-02-23
|
||||
def create_update_event_person_profile_obj_v4(
|
||||
event_person_profile_dict_obj: Event_Person_Profile_Base|dict,
|
||||
event_person_profile_id: int|str = None,
|
||||
account_id: int|str = None,
|
||||
event_id: int|str = None,
|
||||
# account_id: int|str = None,
|
||||
# event_id: int|str = None,
|
||||
event_person_id: int|str = None,
|
||||
create_sub_obj: bool = False,
|
||||
fail_any: bool = False, # Fail if any thing goes wrong for sub objects
|
||||
@@ -109,12 +108,8 @@ def create_update_event_person_profile_obj_v4(
|
||||
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
log.debug(locals())
|
||||
|
||||
# ### SECTION ### Secondary data validation
|
||||
log.info('Checking requirements...')
|
||||
if account_id := redis_lookup_id_random(record_id_random=account_id, table_name='account'): pass
|
||||
else:
|
||||
log.error('Missing or invalid Account ID passed. Not required. Ignoring for now.')
|
||||
log.info(f'Account ID: {account_id}')
|
||||
|
||||
if event_person_profile_id:
|
||||
log.info(f'Event Person Profile ID passed. Update existing Event Person Profile. Event Person Profile ID: {event_person_profile_id}')
|
||||
|
||||
@@ -131,6 +126,7 @@ def create_update_event_person_profile_obj_v4(
|
||||
log.info(f'Event Person ID: {event_person_id}')
|
||||
return False
|
||||
|
||||
log.info('Create dictionary or Pydantic object')
|
||||
log.debug(type(event_person_profile_dict_obj))
|
||||
if isinstance(event_person_profile_dict_obj, dict):
|
||||
event_person_profile_dict = event_person_profile_dict_obj
|
||||
@@ -138,8 +134,6 @@ def create_update_event_person_profile_obj_v4(
|
||||
event_person_profile_dict['event_person_profile_id'] = event_person_profile_id
|
||||
try:
|
||||
event_person_profile_obj = Event_Person_Profile_Base(**event_person_profile_dict)
|
||||
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
log.debug(event_person_profile_obj)
|
||||
except ValidationError as e:
|
||||
log.error(e.json())
|
||||
return False
|
||||
@@ -148,8 +142,16 @@ def create_update_event_person_profile_obj_v4(
|
||||
if event_person_profile_id:
|
||||
# NOTE: Can't update the ID alias if it was never set.
|
||||
event_person_profile_obj.id = event_person_profile_id
|
||||
log.debug(event_person_profile_obj)
|
||||
|
||||
event_person_profile_dict = event_person_profile_obj.dict(by_alias=False, exclude_defaults=False, exclude_unset=True, exclude={'account_id', 'account_id_random', 'contact', 'event_cfg', 'event_id', 'event_id_random', 'organization', 'created_on', 'updated_on'})
|
||||
event_person_profile_dict = event_person_profile_obj.dict(by_alias=False, exclude_defaults=False, exclude_unset=True, exclude={'account_id', 'account_id_random', 'contact', 'event_cfg', 'event_id', 'event_id_random', 'event_person_id', 'event_person_id_random', 'organization', 'created_on', 'updated_on'})
|
||||
|
||||
# ### SECTION ### Process data
|
||||
contact_id = None
|
||||
if event_person_profile_obj.contact and event_person_profile_obj.contact.id:
|
||||
contact_id = event_person_profile_obj.contact.id
|
||||
elif event_person_profile_obj.contact and event_person_profile_obj.contact_id:
|
||||
contact_id = event_person_profile_obj.contact_id
|
||||
|
||||
if event_person_profile_id:
|
||||
if event_person_profile_dict_up_result := sql_update(data=event_person_profile_dict, table_name='event_person_profile', rm_id_random=True): pass
|
||||
@@ -169,13 +171,14 @@ def create_update_event_person_profile_obj_v4(
|
||||
event_person_profile_id = event_person_profile_dict_in_result
|
||||
|
||||
# NOTE: This is really only needed if a new contact is being created
|
||||
if not account_id:
|
||||
log.info('Attempting to get Account ID from related object.')
|
||||
if account_id := event_person_profile_obj.account_id: pass
|
||||
elif account_id := event_person_profile_obj.account_id_random: pass
|
||||
elif event_person_id: pass
|
||||
|
||||
log.info('Attempting to get Account ID from related object.')
|
||||
if account_id := event_person_profile_obj.account_id: pass
|
||||
# elif account_id := event_person_profile_obj.account_id_random: pass
|
||||
else:
|
||||
if event_person_id: pass
|
||||
elif event_person_id := event_person_profile_obj.event_person_id: pass
|
||||
elif event_person_id := event_person_profile_obj.event_person_id_random: pass
|
||||
# elif event_person_id := event_person_profile_obj.event_person_id_random: pass
|
||||
|
||||
if event_person_id:
|
||||
if account_id := get_account_id_w_for_type_id(for_type='event_person', for_id=event_person_id): pass
|
||||
@@ -190,10 +193,6 @@ def create_update_event_person_profile_obj_v4(
|
||||
if event_person_profile_obj.contact:
|
||||
event_person_profile_outline['contact_id'] = None
|
||||
contact_obj = event_person_profile_obj.contact
|
||||
if contact_id := event_person_profile_obj.contact_id: pass
|
||||
elif contact_id := contact_obj.id: pass
|
||||
else: contact_id = None
|
||||
contact_obj.id
|
||||
contact_obj.for_type = 'event_person_profile'
|
||||
contact_obj.for_id = event_person_profile_id
|
||||
create_update_contact_obj_result = create_update_contact_obj_v4(
|
||||
|
||||
Reference in New Issue
Block a user