Skip to content

Commit 2545bf4

Browse files
committed
rm mapping
1 parent f2a44a5 commit 2545bf4

File tree

3 files changed

+27
-26
lines changed

3 files changed

+27
-26
lines changed

services/web/server/src/simcore_service_webserver/groups/_utils.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from aiopg.sa.result import RowProxy
2-
31
_GROUPS_SCHEMA_TO_DB = {
42
"gid": "gid",
53
"label": "name",
@@ -10,18 +8,6 @@
108
}
119

1210

13-
def convert_groups_db_to_schema(
14-
db_row: RowProxy, *, prefix: str | None = "", **kwargs
15-
) -> dict:
16-
converted_dict = {
17-
k: db_row[f"{prefix}{v}"]
18-
for k, v in _GROUPS_SCHEMA_TO_DB.items()
19-
if f"{prefix}{v}" in db_row
20-
}
21-
converted_dict.update(**kwargs)
22-
return converted_dict
23-
24-
2511
def convert_groups_schema_to_db(schema: dict) -> dict:
2612
return {
2713
v: schema[k]

services/web/server/src/simcore_service_webserver/groups/models.py

Lines changed: 0 additions & 6 deletions
This file was deleted.

services/web/server/src/simcore_service_webserver/users/api.py

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
from simcore_postgres_database.utils_users import generate_alternative_username
3232

3333
from ..db.plugin import get_database_engine
34-
from ..groups.models import convert_groups_db_to_schema
3534
from ..login.storage import AsyncpgStorage, get_plugin_storage
3635
from ..security.api import clean_auth_policy_cache
3736
from . import _db
@@ -47,6 +46,28 @@
4746
_logger = logging.getLogger(__name__)
4847

4948

49+
_GROUPS_SCHEMA_TO_DB = {
50+
"gid": "gid",
51+
"label": "name",
52+
"description": "description",
53+
"thumbnail": "thumbnail",
54+
"accessRights": "access_rights",
55+
"inclusionRules": "inclusion_rules",
56+
}
57+
58+
59+
def _convert_groups_db_to_schema(
60+
db_row: RowProxy, *, prefix: str | None = "", **kwargs
61+
) -> dict:
62+
converted_dict = {
63+
k: db_row[f"{prefix}{v}"]
64+
for k, v in _GROUPS_SCHEMA_TO_DB.items()
65+
if f"{prefix}{v}" in db_row
66+
}
67+
converted_dict.update(**kwargs)
68+
return converted_dict
69+
70+
5071
def _parse_as_user(user_id: Any) -> UserID:
5172
try:
5273
return TypeAdapter(UserID).validate_python(user_id)
@@ -64,7 +85,7 @@ async def get_user_profile(
6485

6586
engine = get_database_engine(app)
6687
user_profile: dict[str, Any] = {}
67-
user_primary_group = all_group = {}
88+
user_primary_group = everyone_group = {}
6889
user_standard_groups = []
6990
user_id = _parse_as_user(user_id)
7091

@@ -99,20 +120,20 @@ async def get_user_profile(
99120
assert user_profile["id"] == user_id # nosec
100121

101122
if row.groups_type == GroupType.EVERYONE:
102-
all_group = convert_groups_db_to_schema(
123+
everyone_group = _convert_groups_db_to_schema(
103124
row,
104125
prefix="groups_",
105126
accessRights=row["user_to_groups_access_rights"],
106127
)
107128
elif row.groups_type == GroupType.PRIMARY:
108-
user_primary_group = convert_groups_db_to_schema(
129+
user_primary_group = _convert_groups_db_to_schema(
109130
row,
110131
prefix="groups_",
111132
accessRights=row["user_to_groups_access_rights"],
112133
)
113134
else:
114135
user_standard_groups.append(
115-
convert_groups_db_to_schema(
136+
_convert_groups_db_to_schema(
116137
row,
117138
prefix="groups_",
118139
accessRights=row["user_to_groups_access_rights"],
@@ -147,7 +168,7 @@ async def get_user_profile(
147168
groups={ # type: ignore[arg-type]
148169
"me": user_primary_group,
149170
"organizations": user_standard_groups,
150-
"all": all_group,
171+
"all": everyone_group,
151172
},
152173
privacy=MyProfilePrivacyGet(
153174
hide_fullname=user_profile["privacy_hide_fullname"],

0 commit comments

Comments
 (0)