Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modify code when a user is not a dict type #378

Merged
merged 1 commit into from
Sep 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 10 additions & 12 deletions src/spaceone/identity/service/workspace_group_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -563,27 +563,25 @@ def add_user_name_and_state_to_users(
"name": user_vo.name,
"state": user_vo.state,
}

if wg_users is None:
wg_users = []
users = []
for user in wg_users:
if isinstance(user, dict):
user_id = user.get("user_id", "")
else:
user_id = getattr(user, "user_id", "") or ""

user_name = user_info_map.get(user_id, {}).get("name", "")
user_state = user_info_map.get(user_id, {}).get("state", "")

if isinstance(user, dict):
user_name = user_info_map.get(user_id, {}).get("name", "")
user_state = user_info_map.get(user_id, {}).get("state", "")
user["user_name"] = user_name
user["state"] = user_state
users.append(user)
else:
setattr(user, "user_name", user_name)
setattr(user, "state", user_state)

users.append(user)
user_id = getattr(user, "user_id", "") or ""
user_name = user_info_map.get(user_id, {}).get("name", "")
user_state = user_info_map.get(user_id, {}).get("state", "")
user_dict = user.to_mongo().to_dict()
user_dict["user_name"] = user_name
user_dict["state"] = user_state
users.append(user_dict)

if isinstance(workspace_group_info, dict):
workspace_group_info["users"] = users
Expand Down
Loading