Skip to content

Commit

Permalink
Creaturesets showing up.
Browse files Browse the repository at this point in the history
  • Loading branch information
BuildTools committed Oct 28, 2023
1 parent 37a6239 commit 8ad5a9d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
9 changes: 9 additions & 0 deletions api_v2/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ class Meta:
'category',
'size',
'type',
'creaturesets',
'subtype',
'alignment',
'weight',
Expand Down Expand Up @@ -366,3 +367,11 @@ def get_actions(self, creature):
action_obj = make_action_obj(action)
result.append(action_obj)
return result


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

class Meta:
model = models.CreatureSet
fields = '__all__'
11 changes: 11 additions & 0 deletions api_v2/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,17 @@ class CreatureViewSet(viewsets.ReadOnlyModelViewSet):
filterset_class = CreatureFilterSet


class CreatureSetViewSet(viewsets.ReadOnlyModelViewSet):
"""
list: API endpoint for returning a list of creatures.
retrieve: API endpoint for returning a particular creature.
"""
queryset = models.CreatureSet.objects.all().order_by('pk')
serializer_class = serializers.CreatureSetSerializer
#filterset_class = CreatureFilterSet



class RaceFilterSet(FilterSet):
class Meta:
model = models.Race
Expand Down
1 change: 1 addition & 0 deletions server/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
router_v2.register(r'feats',views_v2.FeatViewSet)
router_v2.register(r'races',views_v2.RaceViewSet)
router_v2.register(r'creatures',views_v2.CreatureViewSet)
router_v2.register(r'creaturesets',views_v2.CreatureSetViewSet)

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

0 comments on commit 8ad5a9d

Please sign in to comment.