Skip to content

Commit

Permalink
feat(api): add Serializer for SubCategory
Browse files Browse the repository at this point in the history
  • Loading branch information
MagneticNeedle committed Jul 20, 2023
1 parent e016a5a commit 0c404bb
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
5 changes: 4 additions & 1 deletion bfportal/core/models/experience.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,10 @@ class ExperiencePage(RoutablePageMixin, CustomBasePage):
APIField("no_players"),
APIField("no_bots"),
APIField("category", serializer=serializers.ExperiencesCategorySerializer()),
APIField("sub_categories"),
APIField(
"sub_categories",
serializer=serializers.SubCategoryCategorySerializer(many=True),
),
APIField("bugged"),
APIField("broken"),
APIField("xp_farm"),
Expand Down
12 changes: 11 additions & 1 deletion bfportal/core/serializers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from rest_framework import serializers

from .models.categories import BaseCategory, ExperiencesCategory
from .models.categories import BaseCategory, ExperiencesCategory, SubCategory

__all__ = ["ExperiencesCategorySerializer", "SubCategoryCategorySerializer"]


class BaseCategorySerializer(serializers.ModelSerializer):
Expand All @@ -17,3 +19,11 @@ class ExperiencesCategorySerializer(BaseCategorySerializer):
class Meta:
model = ExperiencesCategory
exclude = BaseCategorySerializer.Meta.exclude


class SubCategoryCategorySerializer(BaseCategorySerializer):
"""Serializer for SubCategory."""

class Meta:
model = SubCategory
exclude = BaseCategorySerializer.Meta.exclude

0 comments on commit 0c404bb

Please sign in to comment.