diff --git a/packages/common-library/src/common_library/groups_enums.py b/packages/common-library/src/common_library/groups_enums.py index 72c5029d646..215edf335f1 100644 --- a/packages/common-library/src/common_library/groups_enums.py +++ b/packages/common-library/src/common_library/groups_enums.py @@ -1,7 +1,7 @@ import enum -class GroupTypeEnum(enum.Enum): +class GroupType(enum.Enum): """ standard: standard group, e.g. any group that is not a primary group or special group such as the everyone group primary: primary group, e.g. the primary group is the user own defined group that typically only contain the user (same as in linux) diff --git a/packages/models-library/src/models_library/groups.py b/packages/models-library/src/models_library/groups.py index 902a7da0355..797453922f9 100644 --- a/packages/models-library/src/models_library/groups.py +++ b/packages/models-library/src/models_library/groups.py @@ -1,7 +1,7 @@ from typing import Annotated, Final, NamedTuple, TypeAlias from common_library.basic_types import DEFAULT_FACTORY -from common_library.groups_enums import GroupTypeEnum as GroupTypeEnum +from common_library.groups_enums import GroupType as GroupType from pydantic import BaseModel, ConfigDict, EmailStr, Field, field_validator from pydantic.types import PositiveInt from typing_extensions import TypedDict @@ -14,14 +14,14 @@ GroupID: TypeAlias = PositiveInt -__all__: tuple[str, ...] = ("GroupTypeEnum",) +__all__: tuple[str, ...] = ("GroupType",) class Group(BaseModel): gid: PositiveInt name: str description: str - group_type: Annotated[GroupTypeEnum, Field(alias="type")] + group_type: Annotated[GroupType, Field(alias="type")] thumbnail: str | None inclusion_rules: Annotated[ @@ -32,7 +32,7 @@ class Group(BaseModel): ] = DEFAULT_FACTORY _from_equivalent_enums = field_validator("group_type", mode="before")( - create_enums_pre_validator(GroupTypeEnum) + create_enums_pre_validator(GroupType) ) model_config = ConfigDict(populate_by_name=True) diff --git a/packages/postgres-database/src/simcore_postgres_database/models/groups.py b/packages/postgres-database/src/simcore_postgres_database/models/groups.py index 86ac946b4e9..e2d1e4655ef 100644 --- a/packages/postgres-database/src/simcore_postgres_database/models/groups.py +++ b/packages/postgres-database/src/simcore_postgres_database/models/groups.py @@ -6,7 +6,7 @@ import sqlalchemy as sa -from common_library.groups_enums import GroupTypeEnum +from common_library.groups_enums import GroupType from sqlalchemy.dialects.postgresql import JSONB from sqlalchemy.sql import func @@ -27,7 +27,7 @@ sa.Column("description", sa.String, nullable=False, doc="Short description"), sa.Column( "type", - sa.Enum(GroupTypeEnum), + sa.Enum(GroupType), nullable=False, server_default="STANDARD", doc="Classification of the group based on GroupType enum", diff --git a/packages/postgres-database/src/simcore_postgres_database/utils_groups_extra_properties.py b/packages/postgres-database/src/simcore_postgres_database/utils_groups_extra_properties.py index e88fe83b0df..b6c25183a21 100644 --- a/packages/postgres-database/src/simcore_postgres_database/utils_groups_extra_properties.py +++ b/packages/postgres-database/src/simcore_postgres_database/utils_groups_extra_properties.py @@ -7,7 +7,7 @@ from aiopg.sa.connection import SAConnection from aiopg.sa.result import RowProxy -from .models.groups import GroupTypeEnum, groups, user_to_groups +from .models.groups import GroupType, groups, user_to_groups from .models.groups_extra_properties import groups_extra_properties from .utils_models import FromRowMixin @@ -44,9 +44,9 @@ async def _list_table_entries_ordered_by_group_type( groups.c.type, sa.case( # NOTE: the ordering is important for the aggregation afterwards - (groups.c.type == GroupTypeEnum.EVERYONE, sa.literal(3)), - (groups.c.type == GroupTypeEnum.STANDARD, sa.literal(2)), - (groups.c.type == GroupTypeEnum.PRIMARY, sa.literal(1)), + (groups.c.type == GroupType.EVERYONE, sa.literal(3)), + (groups.c.type == GroupType.STANDARD, sa.literal(2)), + (groups.c.type == GroupType.PRIMARY, sa.literal(1)), else_=sa.literal(4), ).label("type_order"), ) @@ -124,10 +124,10 @@ async def get_aggregated_properties_for_user( for row in rows: group_extra_properties = GroupExtraProperties.from_row(row) match row.type: - case GroupTypeEnum.PRIMARY: + case GroupType.PRIMARY: # this always has highest priority return group_extra_properties - case GroupTypeEnum.STANDARD: + case GroupType.STANDARD: if merged_standard_extra_properties: merged_standard_extra_properties = ( _merge_extra_properties_booleans( @@ -137,7 +137,7 @@ async def get_aggregated_properties_for_user( ) else: merged_standard_extra_properties = group_extra_properties - case GroupTypeEnum.EVERYONE: + case GroupType.EVERYONE: # if there are standard properties, they take precedence return ( merged_standard_extra_properties diff --git a/packages/postgres-database/src/simcore_postgres_database/utils_products.py b/packages/postgres-database/src/simcore_postgres_database/utils_products.py index 9e54fef9787..33e877c21d0 100644 --- a/packages/postgres-database/src/simcore_postgres_database/utils_products.py +++ b/packages/postgres-database/src/simcore_postgres_database/utils_products.py @@ -7,7 +7,7 @@ import sqlalchemy as sa from ._protocols import AiopgConnection, DBConnection -from .models.groups import GroupTypeEnum, groups +from .models.groups import GroupType, groups from .models.products import products # NOTE: outside this module, use instead packages/models-library/src/models_library/users.py @@ -57,7 +57,7 @@ async def execute_get_or_create_product_group(conn, product_name: str) -> int: .values( name=product_name, description=f"{product_name} product group", - type=GroupTypeEnum.STANDARD, + type=GroupType.STANDARD, ) .returning(groups.c.gid) ) diff --git a/packages/postgres-database/src/simcore_postgres_database/webserver_models.py b/packages/postgres-database/src/simcore_postgres_database/webserver_models.py index 68f8d51bfe4..571db047cfb 100644 --- a/packages/postgres-database/src/simcore_postgres_database/webserver_models.py +++ b/packages/postgres-database/src/simcore_postgres_database/webserver_models.py @@ -9,7 +9,7 @@ from .models.comp_pipeline import StateType, comp_pipeline from .models.comp_tasks import DB_CHANNEL_NAME, NodeClass, comp_tasks from .models.confirmations import ConfirmationAction, confirmations -from .models.groups import GroupTypeEnum, groups, user_to_groups +from .models.groups import GroupType, groups, user_to_groups from .models.products import products from .models.projects import ProjectType, projects from .models.projects_tags import projects_tags @@ -28,7 +28,7 @@ "DB_CHANNEL_NAME", "group_classifiers", "groups", - "GroupTypeEnum", + "GroupType", "NodeClass", "products", "projects", diff --git a/packages/postgres-database/tests/conftest.py b/packages/postgres-database/tests/conftest.py index a446120e344..feb8bfaae97 100644 --- a/packages/postgres-database/tests/conftest.py +++ b/packages/postgres-database/tests/conftest.py @@ -33,7 +33,7 @@ ProjectNodesRepo, ) from simcore_postgres_database.webserver_models import ( - GroupTypeEnum, + GroupType, groups, user_to_groups, users, @@ -237,7 +237,7 @@ def create_fake_group( async def _creator(conn: SAConnection, **overrides) -> RowProxy: if "type" not in overrides: - overrides["type"] = GroupTypeEnum.STANDARD + overrides["type"] = GroupType.STANDARD result: ResultProxy = await conn.execute( groups.insert() .values(**random_group(**overrides)) @@ -281,7 +281,7 @@ async def _creator(conn, group: RowProxy | None = None, **overrides) -> RowProxy created_ids.append(user.id) if group: - assert group.type == GroupTypeEnum.STANDARD.name + assert group.type == GroupType.STANDARD.name result = await conn.execute( user_to_groups.insert().values(uid=user.id, gid=group.gid) ) diff --git a/packages/postgres-database/tests/products/test_utils_products.py b/packages/postgres-database/tests/products/test_utils_products.py index f2557037a95..a1b84fe96dd 100644 --- a/packages/postgres-database/tests/products/test_utils_products.py +++ b/packages/postgres-database/tests/products/test_utils_products.py @@ -10,7 +10,7 @@ import pytest import sqlalchemy as sa from aiopg.sa.engine import Engine -from simcore_postgres_database.models.groups import GroupTypeEnum, groups +from simcore_postgres_database.models.groups import GroupType, groups from simcore_postgres_database.models.products import products from simcore_postgres_database.utils_products import ( get_default_product_name, @@ -61,7 +61,7 @@ async def test_get_or_create_group_product( product_group = await result.first() # check product's group - assert product_group.type == GroupTypeEnum.STANDARD + assert product_group.type == GroupType.STANDARD assert product_group.name == product_row.name assert product_group.description == f"{product_row.name} product group" diff --git a/packages/postgres-database/tests/test_models_groups.py b/packages/postgres-database/tests/test_models_groups.py index 95c9242e840..649e2111867 100644 --- a/packages/postgres-database/tests/test_models_groups.py +++ b/packages/postgres-database/tests/test_models_groups.py @@ -16,7 +16,7 @@ from pytest_simcore.helpers.faker_factories import random_user from simcore_postgres_database.models.base import metadata from simcore_postgres_database.webserver_models import ( - GroupTypeEnum, + GroupType, groups, user_to_groups, users, @@ -74,7 +74,7 @@ async def test_all_group( assert groups_count == 1 result = await connection.execute( - groups.select().where(groups.c.type == GroupTypeEnum.EVERYONE) + groups.select().where(groups.c.type == GroupType.EVERYONE) ) all_group_gid = (await result.fetchone()).gid assert all_group_gid == 1 # it's the first group so it gets a 1 @@ -108,7 +108,7 @@ async def test_all_group( groups_count = await connection.scalar(select(func.count()).select_from(groups)) assert groups_count == 1 result = await connection.execute( - groups.select().where(groups.c.type == GroupTypeEnum.EVERYONE) + groups.select().where(groups.c.type == GroupType.EVERYONE) ) all_group_gid = (await result.fetchone()).gid assert all_group_gid == 1 # it's the first group so it gets a 1 @@ -130,7 +130,7 @@ async def test_own_group( # now check there is a primary group result = await connection.execute( - groups.select().where(groups.c.type == GroupTypeEnum.PRIMARY) + groups.select().where(groups.c.type == GroupType.PRIMARY) ) primary_group: RowProxy = await result.fetchone() assert primary_group.gid == user.primary_gid diff --git a/packages/postgres-database/tests/test_utils_groups_extra_properties.py b/packages/postgres-database/tests/test_utils_groups_extra_properties.py index bad39c75d5f..fafc97d1551 100644 --- a/packages/postgres-database/tests/test_utils_groups_extra_properties.py +++ b/packages/postgres-database/tests/test_utils_groups_extra_properties.py @@ -11,11 +11,7 @@ import sqlalchemy from aiopg.sa.result import RowProxy from faker import Faker -from simcore_postgres_database.models.groups import ( - GroupTypeEnum, - groups, - user_to_groups, -) +from simcore_postgres_database.models.groups import GroupType, groups, user_to_groups from simcore_postgres_database.models.groups_extra_properties import ( groups_extra_properties, ) @@ -108,7 +104,7 @@ async def test_get( @pytest.fixture async def everyone_group_id(connection: aiopg.sa.connection.SAConnection) -> int: result = await connection.scalar( - sqlalchemy.select(groups.c.gid).where(groups.c.type == GroupTypeEnum.EVERYONE) + sqlalchemy.select(groups.c.gid).where(groups.c.type == GroupType.EVERYONE) ) assert result return result diff --git a/packages/postgres-database/tests/test_utils_services.py b/packages/postgres-database/tests/test_utils_services.py index 5e2866cf6c3..70b102fea70 100644 --- a/packages/postgres-database/tests/test_utils_services.py +++ b/packages/postgres-database/tests/test_utils_services.py @@ -10,7 +10,7 @@ import sqlalchemy as sa from faker import Faker from pytest_simcore.helpers.faker_factories import random_group -from simcore_postgres_database.models.groups import GroupTypeEnum, groups +from simcore_postgres_database.models.groups import GroupType, groups from simcore_postgres_database.models.products import products from simcore_postgres_database.models.services import ( services_access_rights, @@ -165,12 +165,12 @@ def services_fixture(faker: Faker, pg_sa_engine: sa.engine.Engine) -> ServicesFi # GROUPS product_gid = conn.execute( groups.insert() - .values(**random_group(type=GroupTypeEnum.STANDARD, name="osparc group")) + .values(**random_group(type=GroupType.STANDARD, name="osparc group")) .returning(groups.c.gid) ).scalar() everyone_gid = conn.execute( - sa.select(groups.c.gid).where(groups.c.type == GroupTypeEnum.EVERYONE) + sa.select(groups.c.gid).where(groups.c.type == GroupType.EVERYONE) ).scalar() assert product_gid != everyone_gid diff --git a/packages/pytest-simcore/src/pytest_simcore/helpers/faker_factories.py b/packages/pytest-simcore/src/pytest_simcore/helpers/faker_factories.py index eee0c78a3c1..d4418a5ef81 100644 --- a/packages/pytest-simcore/src/pytest_simcore/helpers/faker_factories.py +++ b/packages/pytest-simcore/src/pytest_simcore/helpers/faker_factories.py @@ -142,12 +142,12 @@ def random_project(fake: Faker = DEFAULT_FAKER, **overrides) -> dict[str, Any]: def random_group(fake: Faker = DEFAULT_FAKER, **overrides) -> dict[str, Any]: from simcore_postgres_database.models.groups import groups - from simcore_postgres_database.webserver_models import GroupTypeEnum + from simcore_postgres_database.webserver_models import GroupType data = { "name": fake.company(), "description": fake.text(), - "type": GroupTypeEnum.STANDARD.name, + "type": GroupType.STANDARD.name, } assert set(data.keys()).issubset({c.name for c in groups.columns}) # nosec diff --git a/services/api-server/src/simcore_service_api_server/db/tables.py b/services/api-server/src/simcore_service_api_server/db/tables.py index 34bec9bf785..e07cfdb3792 100644 --- a/services/api-server/src/simcore_service_api_server/db/tables.py +++ b/services/api-server/src/simcore_service_api_server/db/tables.py @@ -1,16 +1,12 @@ from simcore_postgres_database.models.api_keys import api_keys from simcore_postgres_database.models.base import metadata -from simcore_postgres_database.models.groups import ( - GroupTypeEnum, - groups, - user_to_groups, -) +from simcore_postgres_database.models.groups import GroupType, groups, user_to_groups from simcore_postgres_database.models.users import UserRole, UserStatus, users __all__: tuple[str, ...] = ( "api_keys", "groups", - "GroupTypeEnum", + "GroupType", "metadata", "user_to_groups", "UserRole", diff --git a/services/catalog/src/simcore_service_catalog/db/repositories/groups.py b/services/catalog/src/simcore_service_catalog/db/repositories/groups.py index c491e3eb208..d7061947a10 100644 --- a/services/catalog/src/simcore_service_catalog/db/repositories/groups.py +++ b/services/catalog/src/simcore_service_catalog/db/repositories/groups.py @@ -7,7 +7,7 @@ from pydantic.types import PositiveInt from ...exceptions.errors import UninitializedGroupError -from ..tables import GroupTypeEnum, groups, user_to_groups, users +from ..tables import GroupType, groups, user_to_groups, users from ._base import BaseRepository @@ -30,12 +30,12 @@ async def list_user_groups(self, user_id: int) -> list[GroupAtDB]: async def get_everyone_group(self) -> GroupAtDB: async with self.db_engine.connect() as conn: result = await conn.execute( - sa.select(groups).where(groups.c.type == GroupTypeEnum.EVERYONE) + sa.select(groups).where(groups.c.type == GroupType.EVERYONE) ) row = result.first() if not row: raise UninitializedGroupError( - group=GroupTypeEnum.EVERYONE, repo_cls=GroupsRepository + group=GroupType.EVERYONE, repo_cls=GroupsRepository ) return GroupAtDB.model_validate(row) diff --git a/services/catalog/src/simcore_service_catalog/db/repositories/services.py b/services/catalog/src/simcore_service_catalog/db/repositories/services.py index a977cf612bc..7cb1b72e333 100644 --- a/services/catalog/src/simcore_service_catalog/db/repositories/services.py +++ b/services/catalog/src/simcore_service_catalog/db/repositories/services.py @@ -10,7 +10,7 @@ from models_library.api_schemas_catalog.services_specifications import ( ServiceSpecifications, ) -from models_library.groups import GroupAtDB, GroupID, GroupTypeEnum +from models_library.groups import GroupAtDB, GroupID, GroupType from models_library.products import ProductName from models_library.services import ServiceKey, ServiceVersion from models_library.users import UserID @@ -597,16 +597,16 @@ async def get_service_specifications( continue # filter by group type group = gid_to_group_map[row.gid] - if (group.group_type == GroupTypeEnum.STANDARD) and _is_newer( + if (group.group_type == GroupType.STANDARD) and _is_newer( teams_specs.get(db_service_spec.gid), db_service_spec, ): teams_specs[db_service_spec.gid] = db_service_spec - elif (group.group_type == GroupTypeEnum.EVERYONE) and _is_newer( + elif (group.group_type == GroupType.EVERYONE) and _is_newer( everyone_specs, db_service_spec ): everyone_specs = db_service_spec - elif (group.group_type == GroupTypeEnum.PRIMARY) and _is_newer( + elif (group.group_type == GroupType.PRIMARY) and _is_newer( primary_specs, db_service_spec ): primary_specs = db_service_spec diff --git a/services/catalog/src/simcore_service_catalog/db/tables.py b/services/catalog/src/simcore_service_catalog/db/tables.py index fa0413d2812..aaff065fcf7 100644 --- a/services/catalog/src/simcore_service_catalog/db/tables.py +++ b/services/catalog/src/simcore_service_catalog/db/tables.py @@ -1,8 +1,4 @@ -from simcore_postgres_database.models.groups import ( - GroupTypeEnum, - groups, - user_to_groups, -) +from simcore_postgres_database.models.groups import GroupType, groups, user_to_groups from simcore_postgres_database.models.projects import ProjectType, projects from simcore_postgres_database.models.services import ( services_access_rights, @@ -18,7 +14,7 @@ __all__ = ( "groups", - "GroupTypeEnum", + "GroupType", "projects", "ProjectType", "services_access_rights", diff --git a/services/web/server/src/simcore_service_webserver/db/models.py b/services/web/server/src/simcore_service_webserver/db/models.py index f4a3a819799..0cbfaa7638c 100644 --- a/services/web/server/src/simcore_service_webserver/db/models.py +++ b/services/web/server/src/simcore_service_webserver/db/models.py @@ -4,7 +4,7 @@ from simcore_postgres_database.models.base import metadata from simcore_postgres_database.webserver_models import ( ConfirmationAction, - GroupTypeEnum, + GroupType, UserRole, UserStatus, api_keys, @@ -28,7 +28,7 @@ "confirmations", "group_classifiers", "groups", - "GroupTypeEnum", + "GroupType", "metadata", "products", "projects", 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 a91849a4645..a2108766786 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 @@ -2,7 +2,7 @@ import asyncpg.exceptions from aiohttp import web -from models_library.groups import Group, GroupID, GroupTypeEnum +from models_library.groups import Group, GroupID, GroupType from models_library.projects import ProjectID from models_library.users import UserID from simcore_postgres_database.errors import DatabaseError @@ -86,9 +86,9 @@ async def get_new_project_owner_gid( if access_rights[other_gid]["write"] is not True: continue - if group.group_type == GroupTypeEnum.STANDARD: + if group.group_type == GroupType.STANDARD: standard_groups[other_gid] = access_rights[other_gid] - elif group.group_type == GroupTypeEnum.PRIMARY: + elif group.group_type == GroupType.PRIMARY: primary_groups[other_gid] = access_rights[other_gid] _logger.debug( diff --git a/services/web/server/src/simcore_service_webserver/groups/_groups_db.py b/services/web/server/src/simcore_service_webserver/groups/_groups_db.py index 666b40823ab..aedc78676d3 100644 --- a/services/web/server/src/simcore_service_webserver/groups/_groups_db.py +++ b/services/web/server/src/simcore_service_webserver/groups/_groups_db.py @@ -3,6 +3,7 @@ import sqlalchemy as sa from aiohttp import web +from common_library.groups_enums import GroupType from models_library.basic_types import IDStr from models_library.groups import ( AccessRightsDict, @@ -16,7 +17,6 @@ ) from models_library.users import UserID from simcore_postgres_database.errors import UniqueViolation -from simcore_postgres_database.models.groups import GroupTypeEnum from simcore_postgres_database.utils_products import execute_get_or_create_product_group from simcore_postgres_database.utils_repos import ( pass_or_acquire_connection, @@ -27,7 +27,7 @@ from sqlalchemy.engine.row import Row from sqlalchemy.ext.asyncio import AsyncConnection -from ..db.models import GroupTypeEnum, groups, user_to_groups, users +from ..db.models import GroupType, groups, user_to_groups, users from ..db.plugin import get_asyncpg_engine from ..users.exceptions import UserNotFoundError from .exceptions import ( @@ -172,16 +172,16 @@ async def get_all_user_groups_with_read_access( async with pass_or_acquire_connection(get_asyncpg_engine(app), connection) as conn: result = await conn.stream(query) async for row in result: - if row.type == GroupTypeEnum.EVERYONE: + if row.type == GroupType.EVERYONE: assert row.access_rights["read"] # nosec everyone_group = _to_group_info_tuple(row) - elif row.type == GroupTypeEnum.PRIMARY: + elif row.type == GroupType.PRIMARY: assert row.access_rights["read"] # nosec primary_group = _to_group_info_tuple(row) else: - assert row.type == GroupTypeEnum.STANDARD # nosec + assert row.type == GroupType.STANDARD # nosec # only add if user has read access if row.access_rights["read"]: standard_groups.append(_to_group_info_tuple(row)) @@ -311,7 +311,7 @@ async def create_standard_group( groups.insert() .values( **create.model_dump(mode="json", exclude_unset=True), - type=GroupTypeEnum.STANDARD, + type=GroupType.STANDARD, ) .returning(*_GROUP_COLUMNS) ) @@ -357,9 +357,7 @@ async def update_standard_group( # pylint: disable=no-value-for-parameter groups.update() .values(**values) - .where( - (groups.c.gid == row.gid) & (groups.c.type == GroupTypeEnum.STANDARD) - ) + .where((groups.c.gid == row.gid) & (groups.c.type == GroupType.STANDARD)) .returning(*_GROUP_COLUMNS) ) row = await result.fetchone() @@ -385,7 +383,7 @@ async def delete_standard_group( await conn.execute( # pylint: disable=no-value-for-parameter groups.delete().where( - (groups.c.gid == group.gid) & (groups.c.type == GroupTypeEnum.STANDARD) + (groups.c.gid == group.gid) & (groups.c.type == GroupType.STANDARD) ) ) diff --git a/services/web/server/src/simcore_service_webserver/projects/_db_utils.py b/services/web/server/src/simcore_service_webserver/projects/_db_utils.py index a4d7e6fdbdd..e36e2d455b3 100644 --- a/services/web/server/src/simcore_service_webserver/projects/_db_utils.py +++ b/services/web/server/src/simcore_service_webserver/projects/_db_utils.py @@ -22,7 +22,7 @@ from sqlalchemy.sql import select from sqlalchemy.sql.selectable import CompoundSelect, Select -from ..db.models import GroupTypeEnum, groups, projects_tags, user_to_groups, users +from ..db.models import GroupType, groups, projects_tags, user_to_groups, users from ..users.exceptions import UserNotFoundError from ..utils import format_datetime from .exceptions import ( @@ -112,7 +112,7 @@ class BaseProjectDB: @classmethod async def _get_everyone_group(cls, conn: SAConnection) -> RowProxy: result = await conn.execute( - sa.select(groups).where(groups.c.type == GroupTypeEnum.EVERYONE) + sa.select(groups).where(groups.c.type == GroupType.EVERYONE) ) row = await result.first() assert row is not None # nosec diff --git a/services/web/server/src/simcore_service_webserver/projects/_nodes_handlers.py b/services/web/server/src/simcore_service_webserver/projects/_nodes_handlers.py index c78ede85238..6670ed64442 100644 --- a/services/web/server/src/simcore_service_webserver/projects/_nodes_handlers.py +++ b/services/web/server/src/simcore_service_webserver/projects/_nodes_handlers.py @@ -25,7 +25,7 @@ NodePatch, NodeRetrieve, ) -from models_library.groups import EVERYONE_GROUP_ID, Group, GroupID, GroupTypeEnum +from models_library.groups import EVERYONE_GROUP_ID, Group, GroupID, GroupType from models_library.projects import Project, ProjectID from models_library.projects_nodes_io import NodeID, NodeIDStr from models_library.services import ServiceKeyVersion @@ -566,7 +566,7 @@ async def get_project_services_access_for_gid( raise GroupNotFoundError(gid=query_params.for_gid) # Update groups to compare based on the type of sharing group - if _sharing_with_group.group_type == GroupTypeEnum.PRIMARY: + if _sharing_with_group.group_type == GroupType.PRIMARY: _user_id = await get_user_id_from_gid( app=request.app, primary_gid=query_params.for_gid ) @@ -575,7 +575,7 @@ async def get_project_services_access_for_gid( ) groups_to_compare.update(set(user_groups_ids)) groups_to_compare.add(query_params.for_gid) - elif _sharing_with_group.group_type == GroupTypeEnum.STANDARD: + elif _sharing_with_group.group_type == GroupType.STANDARD: groups_to_compare = {query_params.for_gid} # Initialize a list for inaccessible services diff --git a/services/web/server/src/simcore_service_webserver/users/api.py b/services/web/server/src/simcore_service_webserver/users/api.py index 944e703ec98..1c1d217a28e 100644 --- a/services/web/server/src/simcore_service_webserver/users/api.py +++ b/services/web/server/src/simcore_service_webserver/users/api.py @@ -24,11 +24,7 @@ from models_library.products import ProductName from models_library.users import UserID from pydantic import EmailStr, TypeAdapter, ValidationError -from simcore_postgres_database.models.groups import ( - GroupTypeEnum, - groups, - user_to_groups, -) +from simcore_postgres_database.models.groups import GroupType, groups, user_to_groups from simcore_postgres_database.models.users import UserRole, users from simcore_postgres_database.utils_groups_extra_properties import ( GroupExtraPropertiesNotFoundError, @@ -125,13 +121,13 @@ async def get_user_profile( } assert user_profile["id"] == user_id # nosec - if row.groups_type == GroupTypeEnum.EVERYONE: + if row.groups_type == GroupType.EVERYONE: everyone_group = _convert_groups_db_to_schema( row, prefix="groups_", accessRights=row["user_to_groups_access_rights"], ) - elif row.groups_type == GroupTypeEnum.PRIMARY: + elif row.groups_type == GroupType.PRIMARY: user_primary_group = _convert_groups_db_to_schema( row, prefix="groups_", diff --git a/services/web/server/tests/unit/isolated/test_groups_models.py b/services/web/server/tests/unit/isolated/test_groups_models.py index 4972d415bb4..2e5201422e9 100644 --- a/services/web/server/tests/unit/isolated/test_groups_models.py +++ b/services/web/server/tests/unit/isolated/test_groups_models.py @@ -12,7 +12,7 @@ AccessRightsDict, Group, GroupMember, - GroupTypeEnum, + GroupType, StandardGroupCreate, StandardGroupUpdate, ) @@ -54,7 +54,7 @@ def test_output_schemas_from_models(faker: Faker): gid=1, name=faker.word(), description=faker.sentence(), - group_type=GroupTypeEnum.STANDARD, + group_type=GroupType.STANDARD, thumbnail=None, ) output_schema = GroupGet.from_model(