Work on simplifying functions. ID lookups are better. Person and User related is being worked on.
This commit is contained in:
@@ -424,6 +424,29 @@ def get_person_rec_list(
|
||||
# ### END ### API Person Methods ### get_person_rec_list() ###
|
||||
|
||||
|
||||
# def quick_dict_obj_return(
|
||||
# data_dict_obj,
|
||||
# Obj_Type,
|
||||
# dict_exclude: list,
|
||||
# ) -> dict:
|
||||
|
||||
# log.debug(type(data_dict_obj))
|
||||
# if isinstance(data_dict_obj, dict):
|
||||
# data_dict = data_dict_obj
|
||||
# try:
|
||||
# data_obj = Person_Base(**data_dict)
|
||||
# data_obj = Obj_Type(**data_dict)
|
||||
# log.debug(data_obj)
|
||||
# except ValidationError as e:
|
||||
# log.error(e.json())
|
||||
# return False
|
||||
# else:
|
||||
# data_obj = data_dict_obj
|
||||
# data_obj.account_id = account_id
|
||||
|
||||
# data_dict = data_obj.dict(by_alias=False, exclude_defaults=False, exclude_unset=True, exclude=['contact', 'contact_id', 'contact_id_random', 'email', 'cc_email', 'membership_person_id', 'membership_person_id_random', 'organization', 'user', 'created_on', 'updated_on'])
|
||||
|
||||
|
||||
# ### BEGIN ### API Person Methods ### create_person_kiss() ###
|
||||
# Updated 2022-01-05
|
||||
def create_person_kiss(
|
||||
@@ -436,13 +459,13 @@ def create_person_kiss(
|
||||
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
log.debug(locals())
|
||||
|
||||
# ### SECTION ### Secondary data validation
|
||||
log.info('Create dictionary or Pydantic object')
|
||||
log.debug(type(person_dict_obj))
|
||||
if isinstance(person_dict_obj, dict):
|
||||
person_dict = person_dict_obj
|
||||
try:
|
||||
person_obj = Person_Base(**person_dict)
|
||||
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
log.debug(person_obj)
|
||||
except ValidationError as e:
|
||||
log.error(e.json())
|
||||
@@ -453,6 +476,7 @@ def create_person_kiss(
|
||||
|
||||
person_dict = person_obj.dict(by_alias=False, exclude_defaults=False, exclude_unset=True, exclude={'contact', 'contact_id', 'contact_id_random', 'email', 'cc_email', 'membership_person_id', 'membership_person_id_random', 'organization', 'user', 'created_on', 'updated_on'})
|
||||
|
||||
# ### SECTION ### Process data
|
||||
if user_id:
|
||||
# Link to an existing user
|
||||
log.info(f'Adding user_id to person_dict. User ID: {user_id}')
|
||||
@@ -469,7 +493,11 @@ def create_person_kiss(
|
||||
|
||||
if contact_id and person.contact:
|
||||
log.info('Updating Contact object')
|
||||
if contact_update_result := update_contact(): pass
|
||||
if contact_update_result := update_contact(
|
||||
contact_dict_obj = person_obj.contact,
|
||||
for_type = 'person',
|
||||
for_id = person_id,
|
||||
): pass
|
||||
else: return False
|
||||
elif person.contact:
|
||||
log.info('Creating Contact object')
|
||||
@@ -484,7 +512,10 @@ def create_person_kiss(
|
||||
|
||||
if user_id and person.user:
|
||||
log.info('Updating User object')
|
||||
if user_update_result := update_user(): pass
|
||||
if user_update_result := update_user(
|
||||
user_dict_obj = person_obj.user,
|
||||
person_id = person_id,
|
||||
): pass # NOTE: There is a trigger that will update the person record with the new user ID.
|
||||
else: return False
|
||||
elif person.user:
|
||||
log.info('Creating User object')
|
||||
|
||||
Reference in New Issue
Block a user