Code clean up. Simplifying person, user, contact, and address methods

This commit is contained in:
Scott Idem
2022-01-06 13:47:23 -05:00
parent 567f6a6302
commit c01e668d9e
5 changed files with 22 additions and 21 deletions

View File

@@ -27,14 +27,14 @@ from app.models.user_models import User_Base, User_New_Base, User_Out_Base
def create_user_obj(
account_id: int|str,
user_dict_obj: User_New_Base,
person_id: int,
person_id: int = None, # This should be required in the future
allow_update: bool = False, # Allow updating the user account if one is found
avoid_dup_username: bool = False, # Avoid creating a duplicate by modifying the supplied username
create_sub_obj: bool = False,
fail_any: bool = True, # Fail if any thing goes wrong for sub objects
return_dict: bool = False,
) -> bool|dict|int:
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.setLevel(logging.INFO) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.debug(locals())
# ### SECTION ### Secondary data validation
@@ -147,12 +147,12 @@ def create_user_obj(
def update_user_obj(
user_id: int|str, # Ideally the int ID should be passed. This allows for updating of the id_random value.
user_dict_obj: User_Base,
person_id: int,
person_id: int = None, # This should be required in the future?
create_sub_obj: bool = False,
fail_any: bool = True, # Fail if any thing goes wrong for sub objects
return_dict: bool = False,
) -> bool|int:
log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.setLevel(logging.INFO) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.debug(locals())
# ### SECTION ### Secondary data validation
@@ -274,7 +274,7 @@ def update_user_obj(
# ### SECTION ### Process data
user_obj.id = user_id # Is this needed?
user_dict['user_id'] = user_id
user_dict['id'] = user_id
if person_id:
# Link to an existing person