From 811c57dbbdca1d74c7cc6fc786b403e19b26f223 Mon Sep 17 00:00:00 2001 From: odrling Date: Wed, 24 Jul 2024 01:31:12 +0200 Subject: [PATCH 1/2] Serialize work type ID Serialize the ID of work types to be able to use the `/api/library/work-types/{id}` route, otherwise the ID has to be guessed. Found while trying to implement feeding in https://github.com/Japan7/karaberus/issues/38 --- dakara_server/library/serializers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dakara_server/library/serializers.py b/dakara_server/library/serializers.py index abc80af9..fd7c1dcb 100644 --- a/dakara_server/library/serializers.py +++ b/dakara_server/library/serializers.py @@ -115,7 +115,7 @@ class WorkTypeSerializer(serializers.ModelSerializer): class Meta: model = WorkType - fields = ("name", "name_plural", "query_name", "icon_name") + fields = ("id", "name", "name_plural", "query_name", "icon_name") @staticmethod def set(work_type_data): From e5ad313ae8a8f00fb94d95f0eb5fdaa705e7a54c Mon Sep 17 00:00:00 2001 From: odrling Date: Sun, 28 Jul 2024 23:27:42 +0200 Subject: [PATCH 2/2] check expected work type IDs in tests --- dakara_server/library/tests/base_test.py | 1 + 1 file changed, 1 insertion(+) diff --git a/dakara_server/library/tests/base_test.py b/dakara_server/library/tests/base_test.py index b12d2121..49596682 100644 --- a/dakara_server/library/tests/base_test.py +++ b/dakara_server/library/tests/base_test.py @@ -131,6 +131,7 @@ def check_work_json(self, json, expected_work): def check_work_type_json(self, json, expected_work_type): """Method to test an representation against the expected work type.""" + self.assertEqual(json["id"], expected_work_type.id) self.assertEqual(json["name"], expected_work_type.name) self.assertEqual(json["name_plural"], expected_work_type.name_plural) self.assertEqual(json["query_name"], expected_work_type.query_name)