Skip to content

Commit 677a8f8

Browse files
Merge pull request #828 from calumbell/756/document-type
Add `"type"` field to `Document` model
2 parents 5ff76dd + 5f53110 commit 677a8f8

30 files changed

+96
-34
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Generated by Django 5.2.1 on 2025-11-04 19:23
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('api_v2', '0066_alter_classfeature_feature_type'),
10+
]
11+
12+
operations = [
13+
migrations.AddField(
14+
model_name='document',
15+
name='type',
16+
field=models.TextField(choices=[('SOURCE', 'Source'), ('MISC', 'Miscellaneous')], default='SOURCE', help_text='Whether this Document is a published data source, or general resources'),
17+
),
18+
]

api_v2/models/document.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,15 @@ class Document(HasName, HasDescription):
1212

1313
key = key_field()
1414

15+
type = models.TextField(
16+
choices=[
17+
("SOURCE", "Source"),
18+
("MISC", "Miscellaneous")
19+
],
20+
help_text='Whether this Document is a published data source, or general resources',
21+
default="SOURCE",
22+
)
23+
1524
licenses = models.ManyToManyField(
1625
"License",
1726
help_text="Licenses that the content has been released under.")
@@ -128,7 +137,7 @@ class FromDocument(models.Model):
128137
primary_key=True,
129138
max_length=100,
130139
help_text="Unique key for the Item.")
131-
140+
132141
def as_text(self):
133142
return "{}\n\n{}".format(self.name, self.desc)
134143

api_v2/serializers/document.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,4 +81,4 @@ def get_display_name(self, obj):
8181

8282
class Meta:
8383
model = models.Document
84-
fields = ['name', 'key', 'display_name', 'publisher', 'gamesystem', 'permalink']
84+
fields = ['name', 'key', 'type', 'display_name', 'publisher', 'gamesystem', 'permalink']

api_v2/tests/responses/TestObjects.test_alignment_example.approved.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525
"key": "open5e",
2626
"name": "Open5e",
2727
"url": "http://localhost:8000/v2/publishers/open5e/"
28-
}
28+
},
29+
"type": "MISC"
2930
},
3031
"key": "chaotic-good",
3132
"morality": "good",

api_v2/tests/responses/TestObjects.test_armor_example.approved.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
"key": "wizards-of-the-coast",
1919
"name": "Wizards of the Coast",
2020
"url": "http://localhost:8000/v2/publishers/wizards-of-the-coast/"
21-
}
21+
},
22+
"type": "SOURCE"
2223
},
2324
"grants_stealth_disadvantage": true,
2425
"key": "srd_splint",

api_v2/tests/responses/TestObjects.test_background_example.approved.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@
4141
"key": "wizards-of-the-coast",
4242
"name": "Wizards of the Coast",
4343
"url": "http://localhost:8000/v2/publishers/wizards-of-the-coast/"
44-
}
44+
},
45+
"type": "SOURCE"
4546
},
4647
"key": "srd_acolyte",
4748
"name": "Acolyte",

api_v2/tests/responses/TestObjects.test_class_example.approved.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
"key": "wizards-of-the-coast",
1616
"name": "Wizards of the Coast",
1717
"url": "http://localhost:8000/v2/publishers/wizards-of-the-coast/"
18-
}
18+
},
19+
"type": "SOURCE"
1920
},
2021
"features": [
2122
{

api_v2/tests/responses/TestObjects.test_condition_example.approved.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@
3030
"key": "open5e",
3131
"name": "Open5e",
3232
"url": "http://localhost:8000/v2/publishers/open5e/"
33-
}
33+
},
34+
"type": "MISC"
3435
},
3536
"icon": {
3637
"alt_text": "An icon representing the Stunned condition. A black-and-white silhouette of a figure visible from the shoulders up faces the viewer. They are surrounded by stars that sit on rings which suggest orbits.",

api_v2/tests/responses/TestObjects.test_creature_ancient_example.approved.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,8 @@
195195
"key": "wizards-of-the-coast",
196196
"name": "Wizards of the Coast",
197197
"url": "http://localhost:8000/v2/publishers/wizards-of-the-coast/"
198-
}
198+
},
199+
"type": "SOURCE"
199200
},
200201
"environments": [
201202
{

api_v2/tests/responses/TestObjects.test_creature_goblin_example.approved.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,8 @@
9898
"key": "wizards-of-the-coast",
9999
"name": "Wizards of the Coast",
100100
"url": "http://localhost:8000/v2/publishers/wizards-of-the-coast/"
101-
}
101+
},
102+
"type": "SOURCE"
102103
},
103104
"environments": [
104105
{

0 commit comments

Comments
 (0)