diff --git a/packages/models-library/src/models_library/api_schemas_webserver/groups.py b/packages/models-library/src/models_library/api_schemas_webserver/groups.py index 2c3f3be47d9..7c6e84007e8 100644 --- a/packages/models-library/src/models_library/api_schemas_webserver/groups.py +++ b/packages/models-library/src/models_library/api_schemas_webserver/groups.py @@ -234,6 +234,8 @@ def from_model( groups_by_type: GroupsByTypeTuple, my_product_group: tuple[Group, AccessRightsDict], ) -> Self: + assert groups_by_type.primary # nosec + assert groups_by_type.everyone # nosec return cls( me=GroupGet.from_model(*groups_by_type.primary), organizations=[GroupGet.from_model(*gi) for gi in groups_by_type.standard], diff --git a/services/static-webserver/client/tools/qooxdoo-kit/builder/Dockerfile b/services/static-webserver/client/tools/qooxdoo-kit/builder/Dockerfile index d5ec65a2592..0f29097d278 100644 --- a/services/static-webserver/client/tools/qooxdoo-kit/builder/Dockerfile +++ b/services/static-webserver/client/tools/qooxdoo-kit/builder/Dockerfile @@ -4,7 +4,7 @@ # # Note: context at osparc-simcore/services/static-webserver/client expected # -ARG tag +ARG tag="latest" FROM itisfoundation/qooxdoo-kit:${tag} AS touch WORKDIR /project diff --git a/services/web/server/src/simcore_service_webserver/garbage_collector/_core_utils.py b/services/web/server/src/simcore_service_webserver/garbage_collector/_core_utils.py index a2108766786..6a85dc83539 100644 --- a/services/web/server/src/simcore_service_webserver/garbage_collector/_core_utils.py +++ b/services/web/server/src/simcore_service_webserver/garbage_collector/_core_utils.py @@ -31,7 +31,7 @@ async def _fetch_new_project_owner_from_groups( # go through user_to_groups table and fetch all uid for matching gid for group_gid in standard_groups: # remove the current owner from the bunch - target_group_users = await get_users_in_group(app=app, gid=group_gid) - { + target_group_users = await get_users_in_group(app=app, gid=int(group_gid)) - { user_id } _logger.info("Found group users '%s'", target_group_users) diff --git a/services/web/server/src/simcore_service_webserver/groups/api.py b/services/web/server/src/simcore_service_webserver/groups/api.py index b4cb9b486df..e133f03a8f1 100644 --- a/services/web/server/src/simcore_service_webserver/groups/api.py +++ b/services/web/server/src/simcore_service_webserver/groups/api.py @@ -6,6 +6,7 @@ auto_add_user_to_groups, auto_add_user_to_product_group, get_group_from_gid, + get_product_group_for_user, is_user_by_email_in_group, list_all_user_groups_ids, list_user_groups_ids_with_read_access, @@ -17,9 +18,10 @@ "auto_add_user_to_groups", "auto_add_user_to_product_group", "get_group_from_gid", + "get_product_group_for_user", "is_user_by_email_in_group", "list_all_user_groups_ids", - "list_user_groups_with_read_access", "list_user_groups_ids_with_read_access", + "list_user_groups_with_read_access", # nopycln: file ) diff --git a/services/web/server/src/simcore_service_webserver/users/_users_rest.py b/services/web/server/src/simcore_service_webserver/users/_users_rest.py index bc14362749a..33540de2424 100644 --- a/services/web/server/src/simcore_service_webserver/users/_users_rest.py +++ b/services/web/server/src/simcore_service_webserver/users/_users_rest.py @@ -1,4 +1,5 @@ import logging +from contextlib import suppress from aiohttp import web from models_library.api_schemas_webserver.users import ( @@ -23,6 +24,7 @@ to_exceptions_handlers_map, ) from ..groups import api as groups_api +from ..groups.exceptions import GroupNotFoundError from ..login.decorators import login_required from ..security.decorators import permission_required from ..utils_aiohttp import envelope_json_response @@ -89,14 +91,14 @@ async def get_my_profile(request: web.Request) -> web.Response: my_product_group = None - # if product.group_id: - # with suppress(GroupNotFoundError): - # # Product is optional - # my_product_group = await groups_api.get_product_group_for_user( - # app=request.app, - # user_id=req_ctx.user_id, - # product_gid=product.group_id, - # ) + if product.group_id: + with suppress(GroupNotFoundError): + # Product is optional + my_product_group = await groups_api.get_product_group_for_user( + app=request.app, + user_id=req_ctx.user_id, + product_gid=product.group_id, + ) my_profile, preferences = await _users_service.get_my_profile( request.app, user_id=req_ctx.user_id, product_name=req_ctx.product_name diff --git a/services/web/server/src/simcore_service_webserver/users/_users_service.py b/services/web/server/src/simcore_service_webserver/users/_users_service.py index 8ce0e30c91b..d0336fea8ec 100644 --- a/services/web/server/src/simcore_service_webserver/users/_users_service.py +++ b/services/web/server/src/simcore_service_webserver/users/_users_service.py @@ -146,7 +146,7 @@ async def _list_products_or_none(user_id): ] -async def get_users_in_group(app: web.Application, gid: GroupID) -> set[UserID]: +async def get_users_in_group(app: web.Application, *, gid: GroupID) -> set[UserID]: return await _users_repository.get_users_ids_in_group( get_asyncpg_engine(app), group_id=gid ) diff --git a/services/web/server/tests/unit/with_dbs/01/groups/test_groups_handlers_crud.py b/services/web/server/tests/unit/with_dbs/01/groups/test_groups_handlers_crud.py index 684f8726089..74aa021ddb6 100644 --- a/services/web/server/tests/unit/with_dbs/01/groups/test_groups_handlers_crud.py +++ b/services/web/server/tests/unit/with_dbs/01/groups/test_groups_handlers_crud.py @@ -71,8 +71,8 @@ async def test_list_user_groups_and_try_modify_organizations( my_groups = MyGroupsGet.model_validate(data) assert not error - assert my_groups.me.model_dump(by_alias=True) == primary_group - assert my_groups.all.model_dump(by_alias=True) == all_group + assert my_groups.me.model_dump(by_alias=True, exclude_unset=True) == primary_group + assert my_groups.all.model_dump(by_alias=True, exclude_unset=True) == all_group assert my_groups.organizations assert len(my_groups.organizations) == len(standard_groups) @@ -80,7 +80,7 @@ async def test_list_user_groups_and_try_modify_organizations( by_gid = operator.itemgetter("gid") assert sorted( TypeAdapter(list[GroupGet]).dump_python( - my_groups.organizations, mode="json", by_alias=True + my_groups.organizations, mode="json", by_alias=True, exclude_unset=True ), key=by_gid, ) == sorted(standard_groups, key=by_gid)