From 3cb43b02fff6428c9fab310053f5abbf6b587e55 Mon Sep 17 00:00:00 2001 From: shamoon <4887959+shamoon@users.noreply.github.com> Date: Sat, 25 Jan 2025 19:14:11 -0800 Subject: [PATCH] Dont make default version change --- docs/api.md | 5 ++++- src/documents/tests/test_api_custom_fields.py | 4 +++- src/paperless/settings.py | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/docs/api.md b/docs/api.md index 59f9d7efc..d02a5117c 100644 --- a/docs/api.md +++ b/docs/api.md @@ -577,4 +577,7 @@ Initial API version. #### Version 7 - The format of select type custom fields has changed to return the options - as an array of objects with `id` and `label` fields. + as an array of objects with `id` and `label` fields. When creating or + updating a custom field value of a document for a select type custom field, + the value should be the `id` of the option whereas previously was the index + of the option. diff --git a/src/documents/tests/test_api_custom_fields.py b/src/documents/tests/test_api_custom_fields.py index e4a261ff7..0479c103a 100644 --- a/src/documents/tests/test_api_custom_fields.py +++ b/src/documents/tests/test_api_custom_fields.py @@ -151,7 +151,6 @@ class TestCustomFieldsAPI(DirectoriesMixin, APITestCase): def test_custom_field_select_unique_ids(self): """ GIVEN: - - Nothing - Existing custom field WHEN: - API request to create custom field with select options without id @@ -172,6 +171,7 @@ class TestCustomFieldsAPI(DirectoriesMixin, APITestCase): }, }, ), + headers={"Accept": "application/json; version=7"}, content_type="application/json", ) self.assertEqual(resp.status_code, status.HTTP_201_CREATED) @@ -197,6 +197,7 @@ class TestCustomFieldsAPI(DirectoriesMixin, APITestCase): }, }, ), + headers={"Accept": "application/json; version=7"}, content_type="application/json", ) self.assertEqual(resp.status_code, status.HTTP_200_OK) @@ -560,6 +561,7 @@ class TestCustomFieldsAPI(DirectoriesMixin, APITestCase): }, ], }, + headers={"Accept": "application/json; version=7"}, format="json", ) diff --git a/src/paperless/settings.py b/src/paperless/settings.py index dcfdc020d..53a6902d5 100644 --- a/src/paperless/settings.py +++ b/src/paperless/settings.py @@ -341,7 +341,7 @@ REST_FRAMEWORK = { "rest_framework.authentication.SessionAuthentication", ], "DEFAULT_VERSIONING_CLASS": "rest_framework.versioning.AcceptHeaderVersioning", - "DEFAULT_VERSION": "7", + "DEFAULT_VERSION": "1", # Make sure these are ordered and that the most recent version appears # last "ALLOWED_VERSIONS": ["1", "2", "3", "4", "5", "6", "7"],