Skip to content

Commit

Permalink
Exposing conditions.
Browse files Browse the repository at this point in the history
  • Loading branch information
BuildTools committed Nov 4, 2023
1 parent 3e5014b commit 530243e
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 6 deletions.
4 changes: 3 additions & 1 deletion api_v2/serializers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,6 @@

from .language import LanguageSerializer

from .alignment import AlignmentSerializer
from .alignment import AlignmentSerializer

from .condition import ConditionSerializer
14 changes: 14 additions & 0 deletions api_v2/serializers/condition.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
"""Serializer for the Condition model."""

from rest_framework import serializers

from api_v2 import models

from .abstracts import GameContentSerializer

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

class Meta:
model = models.Condition
fields = '__all__'
4 changes: 3 additions & 1 deletion api_v2/views/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,6 @@

from .language import LanguageFilterSet, LanguageViewSet

from .alignment import AlignmentFilterSet, AlignmentViewSet
from .alignment import AlignmentFilterSet, AlignmentViewSet

from .condition import ConditionViewSet
16 changes: 16 additions & 0 deletions api_v2/views/condition.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from rest_framework import viewsets

from api_v2 import models
from api_v2 import serializers


class ConditionViewSet(viewsets.ReadOnlyModelViewSet):
"""
list: API endpoint for returning a list of conditions.
retrieve: API endpoint for returning a particular condition.
"""
queryset = models.Condition.objects.all().order_by('pk')
serializer_class = serializers.ConditionSerializer



9 changes: 5 additions & 4 deletions server/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,11 @@
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'creaturetype',views_v2.CreatureTypeViewSet)
router_v2.register(r'damagetype',views_v2.DamageTypeViewSet)
router_v2.register(r'language',views_v2.LanguageViewSet)
router_v2.register(r'alignment',views_v2.AlignmentViewSet)
router_v2.register(r'creaturetypes',views_v2.CreatureTypeViewSet)
router_v2.register(r'damagetypes',views_v2.DamageTypeViewSet)
router_v2.register(r'languages',views_v2.LanguageViewSet)
router_v2.register(r'alignments',views_v2.AlignmentViewSet)
router_v2.register(r'conditions',views_v2.ConditionViewSet)

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

0 comments on commit 530243e

Please sign in to comment.