Code clean up. Simplifying person, user, contact, and address methods
This commit is contained in:
@@ -448,7 +448,7 @@ def get_person_rec_list(
|
||||
|
||||
|
||||
# ### BEGIN ### API Person Methods ### create_person_kiss() ###
|
||||
# Updated 2022-01-05
|
||||
# Updated 2022-01-06
|
||||
def create_person_kiss(
|
||||
account_id: int,
|
||||
person_dict_obj: Person_Base,
|
||||
@@ -495,7 +495,7 @@ def create_person_kiss(
|
||||
log.debug(person_dict_in_result)
|
||||
person_id = person_dict_in_result
|
||||
|
||||
if contact_id and person.contact:
|
||||
if contact_id and person_obj.contact:
|
||||
log.info('Updating Contact object')
|
||||
if contact_update_result := update_contact_obj(
|
||||
contact_id = contact_id,
|
||||
@@ -504,7 +504,7 @@ def create_person_kiss(
|
||||
for_id = person_id,
|
||||
): pass
|
||||
else: return False
|
||||
elif person.contact:
|
||||
elif person_obj.contact:
|
||||
log.info('Creating Contact object')
|
||||
if contact_create_result := create_contact_obj(
|
||||
account_id = account_id,
|
||||
@@ -515,7 +515,7 @@ def create_person_kiss(
|
||||
else: return False
|
||||
else: pass
|
||||
|
||||
if user_id and person.user:
|
||||
if user_id and person_obj.user:
|
||||
log.info('Updating User object')
|
||||
if user_update_result := update_user_obj(
|
||||
user_id = user_id,
|
||||
@@ -523,7 +523,7 @@ def create_person_kiss(
|
||||
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:
|
||||
elif person_obj.user:
|
||||
log.info('Creating User object')
|
||||
if user_create_result := create_user_obj(
|
||||
account_id = account_id,
|
||||
@@ -540,7 +540,7 @@ def create_person_kiss(
|
||||
|
||||
|
||||
# ### BEGIN ### API Person Methods ### update_person_kiss() ###
|
||||
# Updated 2022-01-05
|
||||
# Updated 2022-01-06
|
||||
def update_person_kiss(
|
||||
person_id: int,
|
||||
person_dict_obj: Person_Base,
|
||||
@@ -569,7 +569,7 @@ def update_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
|
||||
person_obj.person_id = person_id # Is this needed?
|
||||
person_obj.id = person_id # Is this needed?
|
||||
person_dict['person_id'] = person_id
|
||||
|
||||
if user_id:
|
||||
@@ -586,7 +586,7 @@ def update_person_kiss(
|
||||
|
||||
log.debug(person_dict_up_result)
|
||||
|
||||
if contact_id and person.contact:
|
||||
if contact_id and person_obj.contact:
|
||||
log.info('Updating Contact object')
|
||||
if contact_update_result := update_contact_obj(
|
||||
contact_id = contact_id,
|
||||
@@ -595,7 +595,7 @@ def update_person_kiss(
|
||||
for_id = person_id,
|
||||
): pass
|
||||
else: return False
|
||||
elif person.contact:
|
||||
elif person_obj.contact:
|
||||
log.info('Creating Contact object')
|
||||
if contact_create_result := create_contact_obj(
|
||||
account_id = account_id,
|
||||
@@ -606,7 +606,7 @@ def update_person_kiss(
|
||||
else: return False
|
||||
else: pass
|
||||
|
||||
if user_id and person.user:
|
||||
if user_id and person_obj.user:
|
||||
log.info('Updating User object')
|
||||
if user_update_result := update_user_obj(
|
||||
user_id = user_id,
|
||||
@@ -614,7 +614,7 @@ def update_person_kiss(
|
||||
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:
|
||||
elif person_obj.user:
|
||||
log.info('Creating User object')
|
||||
if user_create_result := create_user_obj(
|
||||
account_id = account_id,
|
||||
@@ -1495,10 +1495,10 @@ def update_person_obj(
|
||||
log.debug(contact_id)
|
||||
log.debug(contact_obj_up)
|
||||
if contact_obj_up_result := update_contact_obj(
|
||||
contact_id = contact_id,
|
||||
contact_obj_up = contact_obj_up,
|
||||
create_sub_obj = create_sub_obj,
|
||||
):
|
||||
contact_id = contact_id,
|
||||
contact_dict_obj = contact_obj_up,
|
||||
create_sub_obj = create_sub_obj,
|
||||
):
|
||||
log.debug(contact_obj_up_result)
|
||||
else:
|
||||
log.debug(contact_obj_up_result)
|
||||
@@ -1507,7 +1507,10 @@ def update_person_obj(
|
||||
# NOTE: This will blindly create a new contact even if there was one associated but the person.contact_id was not found.
|
||||
contact_obj_in = person_obj_up.contact
|
||||
log.debug(contact_obj_in)
|
||||
if contact_obj_in_result := create_contact_obj(contact_obj_new=contact_obj_in):
|
||||
if contact_obj_in_result := create_contact_obj(
|
||||
account_id = contact_obj_in.account_id,
|
||||
contact_dict_obj = contact_obj_in,
|
||||
):
|
||||
# log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
log.debug(contact_obj_in_result)
|
||||
# NOTE: This last update should no longer be needed now that the person.contact_id is not supposed to be used.
|
||||
|
||||
Reference in New Issue
Block a user