diff --git a/app/methods/address_methods.py b/app/methods/address_methods.py index 48f65ea..5943967 100644 --- a/app/methods/address_methods.py +++ b/app/methods/address_methods.py @@ -231,7 +231,7 @@ def create_address_obj( for_id: int|str = None, fail_any: bool = False, # Fail if any thing goes wrong for sub objects ) -> int|bool: - 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 @@ -312,7 +312,7 @@ def update_address_obj( create_sub_obj: bool = False, fail_any: bool = False, # Fail if any thing goes wrong for sub objects ) -> bool: - 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 @@ -326,7 +326,6 @@ def update_address_obj( address_dict = address_dict_obj try: address_obj = Contact_Base(**address_dict) - log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(address_obj) except ValidationError as e: log.error(e.json()) @@ -338,7 +337,7 @@ def update_address_obj( # ### SECTION ### Process data address_obj.id = address_id # Is this needed? - address_dict['address_id'] = address_id + address_dict['id'] = address_id log.debug(address_dict_obj) # log.debug(address_dict_obj.dict(by_alias=True, exclude_unset=True)) diff --git a/app/methods/contact_methods.py b/app/methods/contact_methods.py index f9ac1a3..377b36d 100644 --- a/app/methods/contact_methods.py +++ b/app/methods/contact_methods.py @@ -322,7 +322,7 @@ def create_contact_obj( create_sub_obj: bool = False, fail_any: bool = False, # Fail if any thing goes wrong for sub objects ) -> int|bool: - 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 @@ -451,7 +451,7 @@ def update_contact_obj( fail_any: bool = False, # Fail if any thing goes wrong for sub objects return_dict: bool = False, ) -> bool: - 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 @@ -465,7 +465,6 @@ def update_contact_obj( contact_dict = contact_dict_obj try: contact_obj = Contact_Base(**contact_dict) - log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(contact_obj) except ValidationError as e: log.error(e.json()) @@ -477,7 +476,7 @@ def update_contact_obj( # ### SECTION ### Process data contact_obj.id = contact_id # Is this needed? - contact_dict['contact_id'] = contact_id + contact_dict['id'] = contact_id account_id = get_account_id_w_contact_id(contact_id) diff --git a/app/methods/person_methods.py b/app/methods/person_methods.py index c60ed3b..99e6376 100644 --- a/app/methods/person_methods.py +++ b/app/methods/person_methods.py @@ -570,7 +570,7 @@ def update_person_kiss( # ### SECTION ### Process data person_obj.id = person_id # Is this needed? - person_dict['person_id'] = person_id + person_dict['id'] = person_id if user_id: # Link to an existing user @@ -799,6 +799,7 @@ def create_update_person_obj_v4b( if update_user_obj_result := update_user_obj( user_id = user_id, user_dict_obj = user_obj, + person_id = person_id, # create_sub_obj = create_sub_obj, # fail_any = fail_any, ): @@ -819,6 +820,7 @@ def create_update_person_obj_v4b( if create_user_obj_result := create_user_obj( account_id = account_id, user_dict_obj = user_obj, + person_id = person_id, # create_sub_obj = create_sub_obj, # fail_any = fail_any, ): diff --git a/app/methods/user_methods.py b/app/methods/user_methods.py index 533bd24..a94c30c 100644 --- a/app/methods/user_methods.py +++ b/app/methods/user_methods.py @@ -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 diff --git a/app/routers/user.py b/app/routers/user.py index 4d422c4..1fc43ec 100644 --- a/app/routers/user.py +++ b/app/routers/user.py @@ -223,11 +223,12 @@ async def user_authenticate( log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL log.debug(locals()) - if account_id and username and password: - account_id = commons.x_account_id + account_id = commons.x_account_id + if username and password: user_data = {} - user_data['account_id'] = account_id + if not null_account_id: user_data['account_id'] = account_id + else: user_data['account_id'] = None user_data['username'] = username # sql_select(table_name='user', data=user_data) @@ -631,14 +632,14 @@ async def lookup_email( data['account_id'] = account_id data['email'] = email - if enabled in ['enabled', 'disabled', 'all']: - if enabled == 'enabled': + if commons.enabled in ['enabled', 'disabled', 'all']: + if commons.enabled == 'enabled': data['enable'] = True sql_enabled = f'AND `user`.enable = :enable' - elif enabled == 'disabled': + elif commons.enabled == 'disabled': data['enable'] = False sql_enabled = f'AND `user`.enable = :enable' - elif enabled == 'all': + elif commons.enabled == 'all': sql_enabled = '' else: return mk_resp(data=None, status_code=400, response=commons.response) # Bad Request