fix: attribute duplicated project to the user who duplicated it

duplicate() kept the original author in created_by. The project list
filters on created_by, so a non-admin user could not see the copy they
just made. Pass the caller through both duplication paths, the same way
import already does since #3017.
This commit is contained in:
YueGuobin committed 2026-11-05 19:22:27 +08:00
1 parent 7230e86c15
commit 517b0b0d85
4 files changed
+39 -5

No files matched your search

@@ -526,6 +526,8 @@ class TestControllerProjectRoutes:
with open(os.path.join(project.path, "demo")) as f:
content = f.read()
assert content == "hello"
# the imported project is owned by the user who imported it
assert project.created_by == "admin"
async def test_import_with_project_name(
self, app: FastAPI, client: AsyncClient, tmpdir, controller: Controller
@@ -556,6 +558,8 @@ class TestControllerProjectRoutes:
)
assert response.status_code == status.HTTP_201_CREATED
assert response.json()["name"] == "hello"
# the duplicated project is owned by the user who duplicated it
assert response.json()["created_by"] == "admin"
async def test_lock_unlock(self, app: FastAPI, client: AsyncClient, project: Project, compute: Compute) -> None: