Skip to content

Commit

Permalink
Exposing Races
Browse files Browse the repository at this point in the history
  • Loading branch information
BuildTools committed Aug 13, 2023
1 parent faed207 commit 2ac6f28
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
10 changes: 9 additions & 1 deletion api_v2/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,5 +124,13 @@ class FeatSerializer(GameContentSerializer):
key = serializers.ReadOnlyField()

class Meta:
model = models.feat
model = models.Feat
fields = '__all__'


class RaceSerializer(GameContentSerializer):
key = serializers.ReadOnlyField()

class Meta:
model = models.Race
fields = '__all__'
20 changes: 20 additions & 0 deletions api_v2/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,3 +183,23 @@ class FeatViewSet(viewsets.ReadOnlyModelViewSet):
queryset = models.Feat.objects.all().order_by('pk')
serializer_class = serializers.FeatSerializer
filterset_class = FeatFilterSet


class RaceFilterSet(FilterSet):
class Meta:
model = models.Race
fields = {
'key': ['in', 'iexact', 'exact' ],
'name': ['iexact', 'exact'],
'document__key': ['in','iexact','exact'],
}


class RaceViewSet(viewsets.ReadOnlyModelViewSet):
"""
list: API endpoint for returning a list of races.
retrieve: API endpoint for returning a particular race.
"""
queryset = models.Race.objects.all().order_by('pk')
serializer_class = serializers.RaceSerializer
filterset_class = RaceFilterSet
1 change: 1 addition & 0 deletions server/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
router_v2.register(r'armor',views_v2.ArmorViewSet)
router_v2.register(r'rulesets',views_v2.RulesetViewSet)
router_v2.register(r'feats',views_v2.FeatViewSet)
router_v2.register(r'races',views_v2.RaceViewSet)

# Wire up our API using automatic URL routing.
# Additionally, we include login URLs for the browsable API.
Expand Down

0 comments on commit 2ac6f28

Please sign in to comment.