Skip to content

Commit

Permalink
I believe it's ready for data entry now.
Browse files Browse the repository at this point in the history
  • Loading branch information
BuildTools committed Oct 28, 2023
1 parent 8ad5a9d commit 079ca51
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 10 deletions.
18 changes: 18 additions & 0 deletions api_v2/migrations/0011_alter_creatureset_type.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.2.20 on 2023-10-28 12:48

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('api_v2', '0010_creatureset'),
]

operations = [
migrations.AlterField(
model_name='creatureset',
name='type',
field=models.TextField(choices=[('MONSTER_TYPE', 'Monster Type'), ('TAG', 'Tag')]),
),
]
18 changes: 18 additions & 0 deletions api_v2/migrations/0012_alter_creatureset_type.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.2.20 on 2023-10-28 13:16

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('api_v2', '0011_alter_creatureset_type'),
]

operations = [
migrations.AlterField(
model_name='creatureset',
name='type',
field=models.TextField(choices=[('TYPE', 'Type'), ('TAG', 'Tag')]),
),
]
3 changes: 2 additions & 1 deletion api_v2/models/creature.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,8 @@ class CreatureAttack(HasName, FromDocument):
class CreatureSet(HasName, HasDescription, FromDocument):
"""A set of Creatures to be referenced."""

CREATURE_SET_TYPE_CHOICES = [('MONSTER_TYPE', "Monster Type")]
CREATURE_SET_TYPE_CHOICES = [('TYPE', "Type"),
('TAG', "Tag")]

type = models.TextField(choices=CREATURE_SET_TYPE_CHOICES)

Expand Down
22 changes: 13 additions & 9 deletions api_v2/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,15 @@ def make_action_obj(action):

return obj


class CreatureSetSerializer(serializers.ModelSerializer):
key = serializers.ReadOnlyField()

class Meta:
model = models.CreatureSet
fields = '__all__'


class CreatureSerializer(GameContentSerializer):

key = serializers.ReadOnlyField()
Expand All @@ -248,6 +257,7 @@ class CreatureSerializer(GameContentSerializer):
skill_bonuses = serializers.SerializerMethodField()
all_skill_bonuses = serializers.SerializerMethodField()
actions = serializers.SerializerMethodField()
creaturesets = serializers.SerializerMethodField()

class Meta:
model = models.Creature
Expand All @@ -257,9 +267,8 @@ class Meta:
'key',
'name',
'category',
'size',
'type',
'creaturesets',
'size',
'subtype',
'alignment',
'weight',
Expand Down Expand Up @@ -368,10 +377,5 @@ def get_actions(self, creature):
result.append(action_obj)
return result


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

class Meta:
model = models.CreatureSet
fields = '__all__'
def get_creaturesets(self, creature):
return creature.creaturesets.all().values("key","type")

0 comments on commit 079ca51

Please sign in to comment.