diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index 45ce05ba8..6c8cbbb31 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -20,7 +20,6 @@ jobs: CLOUDSDK_CORE_DISABLE_PROMPTS: 1 # used for generating API SM_DOCKER: australia-southeast1-docker.pkg.dev/sample-metadata/images/server:${{ github.sha }} - SM_API_DOCKER: australia-southeast1-docker.pkg.dev/cpg-common/images/sm-api defaults: run: shell: bash -eo pipefail -l {0} diff --git a/api/routes/project.py b/api/routes/project.py index 022244287..5771dfc91 100644 --- a/api/routes/project.py +++ b/api/routes/project.py @@ -30,7 +30,7 @@ async def get_my_projects(connection=get_projectless_db_connection): async def create_project( name: str, dataset: str, - create_test_project: bool = True, + create_test_project: bool = False, connection: Connection = get_projectless_db_connection, ) -> int: """ diff --git a/db/python/tables/project.py b/db/python/tables/project.py index 3a44d2a5c..8ea09105a 100644 --- a/db/python/tables/project.py +++ b/db/python/tables/project.py @@ -125,7 +125,9 @@ async def get_projects_accessible_by_user( relevant_project_ids = await self.connection.fetch_all( _query, {'author': author} ) - projects = await self._get_projects_by_ids(relevant_project_ids) + projects = await self._get_projects_by_ids( + [p['id'] for p in relevant_project_ids] + ) return projects @@ -571,21 +573,20 @@ async def set_group_members(self, group_id: int, members: list[str], author: str """ Set group members for a group (by id) """ - async with self.connection.transaction(): - await self.connection.execute( - """ - DELETE FROM group_member - WHERE group_id = :group_id - """, - {'group_id': group_id}, - ) - await self.connection.execute_many( - """ - INSERT INTO group_member (group_id, member, author) - VALUES (:group_id, :member, :author) - """, - [ - {'group_id': group_id, 'member': member, 'author': author} - for member in members - ], - ) + await self.connection.execute( + """ + DELETE FROM group_member + WHERE group_id = :group_id + """, + {'group_id': group_id}, + ) + await self.connection.execute_many( + """ + INSERT INTO group_member (group_id, member, author) + VALUES (:group_id, :member, :author) + """, + [ + {'group_id': group_id, 'member': member, 'author': author} + for member in members + ], + ) diff --git a/test/test_project_groups.py b/test/test_project_groups.py index 9d0acfa0c..0d135e37f 100644 --- a/test/test_project_groups.py +++ b/test/test_project_groups.py @@ -198,3 +198,28 @@ async def test_project_access_success(self): user=self.author, project_name=g, readonly=True ) self.assertEqual(pid, project_for_name.id) + + @run_as_sync + async def test_get_my_projects(self): + """ + Test that a user with permission only has MY projects + """ + await self._add_group_member_direct(GROUP_NAME_PROJECT_CREATORS) + await self._add_group_member_direct(GROUP_NAME_MEMBERS_ADMIN) + + g = str(uuid.uuid4()) + + pid = await self.pttable.create_project(g, g, self.author) + + await self.pttable.set_group_members( + group_name=self.pttable.get_project_group_name(g, readonly=True), + members=[self.author], + author=self.author, + ) + + projects = await self.pttable.get_projects_accessible_by_user( + author=self.author + ) + + self.assertEqual(1, len(projects)) + self.assertEqual(pid, projects[0].id)