Working on event_person and session proposals. Also general clean up of models and methods.
This commit is contained in:
@@ -51,3 +51,34 @@ def create_contact_obj(contact_obj_new:Contact_Base):
|
||||
log.debug(f'Returning the new contact_id: {contact_id}')
|
||||
return contact_id
|
||||
# ### END ### API Contact Methods ### create_contact_obj() ###
|
||||
|
||||
|
||||
# ### BEGIN ### API Contact Methods ### load_contact_obj() ###
|
||||
def load_contact_obj(contact_id:int|str, inc_address:bool=False) -> Contact_Base|bool:
|
||||
log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
log.debug(locals())
|
||||
|
||||
if contact_id := redis_lookup_id_random(record_id_random=contact_id, table_name='contact'): pass
|
||||
else: return False
|
||||
|
||||
if contact_rec := sql_select(table_name='v_contact', record_id=contact_id):
|
||||
#log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
log.debug(contact_rec)
|
||||
|
||||
if inc_address:
|
||||
if address_rec := sql_select(table_name='v_address', field_name='address_id', field_value=contact_rec.get('address_id', None)):
|
||||
contact_rec['address'] = address_rec
|
||||
#log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
log.debug(address_rec)
|
||||
else:
|
||||
return False
|
||||
|
||||
try:
|
||||
contact_obj = Contact_Base(**contact_rec)
|
||||
log.debug(contact_obj)
|
||||
except ValidationError as e:
|
||||
log.error(e.json())
|
||||
return False
|
||||
|
||||
return contact_obj
|
||||
# ### END ### API Contact Methods ### load_contact_obj() ###
|
||||
|
||||
Reference in New Issue
Block a user