Skip to content

Commit cf83d59

Browse files
committed
tests passing
1 parent e402440 commit cf83d59

File tree

3 files changed

+26
-10
lines changed

3 files changed

+26
-10
lines changed

packages/models-library/src/models_library/api_schemas_webserver/groups.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,26 @@ class GroupGet(OutputSchema):
6363
@classmethod
6464
def from_model(cls, group: Group, access_rights: AccessRightsDict) -> Self:
6565
# Fuses both dataset into GroupSet
66+
_to = {
67+
"name": "label",
68+
}
69+
6670
return cls.model_validate(
6771
{
68-
**group.model_dump(),
72+
**{
73+
_to.get(key, key): value
74+
for key, value in group.model_dump(
75+
include={
76+
"gid",
77+
"name",
78+
"description",
79+
"thumbnail",
80+
"inclusion_rules",
81+
},
82+
exclude_unset=True,
83+
by_alias=False,
84+
).items()
85+
},
6986
"access_rights": access_rights,
7087
}
7188
)

packages/models-library/src/models_library/groups.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import enum
2-
from typing import Annotated, Final, NamedTuple, TypeAlias, TypedDict
2+
from typing import Annotated, Final, NamedTuple, TypeAlias
33

44
from common_library.basic_types import DEFAULT_FACTORY
55
from pydantic import BaseModel, ConfigDict, EmailStr, Field, field_validator
66
from pydantic.types import PositiveInt
7+
from typing_extensions import TypedDict
78

89
from .basic_types import IDStr
910
from .users import GroupID, UserID
@@ -42,6 +43,8 @@ class Group(BaseModel):
4243
create_enums_pre_validator(GroupTypeInModel)
4344
)
4445

46+
model_config = ConfigDict(populate_by_name=True)
47+
4548

4649
class AccessRightsDict(TypedDict):
4750
read: bool

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

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,7 @@ def _row_to_model(group: Row) -> Group:
7575
def _to_group_info_tuple(group: Row) -> GroupInfoTuple:
7676
return (
7777
_row_to_model(group),
78-
AccessRightsDict(
79-
read=group.access_rights.read,
80-
write=group.access_rights.read,
81-
delete=group.access_rights.delete,
82-
),
78+
AccessRightsDict(**group.access_rights),
8379
)
8480

8581

@@ -353,15 +349,15 @@ async def delete_user_group(
353349
users.c.id,
354350
users.c.name,
355351
sa.case(
356-
[(users.c.privacy_hide_email == sa.true(), None)],
352+
(users.c.privacy_hide_email.is_(True), None),
357353
else_=users.c.email,
358354
).label("email"),
359355
sa.case(
360-
[(users.c.privacy_hide_fullname == sa.true(), None)],
356+
(users.c.privacy_hide_fullname.is_(True), None),
361357
else_=users.c.first_name,
362358
).label("first_name"),
363359
sa.case(
364-
[(users.c.privacy_hide_fullname == sa.true(), None)],
360+
(users.c.privacy_hide_fullname.is_(True), None),
365361
else_=users.c.last_name,
366362
).label("last_name"),
367363
users.c.primary_gid,

0 commit comments

Comments
 (0)