Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
pcrespov committed Dec 12, 2024
1 parent 24d3711 commit dd95af0
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
)
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import logging
from contextlib import suppress

from aiohttp import web
from models_library.api_schemas_webserver.users import (
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,16 @@ 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)

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)
Expand Down

0 comments on commit dd95af0

Please sign in to comment.