diff --git a/api_v2/serializers.py b/api_v2/serializers.py index 61c04f6c..55e4e618 100644 --- a/api_v2/serializers.py +++ b/api_v2/serializers.py @@ -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__' diff --git a/api_v2/views.py b/api_v2/views.py index 2b092d44..a015c963 100644 --- a/api_v2/views.py +++ b/api_v2/views.py @@ -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 \ No newline at end of file diff --git a/server/urls.py b/server/urls.py index b8b960f8..bcad7e25 100644 --- a/server/urls.py +++ b/server/urls.py @@ -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.