From 8ad5a9d720b83029737e43b618335c15c5d16f10 Mon Sep 17 00:00:00 2001 From: BuildTools Date: Sat, 28 Oct 2023 07:32:24 -0500 Subject: [PATCH] Creaturesets showing up. --- api_v2/serializers.py | 9 +++++++++ api_v2/views.py | 11 +++++++++++ server/urls.py | 1 + 3 files changed, 21 insertions(+) diff --git a/api_v2/serializers.py b/api_v2/serializers.py index afde8e63..f33832b6 100644 --- a/api_v2/serializers.py +++ b/api_v2/serializers.py @@ -259,6 +259,7 @@ class Meta: 'category', 'size', 'type', + 'creaturesets', 'subtype', 'alignment', 'weight', @@ -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__' diff --git a/api_v2/views.py b/api_v2/views.py index 222428cc..14dfb429 100644 --- a/api_v2/views.py +++ b/api_v2/views.py @@ -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 diff --git a/server/urls.py b/server/urls.py index 3bddfd09..64bba487 100644 --- a/server/urls.py +++ b/server/urls.py @@ -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.