Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:D4rkLght/Skills into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
D4rkLght committed Dec 10, 2023
2 parents 15cabdf + 593ee4a commit a5fe63b
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions backend/api/v1/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@
from users.models import Specialization, UserProfile, UserResources, UserSkill


class SkillResourceSerializer(serializers.ModelSerializer):
"""Краткое отображение ресурсов библиотеки."""

class Meta:
model = ResourceLibrary
fields = '__all__'


class GroupSerializer(serializers.ModelSerializer):
"""Отображение группы."""

Expand Down Expand Up @@ -56,6 +64,19 @@ def get_learning_status(self, obj):
class SkillFrontSerializer(serializers.ModelSerializer):
"""Список всех навыков удобный фронту."""

group = GroupSerializer()
resource_library = SkillResourceSerializer(many=True)
level = serializers.CharField(source='get_level_display')

class Meta:
model = Skill
fields = ('id', 'name', 'level', 'group',
'description', 'type', 'resource_library')


class SkillExpandedSerializer(serializers.ModelSerializer):
"""Список всех навыков для userskills."""

group = GroupSerializer()
resource_library = ResourceLibrarySerializer(many=True)
level = serializers.CharField(source='get_level_display')
Expand All @@ -69,7 +90,7 @@ class Meta:
class UserSkillSerializer(serializers.ModelSerializer):
"""Навыки пользователя."""

skill = SkillFrontSerializer()
skill = SkillExpandedSerializer()
userskill_id = serializers.CharField(source='id')

class Meta:
Expand Down Expand Up @@ -214,7 +235,7 @@ class Meta:
class SkillDetailSerializer(serializers.ModelSerializer):
"""Детальная информация о навыке."""

resource_library = ResourceLibrarySerializer(many=True)
resource_library = SkillResourceSerializer(many=True)
specialization = SpecializationShortSerializer()

class Meta:
Expand Down

0 comments on commit a5fe63b

Please sign in to comment.