Skip to content

Commit

Permalink
exposing traits.
Browse files Browse the repository at this point in the history
  • Loading branch information
BuildTools committed Aug 13, 2023
1 parent dd6b3e2 commit ac33dd0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
4 changes: 4 additions & 0 deletions api_v2/models/race.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ def is_subrace(self):
"""Returns whether the object is a subrace."""
return self.subrace_of != null

@property
def traits(self):
return self.trait_set

class Meta:
"""To assist with the UI layer."""

Expand Down
9 changes: 9 additions & 0 deletions api_v2/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,17 @@ class Meta:
fields = '__all__'


class TraitSerializer(serializers.ModelSerializer):

class Meta:
model = models.Trait
fields = ['name', 'desc']


class RaceSerializer(GameContentSerializer):
key = serializers.ReadOnlyField()
traits = TraitSerializer(
many=True)

class Meta:
model = models.Race
Expand Down

0 comments on commit ac33dd0

Please sign in to comment.