Skip to content

Commit

Permalink
Merge pull request #391 from Pet-projects-CodePET/refactor/requests_a…
Browse files Browse the repository at this point in the history
…nd_serializers

refactor: Вернул id для нужых полей для фронтов и исправил ошибки
  • Loading branch information
Denis-Shtanskiy authored Nov 4, 2024
2 parents 0b11853 + 3c4f475 commit 8932379
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 7 deletions.
5 changes: 1 addition & 4 deletions src/backend/api/v1/general/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,7 @@ class ProfessionSerializer(CustomModelSerializer):

class Meta:
model = Profession
fields = (
"speciality",
"specialization",
)
fields = "__all__"


class SkillSerializer(CustomModelSerializer):
Expand Down
5 changes: 2 additions & 3 deletions src/backend/api/v1/projects/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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, ...]] = (
Expand Down Expand Up @@ -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": (
Expand Down
1 change: 1 addition & 0 deletions src/backend/tests/projects/test_serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down

0 comments on commit 8932379

Please sign in to comment.