Skip to content

Commit

Permalink
Adding in column data.
Browse files Browse the repository at this point in the history
  • Loading branch information
augustjohnson committed Dec 14, 2024
1 parent 164a3c3 commit 386a7d8
Show file tree
Hide file tree
Showing 5 changed files with 4,776 additions and 808 deletions.
16 changes: 5 additions & 11 deletions api_v2/models/characterclass.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,6 @@ class ClassFeatureItem(models.Model):
help_text='The value that should be displayed in the table column (where applicable).'
)

@property
def column(self):
# Represents whether or not this should be displaye as it's own column.
return self.column_value is not None


def __str__(self):
return "{} {} ({})".format(
self.parent.parent.name,
Expand All @@ -53,12 +47,12 @@ class ClassFeature(HasName, HasDescription, FromDocument):

parent = models.ForeignKey('CharacterClass',
on_delete=models.CASCADE)

def featureitem_data(self):
return self.classfeatureitem_set

def column(self):
return len(self.classfeatureitem_set.exclude(column_value=None))>0
def featureitems(self):
return self.classfeatureitem_set.exclude(column_value__isnull=False)

def columnitems(self):
return self.classfeatureitem_set.exclude(column_value__isnull=True)

def __str__(self):
return "{} ({})".format(self.name,self.parent.name)
Expand Down
18 changes: 13 additions & 5 deletions api_v2/serializers/characterclass.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,29 @@


class ClassFeatureItemSerializer(GameContentSerializer):

class Meta:
model = models.ClassFeatureItem
fields = ['level','column_value']
fields = ['level']

class ClassFeatureColumnItemSerializer(GameContentSerializer):
class Meta:
model = models.ClassFeatureItem
fields = ['level','column_value']

class ClassFeatureSerializer(GameContentSerializer):
key = serializers.ReadOnlyField()
column = serializers.ReadOnlyField()
featureitem_data = ClassFeatureItemSerializer(
many=True, context={'request': {}}
featureitems = ClassFeatureItemSerializer(
many=True
)

columnitems = ClassFeatureColumnItemSerializer(
many=True
)

class Meta:
model = models.ClassFeature
fields = ['key', 'name', 'desc','column','featureitem_data']
fields = ['key', 'name', 'desc','featureitems','columnitems']

class CharacterClassSerializer(GameContentSerializer):
key = serializers.ReadOnlyField()
Expand Down
2 changes: 1 addition & 1 deletion data/v2/wizards-of-the-coast/srd/CharacterClass.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"document": "srd",
"subclass_of": null,
"hit_dice": "D12",
"caster_type": null,
"caster_type": "NONE",
"saving_throws": [
"con",
"str"
Expand Down
170 changes: 170 additions & 0 deletions data/v2/wizards-of-the-coast/srd/ClassFeature.json
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,26 @@
"parent": "srd_barbarian"
}
},
{
"model": "api_v2.classfeature",
"pk": "srd_barbarian_rage-damage",
"fields": {
"name": "Rage Damage",
"desc": "[Column data]",
"document": "srd",
"parent": "srd_barbarian"
}
},
{
"model": "api_v2.classfeature",
"pk": "srd_barbarian_rages",
"fields": {
"name": "Rages",
"desc": "[Column data]",
"document": "srd",
"parent": "srd_barbarian"
}
},
{
"model": "api_v2.classfeature",
"pk": "srd_barbarian_reckless-attack",
Expand Down Expand Up @@ -189,6 +209,16 @@
"parent": "srd_bard"
}
},
{
"model": "api_v2.classfeature",
"pk": "srd_bard_cantrips-known",
"fields": {
"name": "Cantrips Known",
"desc": "[Column data]",
"document": "srd",
"parent": "srd_bard"
}
},
{
"model": "api_v2.classfeature",
"pk": "srd_bard_countercharm",
Expand Down Expand Up @@ -279,6 +309,16 @@
"parent": "srd_bard"
}
},
{
"model": "api_v2.classfeature",
"pk": "srd_bard_spells-known",
"fields": {
"name": "Spells Known",
"desc": "[Column data]",
"document": "srd",
"parent": "srd_bard"
}
},
{
"model": "api_v2.classfeature",
"pk": "srd_bard_superior-inspiration",
Expand Down Expand Up @@ -409,6 +449,16 @@
"parent": "srd_cleric"
}
},
{
"model": "api_v2.classfeature",
"pk": "srd_cleric_cantrips-known",
"fields": {
"name": "Cantrips Known",
"desc": "[Column data]",
"document": "srd",
"parent": "srd_cleric"
}
},
{
"model": "api_v2.classfeature",
"pk": "srd_cleric_channel-divinity",
Expand Down Expand Up @@ -599,6 +649,16 @@
"parent": "srd_druid"
}
},
{
"model": "api_v2.classfeature",
"pk": "srd_druid_cantrips-known",
"fields": {
"name": "Cantrips Known",
"desc": "[Column data]",
"document": "srd",
"parent": "srd_druid"
}
},
{
"model": "api_v2.classfeature",
"pk": "srd_druid_druid-circle",
Expand Down Expand Up @@ -959,6 +1019,16 @@
"parent": "srd_monk"
}
},
{
"model": "api_v2.classfeature",
"pk": "srd_monk_ki-points",
"fields": {
"name": "Ki Points",
"desc": "[Column data]",
"document": "srd",
"parent": "srd_monk"
}
},
{
"model": "api_v2.classfeature",
"pk": "srd_monk_martial-arts",
Expand Down Expand Up @@ -1469,6 +1539,16 @@
"parent": "srd_ranger"
}
},
{
"model": "api_v2.classfeature",
"pk": "srd_ranger_spells-known",
"fields": {
"name": "Spells Known",
"desc": "[Column data]",
"document": "srd",
"parent": "srd_ranger"
}
},
{
"model": "api_v2.classfeature",
"pk": "srd_ranger_vanish",
Expand Down Expand Up @@ -1689,6 +1769,16 @@
"parent": "srd_sorcerer"
}
},
{
"model": "api_v2.classfeature",
"pk": "srd_sorcerer_cantrips-known",
"fields": {
"name": "Cantrips Known",
"desc": "[Column data]",
"document": "srd",
"parent": "srd_sorcerer"
}
},
{
"model": "api_v2.classfeature",
"pk": "srd_sorcerer_equipment",
Expand Down Expand Up @@ -1739,6 +1829,16 @@
"parent": "srd_sorcerer"
}
},
{
"model": "api_v2.classfeature",
"pk": "srd_sorcerer_sorcery-points",
"fields": {
"name": "Sorcery Points",
"desc": "[Column data]",
"document": "srd",
"parent": "srd_sorcerer"
}
},
{
"model": "api_v2.classfeature",
"pk": "srd_sorcerer_spellcasting",
Expand All @@ -1749,6 +1849,16 @@
"parent": "srd_sorcerer"
}
},
{
"model": "api_v2.classfeature",
"pk": "srd_sorcerer_spells-known",
"fields": {
"name": "Spells Known",
"desc": "[Column data]",
"document": "srd",
"parent": "srd_sorcerer"
}
},
{
"model": "api_v2.classfeature",
"pk": "srd_sorceror_proficiencies",
Expand Down Expand Up @@ -1869,6 +1979,16 @@
"parent": "srd_warlock"
}
},
{
"model": "api_v2.classfeature",
"pk": "srd_warlock_cantrips-known",
"fields": {
"name": "Cantrips Known",
"desc": "[Column data]",
"document": "srd",
"parent": "srd_warlock"
}
},
{
"model": "api_v2.classfeature",
"pk": "srd_warlock_eldritch-invocation-list",
Expand Down Expand Up @@ -1909,6 +2029,16 @@
"parent": "srd_warlock"
}
},
{
"model": "api_v2.classfeature",
"pk": "srd_warlock_invocations-known",
"fields": {
"name": "Invocations Known",
"desc": "[Column data]",
"document": "srd",
"parent": "srd_warlock"
}
},
{
"model": "api_v2.classfeature",
"pk": "srd_warlock_mystic-arcanum",
Expand Down Expand Up @@ -1959,6 +2089,36 @@
"parent": "srd_warlock"
}
},
{
"model": "api_v2.classfeature",
"pk": "srd_warlock_slot-level",
"fields": {
"name": "Slot Level",
"desc": "[Column data]",
"document": "srd",
"parent": "srd_warlock"
}
},
{
"model": "api_v2.classfeature",
"pk": "srd_warlock_spell-slots",
"fields": {
"name": "Spell Slots",
"desc": "[Column data]",
"document": "srd",
"parent": "srd_warlock"
}
},
{
"model": "api_v2.classfeature",
"pk": "srd_warlock_spells-known",
"fields": {
"name": "Spells Known",
"desc": "[Column data]",
"document": "srd",
"parent": "srd_warlock"
}
},
{
"model": "api_v2.classfeature",
"pk": "srd_way-of-the-open-hand_open-hand-technique",
Expand Down Expand Up @@ -2029,6 +2189,16 @@
"parent": "srd_wizard"
}
},
{
"model": "api_v2.classfeature",
"pk": "srd_wizard_cantrips-known",
"fields": {
"name": "Cantrips Known",
"desc": "[Column data]",
"document": "srd",
"parent": "srd_wizard"
}
},
{
"model": "api_v2.classfeature",
"pk": "srd_wizard_equipment",
Expand Down
Loading

0 comments on commit 386a7d8

Please sign in to comment.