From 3c4f475fba290d169722f275896596789c6ae51d Mon Sep 17 00:00:00 2001 From: denis_shtanskii Date: Mon, 4 Nov 2024 19:14:09 +0300 Subject: [PATCH] =?UTF-8?q?refactor:=20=D0=92=D0=B5=D1=80=D0=BD=D1=83?= =?UTF-8?q?=D0=BB=20id=20=D0=B4=D0=BB=D1=8F=20=D0=BD=D1=83=D0=B6=D1=8B?= =?UTF-8?q?=D1=85=20=D0=BF=D0=BE=D0=BB=D0=B5=D0=B9=20=D0=B4=D0=BB=D1=8F=20?= =?UTF-8?q?=D1=84=D1=80=D0=BE=D0=BD=D1=82=D0=BE=D0=B2=20=D0=B8=20=D0=B8?= =?UTF-8?q?=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=B8=D0=BB=20=D0=BE=D1=88=D0=B8?= =?UTF-8?q?=D0=B1=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/api/v1/general/serializers.py | 5 +---- src/backend/api/v1/projects/serializers.py | 5 ++--- src/backend/tests/projects/test_serializers.py | 1 + 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/backend/api/v1/general/serializers.py b/src/backend/api/v1/general/serializers.py index 52a91ef..824fc3c 100644 --- a/src/backend/api/v1/general/serializers.py +++ b/src/backend/api/v1/general/serializers.py @@ -29,10 +29,7 @@ class ProfessionSerializer(CustomModelSerializer): class Meta: model = Profession - fields = ( - "speciality", - "specialization", - ) + fields = "__all__" class SkillSerializer(CustomModelSerializer): diff --git a/src/backend/api/v1/projects/serializers.py b/src/backend/api/v1/projects/serializers.py index 0cbeb05..62c8c12 100644 --- a/src/backend/api/v1/projects/serializers.py +++ b/src/backend/api/v1/projects/serializers.py @@ -38,14 +38,12 @@ class DirectionSerializer(CustomModelSerializer): class Meta: model = Direction - fields = ("name",) + fields = "__all__" class BaseProjectSpecialistSerializer(CustomModelSerializer): """Общий сериализатор для специалиста необходимого проекту.""" - profession = ProfessionSerializer() - class Meta: model = ProjectSpecialist fields: ClassVar[Tuple[str, ...]] = ( @@ -165,6 +163,7 @@ def get_owner(self, project) -> dict[str, Any]: """Метод возвращает требуемые поля для владельца.""" owner = project.owner return { + "id": owner.id, "username": owner.username, "name": owner.profile.name, "avatar": ( diff --git a/src/backend/tests/projects/test_serializers.py b/src/backend/tests/projects/test_serializers.py index ed36506..eb3a5ba 100644 --- a/src/backend/tests/projects/test_serializers.py +++ b/src/backend/tests/projects/test_serializers.py @@ -3,6 +3,7 @@ def test_owner_field(profile, project): valid_data = { + "id": profile.user.id, "username": profile.user.username, "name": profile.name, "avatar": (profile.avatar.url if profile.avatar else None),