Skip to content

Commit

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

from .damagetype import DamageTypeSerializer

from .language import LanguageSerializer
from .language import LanguageSerializer

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

from rest_framework import serializers

from api_v2 import models

from .abstracts import GameContentSerializer

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

class Meta:
model = models.Alignment
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 @@ -21,4 +21,6 @@

from .damagetype import DamageTypeViewSet

from .language import LanguageFilterSet, LanguageViewSet
from .language import LanguageFilterSet, LanguageViewSet

from .alignment import AlignmentViewSet
16 changes: 16 additions & 0 deletions api_v2/views/alignment.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 AlignmentViewSet(viewsets.ReadOnlyModelViewSet):
"""
list: API endpoint for returning a list of alignments.
retrieve: API endpoint for returning a particular alignment.
"""
queryset = models.Alignment.objects.all().order_by('pk')
serializer_class = serializers.AlignmentSerializer



1 change: 1 addition & 0 deletions server/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
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)

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

0 comments on commit 4859e8c

Please sign in to comment.