Code clean up. Bug fixes for person, user, contact, and address methods. There is a bug related get_account_id_w_for_type_id()
This commit is contained in:
@@ -476,15 +476,25 @@ 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
|
||||
# ### SECTION ### Process data# Look for an account_id in the user_obj
|
||||
if account_id: pass
|
||||
elif account_id := person_obj.account_id: pass
|
||||
|
||||
person_obj.account_id = account_id # Is this needed?
|
||||
person_dict['account_id'] = account_id
|
||||
|
||||
if user_id:
|
||||
# Link to an existing user
|
||||
log.info(f'Adding user_id to person_dict. User ID: {user_id}')
|
||||
person_obj.user_id = user_id # Is this needed?
|
||||
person_dict['user_id'] = user_id
|
||||
# Look for a contact_id in the contact_obj
|
||||
if contact_id: pass
|
||||
elif contact_id := person_obj.contact.id: pass
|
||||
|
||||
# Look for a user_id in the person_obj
|
||||
if user_id: pass
|
||||
elif user_id := person_obj.user.id: pass
|
||||
# if user_id:
|
||||
# # Link to an existing user
|
||||
# log.info(f'Adding user_id to person_dict. User ID: {user_id}')
|
||||
# person_obj.user_id = user_id # Is this needed?
|
||||
# person_dict['user_id'] = user_id
|
||||
|
||||
if person_dict_in_result := sql_insert(data=person_dict, table_name='person', rm_id_random=True, id_random_length=default_num_bytes): pass
|
||||
else:
|
||||
@@ -517,6 +527,11 @@ def create_person_kiss(
|
||||
|
||||
if user_id and person_obj.user:
|
||||
log.info('Updating User object')
|
||||
# Link to an existing user
|
||||
log.info(f'Adding user_id to person_dict. User ID: {user_id}')
|
||||
person_obj.user_id = user_id # Is this needed?
|
||||
person_dict['user_id'] = user_id
|
||||
|
||||
from app.methods.user_methods import update_user_obj # NOTE: This creates a loop if outside function
|
||||
if user_update_result := update_user_obj(
|
||||
user_id = user_id,
|
||||
@@ -575,11 +590,18 @@ def update_person_kiss(
|
||||
person_obj.id = person_id # Is this needed?
|
||||
person_dict['id'] = person_id
|
||||
|
||||
if user_id:
|
||||
# Link to an existing user
|
||||
log.info(f'Adding user_id to person_dict. User ID: {user_id}')
|
||||
person_obj.user_id = user_id # Is this needed?
|
||||
person_dict['user_id'] = user_id
|
||||
# Look for a contact_id in the contact_obj
|
||||
if contact_id: pass
|
||||
elif contact_id := person_obj.contact.id: pass
|
||||
|
||||
# Look for a user_id in the person_obj
|
||||
if user_id: pass
|
||||
elif user_id := person_obj.user.id: pass
|
||||
# if user_id:
|
||||
# # Link to an existing user
|
||||
# log.info(f'Adding user_id to person_dict. User ID: {user_id}')
|
||||
# person_obj.user_id = user_id # Is this needed?
|
||||
# person_dict['user_id'] = user_id
|
||||
|
||||
if person_dict_up_result := sql_update(data=person_dict, table_name='person', rm_id_random=True, id_random_length=default_num_bytes): pass
|
||||
else:
|
||||
@@ -611,6 +633,11 @@ def update_person_kiss(
|
||||
|
||||
if user_id and person_obj.user:
|
||||
log.info('Updating User object')
|
||||
# Link to an existing user
|
||||
log.info(f'Adding user_id to person_dict. User ID: {user_id}')
|
||||
person_obj.user_id = user_id # Is this needed?
|
||||
person_dict['user_id'] = user_id
|
||||
|
||||
from app.methods.user_methods import update_user_obj # NOTE: This creates a loop if outside function
|
||||
if user_update_result := update_user_obj(
|
||||
user_id = user_id,
|
||||
|
||||
Reference in New Issue
Block a user