diff --git a/src/backend/marsha/deposit/serializers.py b/src/backend/marsha/deposit/serializers.py
index ad4e895928..3f0f8b2773 100644
--- a/src/backend/marsha/deposit/serializers.py
+++ b/src/backend/marsha/deposit/serializers.py
@@ -33,7 +33,7 @@ class Meta: # noqa
"filename",
"author_name",
"id",
- "file_depository",
+ "file_depository_id",
"read",
"url",
"uploaded_on",
@@ -42,7 +42,7 @@ class Meta: # noqa
)
read_only_fields = (
"id",
- "file_depository",
+ "file_depository_id",
"url",
"uploaded_on",
"upload_state",
@@ -52,7 +52,7 @@ class Meta: # noqa
# filename = serializers.SerializerMethodField()
url = serializers.SerializerMethodField()
# Make sure file depository UUID is converted to a string during serialization
- file_depository = serializers.PrimaryKeyRelatedField(
+ file_depository_id = serializers.PrimaryKeyRelatedField(
read_only=True, pk_field=serializers.CharField()
)
diff --git a/src/backend/marsha/deposit/tests/api/depositedfiles/test_create.py b/src/backend/marsha/deposit/tests/api/depositedfiles/test_create.py
index 3146b8c950..ada6fad42b 100644
--- a/src/backend/marsha/deposit/tests/api/depositedfiles/test_create.py
+++ b/src/backend/marsha/deposit/tests/api/depositedfiles/test_create.py
@@ -62,7 +62,7 @@ def test_api_deposited_file_create_student_with_user_fullname(self):
response.json(),
{
"author_name": jwt_token.get("user").get("user_fullname"),
- "file_depository": str(file_depository.id),
+ "file_depository_id": str(file_depository.id),
"filename": "test.pdf",
"id": str(DepositedFile.objects.first().id),
"read": False,
@@ -100,7 +100,7 @@ def test_api_deposited_file_create_student_with_username(self):
{
"size": 123,
"filename": "test.pdf",
- "file_depository": str(file_depository.id),
+ "file_depository_id": str(file_depository.id),
}
),
HTTP_AUTHORIZATION=f"Bearer {jwt_token}",
@@ -134,7 +134,7 @@ def test_api_deposited_file_create_student_without_username(self):
{
"size": 123,
"filename": "test.pdf",
- "file_depository": str(file_depository.id),
+ "file_depository_id": str(file_depository.id),
}
),
HTTP_AUTHORIZATION=f"Bearer {jwt_token}",
@@ -164,7 +164,7 @@ def test_api_deposited_file_create_user_access_token(self):
{
"size": 123,
"filename": "test.pdf",
- "file_depository": str(file_depository.id),
+ "file_depository_id": str(file_depository.id),
}
),
)
@@ -175,7 +175,7 @@ def test_api_deposited_file_create_user_access_token(self):
response.json(),
{
"author_name": organization_access.user.username,
- "file_depository": str(file_depository.id),
+ "file_depository_id": str(file_depository.id),
"filename": "test.pdf",
"id": str(DepositedFile.objects.first().id),
"read": False,
@@ -208,7 +208,7 @@ def test_api_deposited_file_create_user_access_token_organization_admin(self):
{
"size": 123,
"filename": "test.pdf",
- "file_depository": str(file_depository.id),
+ "file_depository_id": str(file_depository.id),
}
),
)
@@ -219,7 +219,7 @@ def test_api_deposited_file_create_user_access_token_organization_admin(self):
response.json(),
{
"author_name": organization_access.user.username,
- "file_depository": str(file_depository.id),
+ "file_depository_id": str(file_depository.id),
"filename": "test.pdf",
"id": str(DepositedFile.objects.first().id),
"read": False,
@@ -251,7 +251,7 @@ def test_api_deposited_file_create_user_access_token_playlist_admin(self):
{
"size": 123,
"filename": "test.pdf",
- "file_depository": str(file_depository.id),
+ "file_depository_id": str(file_depository.id),
}
),
)
@@ -262,7 +262,7 @@ def test_api_deposited_file_create_user_access_token_playlist_admin(self):
response.json(),
{
"author_name": playlist_access.user.username,
- "file_depository": str(file_depository.id),
+ "file_depository_id": str(file_depository.id),
"filename": "test.pdf",
"id": str(DepositedFile.objects.first().id),
"read": False,
diff --git a/src/backend/marsha/deposit/tests/api/depositedfiles/test_update.py b/src/backend/marsha/deposit/tests/api/depositedfiles/test_update.py
index 6ecc5815b9..1571bb8e36 100644
--- a/src/backend/marsha/deposit/tests/api/depositedfiles/test_update.py
+++ b/src/backend/marsha/deposit/tests/api/depositedfiles/test_update.py
@@ -70,7 +70,7 @@ def test_api_deposited_file_update_instructor(self):
response.json(),
{
"author_name": deposited_file.author_name,
- "file_depository": str(deposited_file.file_depository.id),
+ "file_depository_id": str(deposited_file.file_depository.id),
"filename": deposited_file.filename,
"id": str(deposited_file.id),
"read": True,
@@ -121,7 +121,7 @@ def test_api_deposited_file_update_user_access_token_organization_admin(self):
response.json(),
{
"author_name": deposited_file.author_name,
- "file_depository": str(deposited_file.file_depository.id),
+ "file_depository_id": str(deposited_file.file_depository.id),
"filename": deposited_file.filename,
"id": str(deposited_file.id),
"read": True,
@@ -156,7 +156,7 @@ def test_api_deposited_file_update_user_access_token_playlist_admin(self):
response.json(),
{
"author_name": deposited_file.author_name,
- "file_depository": str(deposited_file.file_depository.id),
+ "file_depository_id": str(deposited_file.file_depository.id),
"filename": deposited_file.filename,
"id": str(deposited_file.id),
"read": True,
diff --git a/src/backend/marsha/deposit/tests/api/filedepositories/test_depositedfiles.py b/src/backend/marsha/deposit/tests/api/filedepositories/test_depositedfiles.py
index fbf8637f6d..ccd9ddc59b 100644
--- a/src/backend/marsha/deposit/tests/api/filedepositories/test_depositedfiles.py
+++ b/src/backend/marsha/deposit/tests/api/filedepositories/test_depositedfiles.py
@@ -71,7 +71,7 @@ def test_api_file_depository_list_deposited_files_student(self):
"results": [
{
"author_name": owned_deposited_file.author_name,
- "file_depository": str(file_depository.id),
+ "file_depository_id": str(file_depository.id),
"filename": owned_deposited_file.filename,
"id": str(owned_deposited_file.id),
"read": False,
@@ -107,7 +107,7 @@ def test_api_file_depository_list_deposited_files_instructor(self):
"results": [
{
"author_name": deposited_files[2].author_name,
- "file_depository": str(file_depository.id),
+ "file_depository_id": str(file_depository.id),
"filename": deposited_files[2].filename,
"id": str(deposited_files[2].id),
"read": False,
@@ -118,7 +118,7 @@ def test_api_file_depository_list_deposited_files_instructor(self):
},
{
"author_name": deposited_files[1].author_name,
- "file_depository": str(file_depository.id),
+ "file_depository_id": str(file_depository.id),
"filename": deposited_files[1].filename,
"id": str(deposited_files[1].id),
"read": False,
@@ -156,7 +156,7 @@ def test_api_file_depository_list_deposited_files_instructor_filtered(self):
"results": [
{
"author_name": deposited_files_new[1].author_name,
- "file_depository": str(file_depository.id),
+ "file_depository_id": str(file_depository.id),
"filename": deposited_files_new[1].filename,
"id": str(deposited_files_new[1].id),
"read": False,
@@ -167,7 +167,7 @@ def test_api_file_depository_list_deposited_files_instructor_filtered(self):
},
{
"author_name": deposited_files_new[0].author_name,
- "file_depository": str(file_depository.id),
+ "file_depository_id": str(file_depository.id),
"filename": deposited_files_new[0].filename,
"id": str(deposited_files_new[0].id),
"read": False,
@@ -178,7 +178,7 @@ def test_api_file_depository_list_deposited_files_instructor_filtered(self):
},
{
"author_name": deposited_files_read[1].author_name,
- "file_depository": str(file_depository.id),
+ "file_depository_id": str(file_depository.id),
"filename": deposited_files_read[1].filename,
"id": str(deposited_files_read[1].id),
"read": True,
@@ -189,7 +189,7 @@ def test_api_file_depository_list_deposited_files_instructor_filtered(self):
},
{
"author_name": deposited_files_read[0].author_name,
- "file_depository": str(file_depository.id),
+ "file_depository_id": str(file_depository.id),
"filename": deposited_files_read[0].filename,
"id": str(deposited_files_read[0].id),
"read": True,
@@ -216,7 +216,7 @@ def test_api_file_depository_list_deposited_files_instructor_filtered(self):
"results": [
{
"author_name": deposited_files_read[1].author_name,
- "file_depository": str(file_depository.id),
+ "file_depository_id": str(file_depository.id),
"filename": deposited_files_read[1].filename,
"id": str(deposited_files_read[1].id),
"read": True,
@@ -227,7 +227,7 @@ def test_api_file_depository_list_deposited_files_instructor_filtered(self):
},
{
"author_name": deposited_files_read[0].author_name,
- "file_depository": str(file_depository.id),
+ "file_depository_id": str(file_depository.id),
"filename": deposited_files_read[0].filename,
"id": str(deposited_files_read[0].id),
"read": True,
@@ -254,7 +254,7 @@ def test_api_file_depository_list_deposited_files_instructor_filtered(self):
"results": [
{
"author_name": deposited_files_new[1].author_name,
- "file_depository": str(file_depository.id),
+ "file_depository_id": str(file_depository.id),
"filename": deposited_files_new[1].filename,
"id": str(deposited_files_new[1].id),
"read": False,
@@ -265,7 +265,7 @@ def test_api_file_depository_list_deposited_files_instructor_filtered(self):
},
{
"author_name": deposited_files_new[0].author_name,
- "file_depository": str(file_depository.id),
+ "file_depository_id": str(file_depository.id),
"filename": deposited_files_new[0].filename,
"id": str(deposited_files_new[0].id),
"read": False,
@@ -323,7 +323,7 @@ def test_api_file_depository_list_deposited_files_instructor_signed_urls(self):
"results": [
{
"author_name": deposited_files[2].author_name,
- "file_depository": str(file_depository.id),
+ "file_depository_id": str(file_depository.id),
"filename": deposited_files[2].filename,
"id": str(deposited_files[2].id),
"read": False,
@@ -339,7 +339,7 @@ def test_api_file_depository_list_deposited_files_instructor_signed_urls(self):
},
{
"author_name": deposited_files[1].author_name,
- "file_depository": str(file_depository.id),
+ "file_depository_id": str(file_depository.id),
"filename": deposited_files[1].filename,
"id": str(deposited_files[1].id),
"read": False,
@@ -355,7 +355,7 @@ def test_api_file_depository_list_deposited_files_instructor_signed_urls(self):
},
{
"author_name": deposited_files[0].author_name,
- "file_depository": str(file_depository.id),
+ "file_depository_id": str(file_depository.id),
"filename": deposited_files[0].filename,
"id": str(deposited_files[0].id),
"read": False,
@@ -415,7 +415,7 @@ def test_api_file_depository_list_deposited_files_user_access_token_organization
"results": [
{
"author_name": deposited_files[2].author_name,
- "file_depository": str(file_depository.id),
+ "file_depository_id": str(file_depository.id),
"filename": deposited_files[2].filename,
"id": str(deposited_files[2].id),
"read": False,
@@ -426,7 +426,7 @@ def test_api_file_depository_list_deposited_files_user_access_token_organization
},
{
"author_name": deposited_files[1].author_name,
- "file_depository": str(file_depository.id),
+ "file_depository_id": str(file_depository.id),
"filename": deposited_files[1].filename,
"id": str(deposited_files[1].id),
"read": False,
@@ -466,7 +466,7 @@ def test_api_file_depository_list_deposited_files_user_access_token_playlist_adm
"results": [
{
"author_name": deposited_files[2].author_name,
- "file_depository": str(file_depository.id),
+ "file_depository_id": str(file_depository.id),
"filename": deposited_files[2].filename,
"id": str(deposited_files[2].id),
"read": False,
@@ -477,7 +477,7 @@ def test_api_file_depository_list_deposited_files_user_access_token_playlist_adm
},
{
"author_name": deposited_files[1].author_name,
- "file_depository": str(file_depository.id),
+ "file_depository_id": str(file_depository.id),
"filename": deposited_files[1].filename,
"id": str(deposited_files[1].id),
"read": False,
diff --git a/src/frontend/apps/lti_site/apps/deposit/components/Dashboard/DashboardInstructor/index.spec.tsx b/src/frontend/apps/lti_site/apps/deposit/components/Dashboard/DashboardInstructor/index.spec.tsx
index 76fbc92226..ba14326334 100644
--- a/src/frontend/apps/lti_site/apps/deposit/components/Dashboard/DashboardInstructor/index.spec.tsx
+++ b/src/frontend/apps/lti_site/apps/deposit/components/Dashboard/DashboardInstructor/index.spec.tsx
@@ -99,7 +99,7 @@ describe('', () => {
const depositedFiles: DepositedFile[] = [];
for (let i = 0; i < 40; i++) {
depositedFiles.push(
- depositedFileMockFactory({ file_depository: fileDepository }),
+ depositedFileMockFactory({ file_depository_id: fileDepository.id }),
);
}
const queryClient = new QueryClient();
@@ -170,7 +170,7 @@ describe('', () => {
const readStatus = read ? 'read' : 'new';
depositedFiles.push(
depositedFileMockFactory({
- file_depository: fileDepository,
+ file_depository_id: fileDepository.id,
filename: `file${i}_${readStatus}.txt`,
read,
}),
diff --git a/src/frontend/apps/lti_site/apps/deposit/components/Dashboard/DashboardStudent/UploadFiles/index.spec.tsx b/src/frontend/apps/lti_site/apps/deposit/components/Dashboard/DashboardStudent/UploadFiles/index.spec.tsx
index 28c004d4b2..9e9d804561 100644
--- a/src/frontend/apps/lti_site/apps/deposit/components/Dashboard/DashboardStudent/UploadFiles/index.spec.tsx
+++ b/src/frontend/apps/lti_site/apps/deposit/components/Dashboard/DashboardStudent/UploadFiles/index.spec.tsx
@@ -97,7 +97,7 @@ describe('', () => {
depositedFile.id,
file,
modelName.FileDepositories,
- depositedFile.file_depository.id,
+ depositedFile.file_depository_id,
);
});
diff --git a/src/frontend/apps/lti_site/apps/deposit/components/Dashboard/DashboardStudent/UploadFiles/index.tsx b/src/frontend/apps/lti_site/apps/deposit/components/Dashboard/DashboardStudent/UploadFiles/index.tsx
index 9a1ff67ad0..ca806e6bc8 100644
--- a/src/frontend/apps/lti_site/apps/deposit/components/Dashboard/DashboardStudent/UploadFiles/index.tsx
+++ b/src/frontend/apps/lti_site/apps/deposit/components/Dashboard/DashboardStudent/UploadFiles/index.tsx
@@ -102,7 +102,7 @@ export const UploadFiles = () => {
depositedFile.id,
file,
modelName.FileDepositories,
- depositedFile.file_depository.id,
+ depositedFile.file_depository_id,
);
refreshDepositedFiles();
} catch (error) {
diff --git a/src/frontend/apps/lti_site/apps/deposit/components/Dashboard/common/DepositedFileRow/index.spec.tsx b/src/frontend/apps/lti_site/apps/deposit/components/Dashboard/common/DepositedFileRow/index.spec.tsx
index 67310f3c49..f041fa8082 100644
--- a/src/frontend/apps/lti_site/apps/deposit/components/Dashboard/common/DepositedFileRow/index.spec.tsx
+++ b/src/frontend/apps/lti_site/apps/deposit/components/Dashboard/common/DepositedFileRow/index.spec.tsx
@@ -37,7 +37,7 @@ describe('', () => {
);
fetchMock.patch(
- `/api/filedepositories/${depositedFile.file_depository.id}/depositedfiles/${depositedFile.id}/`,
+ `/api/filedepositories/${depositedFile.file_depository_id}/depositedfiles/${depositedFile.id}/`,
{
...depositedFile,
read: true,
@@ -49,7 +49,7 @@ describe('', () => {
await waitFor(() =>
expect(fetchMock.lastCall()![0]).toEqual(
- `/api/filedepositories/${depositedFile.file_depository.id}/depositedfiles/${depositedFile.id}/`,
+ `/api/filedepositories/${depositedFile.file_depository_id}/depositedfiles/${depositedFile.id}/`,
),
);
expect(fetchMock.lastCall()![1]).toEqual({
diff --git a/src/frontend/apps/lti_site/apps/deposit/components/Dashboard/common/DepositedFileRow/index.tsx b/src/frontend/apps/lti_site/apps/deposit/components/Dashboard/common/DepositedFileRow/index.tsx
index 69e041a719..7324629cff 100644
--- a/src/frontend/apps/lti_site/apps/deposit/components/Dashboard/common/DepositedFileRow/index.tsx
+++ b/src/frontend/apps/lti_site/apps/deposit/components/Dashboard/common/DepositedFileRow/index.tsx
@@ -29,7 +29,7 @@ export const DepositedFileRow = ({ file }: DepositedFileProps) => {
const uploadedOnDate = uploadedOn ? uploadedOn.toFormat('dd/MM/yyyy') : null;
const uploadedOnTime = uploadedOn ? uploadedOn.toFormat('HH:mm') : null;
- const { mutate } = useUpdateDepositedFile(file.id, file.file_depository.id);
+ const { mutate } = useUpdateDepositedFile(file.id, file.file_depository_id);
const markFileAsRead = () => {
const callback = () => {
mutate(
diff --git a/src/frontend/apps/lti_site/apps/deposit/data/queries/index.spec.tsx b/src/frontend/apps/lti_site/apps/deposit/data/queries/index.spec.tsx
index 96f4edba77..f781983dc3 100644
--- a/src/frontend/apps/lti_site/apps/deposit/data/queries/index.spec.tsx
+++ b/src/frontend/apps/lti_site/apps/deposit/data/queries/index.spec.tsx
@@ -294,7 +294,7 @@ describe('queries', () => {
it('requests the first page of the resource list', async () => {
const fileDepository = fileDepositoryMockFactory();
const depositedFiles = Array(4).fill(
- depositedFileMockFactory({ file_depository: fileDepository }),
+ depositedFileMockFactory({ file_depository_id: fileDepository.id }),
);
fetchMock.mock(
`/api/filedepositories/${fileDepository.id}/depositedfiles/?limit=3`,
@@ -328,7 +328,7 @@ describe('queries', () => {
it('requests the second page of the resource list', async () => {
const fileDepository = fileDepositoryMockFactory();
const depositedFiles = Array(4).fill(
- depositedFileMockFactory({ file_depository: fileDepository }),
+ depositedFileMockFactory({ file_depository_id: fileDepository.id }),
);
fetchMock.mock(
`/api/filedepositories/${fileDepository.id}/depositedfiles/?limit=3&offset=3`,
@@ -362,7 +362,7 @@ describe('queries', () => {
it('fails to get the resource list', async () => {
const fileDepository = fileDepositoryMockFactory();
Array(4).fill(
- depositedFileMockFactory({ file_depository: fileDepository }),
+ depositedFileMockFactory({ file_depository_id: fileDepository.id }),
);
fetchMock.mock(
`/api/filedepositories/${fileDepository.id}/depositedfiles/?limit=3`,
@@ -398,7 +398,7 @@ describe('queries', () => {
it('updates the resource', async () => {
const depositedFile = depositedFileMockFactory();
fetchMock.patch(
- `/api/filedepositories/${depositedFile.file_depository.id}/depositedfiles/${depositedFile.id}/`,
+ `/api/filedepositories/${depositedFile.file_depository_id}/depositedfiles/${depositedFile.id}/`,
depositedFile,
);
@@ -406,7 +406,7 @@ describe('queries', () => {
() =>
useUpdateDepositedFile(
depositedFile.id,
- depositedFile.file_depository.id,
+ depositedFile.file_depository_id,
),
{
wrapper: WrapperReactQuery,
@@ -420,7 +420,7 @@ describe('queries', () => {
});
expect(fetchMock.lastCall()![0]).toEqual(
- `/api/filedepositories/${depositedFile.file_depository.id}/depositedfiles/${depositedFile.id}/`,
+ `/api/filedepositories/${depositedFile.file_depository_id}/depositedfiles/${depositedFile.id}/`,
);
expect(fetchMock.lastCall()![1]).toEqual({
headers: {
@@ -439,7 +439,7 @@ describe('queries', () => {
it('fails to update the resource', async () => {
const depositedFile = depositedFileMockFactory();
fetchMock.patch(
- `/api/filedepositories/${depositedFile.file_depository.id}/depositedfiles/${depositedFile.id}/`,
+ `/api/filedepositories/${depositedFile.file_depository_id}/depositedfiles/${depositedFile.id}/`,
400,
);
@@ -447,7 +447,7 @@ describe('queries', () => {
() =>
useUpdateDepositedFile(
depositedFile.id,
- depositedFile.file_depository.id,
+ depositedFile.file_depository_id,
),
{
wrapper: WrapperReactQuery,
@@ -461,7 +461,7 @@ describe('queries', () => {
});
expect(fetchMock.lastCall()![0]).toEqual(
- `/api/filedepositories/${depositedFile.file_depository.id}/depositedfiles/${depositedFile.id}/`,
+ `/api/filedepositories/${depositedFile.file_depository_id}/depositedfiles/${depositedFile.id}/`,
);
expect(fetchMock.lastCall()![1]).toEqual({
headers: {
diff --git a/src/frontend/apps/lti_site/apps/deposit/utils/tests/factories.ts b/src/frontend/apps/lti_site/apps/deposit/utils/tests/factories.ts
index 79542e84e1..2817894a5c 100644
--- a/src/frontend/apps/lti_site/apps/deposit/utils/tests/factories.ts
+++ b/src/frontend/apps/lti_site/apps/deposit/utils/tests/factories.ts
@@ -27,7 +27,7 @@ export const depositedFileMockFactory = (
): DepositedFile => {
return {
author_name: faker.name.firstName() + ' ' + faker.name.lastName(),
- file_depository: fileDepositoryMockFactory(),
+ file_depository_id: faker.datatype.uuid(),
filename: faker.system.fileName(),
size: faker.datatype.number().toString(),
id: faker.datatype.uuid(),
diff --git a/src/frontend/packages/lib_components/src/types/apps/deposit/models.ts b/src/frontend/packages/lib_components/src/types/apps/deposit/models.ts
index 341525a97c..6ec9a9352a 100644
--- a/src/frontend/packages/lib_components/src/types/apps/deposit/models.ts
+++ b/src/frontend/packages/lib_components/src/types/apps/deposit/models.ts
@@ -17,7 +17,7 @@ export interface FileDepository extends Resource {
export interface DepositedFile extends Resource {
author_name: string;
- file_depository: FileDepository;
+ file_depository_id: string;
filename: string;
size: string;
read: boolean;