def _validate_name_change(user_profile, data, field_errors): # If user has requested to change name, store old name because we must update associated metadata # after the save process is complete. if "name" not in data: return None old_name = user_profile.name new_name = data['name'] if old_name == new_name: return None try: validate_name(new_name) except ValidationError as err: field_errors["name"] = { "developer_message": f"Error thrown from validate_name: '{err.message}'", "user_message": err.message } return None if _does_name_change_require_verification(user_profile, old_name, new_name): err_msg = 'This name change requires ID verification.' field_errors['name'] = { 'developer_message': err_msg, 'user_message': err_msg } return None return old_name
def _validate_name_change(user_profile, data, field_errors): # If user has requested to change name, store old name because we must update associated metadata # after the save process is complete. if "name" not in data: return None old_name = user_profile.name try: validate_name(data['name']) except ValidationError as err: field_errors["name"] = { "developer_message": f"Error thrown from validate_name: '{err.message}'", "user_message": err.message } return None return old_name