Skip to content

Commit

Permalink
Merge pull request #512 from open5e/staging
Browse files Browse the repository at this point in the history
A few small fixes and changes.
  • Loading branch information
augustjohnson authored Aug 8, 2024
2 parents 5b12f5a + cfed897 commit 0af100b
Show file tree
Hide file tree
Showing 74 changed files with 21,666 additions and 27,544 deletions.
77 changes: 77 additions & 0 deletions api/migrations/0039_auto_20240806_2058.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# Generated by Django 3.2.20 on 2024-08-06 20:58

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('api', '0038_alter_monster_bonus_actions_json'),
]

operations = [
migrations.RemoveField(
model_name='archetype',
name='created_at',
),
migrations.RemoveField(
model_name='armor',
name='created_at',
),
migrations.RemoveField(
model_name='background',
name='created_at',
),
migrations.RemoveField(
model_name='charclass',
name='created_at',
),
migrations.RemoveField(
model_name='condition',
name='created_at',
),
migrations.RemoveField(
model_name='document',
name='created_at',
),
migrations.RemoveField(
model_name='feat',
name='created_at',
),
migrations.RemoveField(
model_name='magicitem',
name='created_at',
),
migrations.RemoveField(
model_name='monster',
name='created_at',
),
migrations.RemoveField(
model_name='plane',
name='created_at',
),
migrations.RemoveField(
model_name='race',
name='created_at',
),
migrations.RemoveField(
model_name='section',
name='created_at',
),
migrations.RemoveField(
model_name='spell',
name='created_at',
),
migrations.RemoveField(
model_name='spelllist',
name='created_at',
),
migrations.RemoveField(
model_name='subrace',
name='created_at',
),
migrations.RemoveField(
model_name='weapon',
name='created_at',
),
]
8 changes: 4 additions & 4 deletions api/models/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ class Document(models.Model):
url = models.URLField(help_text='URL reference to get the document.')
copyright = models.TextField(
null=True, help_text='Copyright statement.') # Copyright 2025 open5e
created_at = models.DateTimeField(
auto_now_add=True,
help_text='Date that this object was added to the database.')
#created_at = models.DateTimeField(
# auto_now_add=True,
# help_text='Date that this object was added to the database.')
license_url = models.TextField(
default="http://open5e.com/legal",
help_text='URL reference for the license.')
Expand All @@ -75,7 +75,7 @@ class GameContent(models.Model):
help_text='Description of the game content item. Markdown.')
# Like the System Reference Document
document = models.ForeignKey(Document, on_delete=models.CASCADE)
created_at = models.DateTimeField(auto_now_add=True, editable=False)
#created_at = models.DateTimeField(auto_now_add=True, editable=False)

# If the source is a physical book (possibly with a digital version),
# then page_no is the page number in the physical book, even if the PDF
Expand Down
28 changes: 7 additions & 21 deletions api/search_indexes.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ def get_model(self):

def index_queryset(self, using=None):
"""Used when the entire index for model is updated."""
return self.get_model().objects.filter(
created_at__lte=datetime.datetime.now()
)
return self.get_model().objects.all()

class SpellIndex(indexes.SearchIndex, indexes.Indexable):
document_slug = indexes.CharField(model_attr='document__slug', indexed=False)
Expand All @@ -49,9 +47,7 @@ def get_model(self):

def index_queryset(self, using=None):
"""Used when the entire index for model is updated."""
return self.get_model().objects.filter(
created_at__lte=datetime.datetime.now()
)
return self.get_model().objects.all()

class SectionIndex(indexes.SearchIndex, indexes.Indexable):
document_slug = indexes.CharField(model_attr='document__slug', indexed=False)
Expand All @@ -68,9 +64,7 @@ def get_model(self):

def index_queryset(self, using=None):
"""Used when the entire index for model is updated."""
return self.get_model().objects.filter(
created_at__lte=datetime.datetime.now()
)
return self.get_model().objects.all()

class ConditionIndex(indexes.SearchIndex, indexes.Indexable):
document_slug = indexes.CharField(model_attr='document__slug', indexed=False)
Expand All @@ -86,9 +80,7 @@ def get_model(self):

def index_queryset(self, using=None):
"""Used when the entire index for model is updated."""
return self.get_model().objects.filter(
created_at__lte=datetime.datetime.now()
)
return self.get_model().objects.all()

class CharClassIndex(indexes.SearchIndex, indexes.Indexable):
document_slug = indexes.CharField(model_attr='document__slug', indexed=False)
Expand All @@ -103,9 +95,7 @@ def get_model(self):

def index_queryset(self, using=None):
"""Used when the entire index for model is updated."""
return self.get_model().objects.filter(
created_at__lte=datetime.datetime.now()
)
return self.get_model().objects.all()

class RaceIndex(indexes.SearchIndex, indexes.Indexable):
document_slug = indexes.CharField(model_attr='document__slug', indexed=False)
Expand All @@ -120,9 +110,7 @@ def get_model(self):

def index_queryset(self, using=None):
"""Used when the entire index for model is updated."""
return self.get_model().objects.filter(
created_at__lte=datetime.datetime.now()
)
return self.get_model().objects.all()

class MagicItemIndex(indexes.SearchIndex, indexes.Indexable):
document_slug = indexes.CharField(model_attr='document__slug', indexed=False)
Expand All @@ -140,6 +128,4 @@ def get_model(self):

def index_queryset(self, using=None):
"""Used when the entire index for model is updated."""
return self.get_model().objects.filter(
created_at__lte=datetime.datetime.now()
)
return self.get_model().objects.all()
1 change: 0 additions & 1 deletion api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ class Meta:
'author',
'organization',
'version',
'created_at',
'copyright',
'license_url',)

Expand Down
17 changes: 0 additions & 17 deletions api/tests/approved_files/TestAPIRoot.test_documents.approved.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
{
"author": "Ean Moody and Open Source Contributors from github.com/open5e-api",
"copyright": "Open5e.com Copyright 2019.",
"created_at": "2014-07-16T00:00:0.000000",
"desc": "Open5e Original Content",
"license": "Open Gaming License",
"license_url": "http://open5e.com/legal",
Expand All @@ -19,7 +18,6 @@
{
"author": "Mike Mearls, Jeremy Crawford, Chris Perkins, Rodney Thompson, Peter Lee, James Wyatt, Robert J. Schwalb, Bruce R. Cordell, Chris Sims, and Steve Townshend, based on original material by E. Gary Gygax and Dave Arneson.",
"copyright": "System Reference Document 5.1 Copyright 2016, Wizards of the Coast, Inc.; Authors Mike Mearls, Jeremy Crawford, Chris Perkins, Rodney Thompson, Peter Lee, James Wyatt, Robert J. Schwalb, Bruce R. Cordell, Chris Sims, and Steve Townshend, based on original material by E. Gary Gygax and Dave Arneson.",
"created_at": "2014-07-16T00:00:0.000000",
"desc": "Dungeons and Dragons 5th Edition Systems Reference Document by Wizards of the Coast",
"license": "Open Gaming License",
"license_url": "http://open5e.com/legal",
Expand All @@ -32,7 +30,6 @@
{
"author": "Chris Harris, Dan Dillon, Rodrigo Garcia Carmona, and Wolfgang Baur",
"copyright": "Tome of Beasts. Copyright 2016, Open Design; Authors Chris Harris, Dan Dillon, Rodrigo Garcia Carmona, and Wolfgang Baur.",
"created_at": "2014-07-16T00:00:0.000000",
"desc": "Tome of Beasts Open-Gaming License Content by Kobold Press",
"license": "Open Gaming License",
"license_url": "http://open5e.com/legal",
Expand All @@ -45,7 +42,6 @@
{
"author": "Wolfgang Baur, Dan Dillon, Richard Green, James Haeck, Chris Harris, Jeremy Hochhalter, James Introcaso, Chris Lockey, Shawn Merwin, and Jon Sawatsky",
"copyright": "Creature Codex. \u00a9 2018 Open Design LLC; Authors Wolfgang Baur, Dan Dillon, Richard Green, James Haeck, Chris Harris, Jeremy Hochhalter, James Introcaso, Chris Lockey, Shawn Merwin, and Jon Sawatsky.",
"created_at": "2014-07-16T00:00:0.000000",
"desc": "Creature Codex Open-Gaming License Content by Kobold Press",
"license": "Open Gaming License",
"license_url": "http://open5e.com/legal",
Expand All @@ -58,7 +54,6 @@
{
"author": "Wolfgang Baur, Celeste Conowitch, Darrin Drader, James Introcaso, Philip Larwood, Jeff Lee, Kelly Pawlik, Brian Suskind, Mike Welham",
"copyright": "Tome of Beasts 2. Copyright 2020 Open Design LLC; Authors Wolfgang Baur, Celeste Conowitch, Darrin Drader, James Introcaso, Philip Larwood, Jeff Lee, Kelly Pawlik, Brian Suskind, Mike Welham.",
"created_at": "2014-07-16T00:00:0.000000",
"desc": "Tome of Beasts 2 Open-Gaming License Content by Kobold Press",
"license": "Open Gaming License",
"license_url": "http://open5e.com/legal",
Expand All @@ -71,7 +66,6 @@
{
"author": "Dan Dillon, Chris Harris, and Jeff Lee",
"copyright": "Deep Magic for 5th Edition \u00a9 2020 Open Design LLC; Authors: Dan Dillon, Chris Harris, and Jeff Lee.",
"created_at": "2014-07-16T00:00:0.000000",
"desc": "Deep Magic Open-Gaming License Content by Kobold Press",
"license": "Open Gaming License",
"license_url": "http://open5e.com/legal",
Expand All @@ -84,7 +78,6 @@
{
"author": "Paul Hughes",
"copyright": "Level Up: Advanced 5th Edition Monstrous Menagerie. Copyright 2021, EN Publishing.",
"created_at": "2014-07-16T00:00:0.000000",
"desc": "Monstrous Menagerie OGL by EN Publishing",
"license": "Open Gaming License",
"license_url": "http://open5e.com/legal",
Expand All @@ -97,7 +90,6 @@
{
"author": "Wolfgang Baur, Celeste Conowitch, Darrin Drader, James Introcaso, Philip Larwood, Jeff Lee, Kelly Pawlik, Brian Suskind, Mike Welham",
"copyright": "Tome of Beasts 3. \u00a92022 Open Design LLC. All rights reserved.",
"created_at": "2014-07-16T00:00:0.000000",
"desc": "Tome of Beasts 3 Open-Gaming License Content by Kobold Press",
"license": "Open Gaming License",
"license_url": "http://open5e.com/legal",
Expand All @@ -110,7 +102,6 @@
{
"author": "EN Publishing",
"copyright": "This work includes material taken from the A5E System Reference Document (A5ESRD) by EN Publishing and available at A5ESRD.com, based on Level Up: Advanced 5th Edition, available at www.levelup5e.com. The A5ESRD is licensed under the Creative Commons Attribution 4.0 International License available at https://creativecommons.org/licenses/by/4.0/legalcode.",
"created_at": "2014-07-16T00:00:0.000000",
"desc": "Advanced 5th Edition System Reference Document by EN Publishing",
"license": "Creative Commons Attribution 4.0 International License",
"license_url": "http://open5e.com/legal",
Expand All @@ -123,7 +114,6 @@
{
"author": "Various",
"copyright": "\u00a9 Open Design LLC",
"created_at": "2014-07-16T00:00:0.000000",
"desc": "Kobold Press Community Use Policy",
"license": "Open Gaming License",
"license_url": "http://open5e.com/legal",
Expand All @@ -136,7 +126,6 @@
{
"author": "Various",
"copyright": "\u00a9 Open Design LLC",
"created_at": "2014-07-16T00:00:0.000000",
"desc": "Kobold Press Community Use Policy",
"license": "Open Gaming License",
"license_url": "http://open5e.com/legal",
Expand All @@ -149,7 +138,6 @@
{
"author": "Various",
"copyright": "\u00a9 Open Design LLC",
"created_at": "2014-07-16T00:00:0.000000",
"desc": "Kobold Press Community Use Policy",
"license": "Open Gaming License",
"license_url": "http://open5e.com/legal",
Expand All @@ -162,7 +150,6 @@
{
"author": "Phillip Larwood, Jeff Lee, and Christopher Lockey",
"copyright": "Vault of Magic. Copyright 2021 Open Design LLC; Authors Phillip Larwood, Jeff Lee, and Christopher Lockey.",
"created_at": "2014-07-16T00:00:0.000000",
"desc": "Vault of Magic Open-Gaming License Content by Kobold Press",
"license": "Open Gaming License",
"license_url": "http://open5e.com/legal",
Expand All @@ -175,7 +162,6 @@
{
"author": "Kelly Pawlik, Ben Mcfarland, and Briand Suskind",
"copyright": "Tome of Heroes. Copyright 2022, Open Design; Authors Kelly Pawlik, Ben Mcfarland, and Briand Suskind.",
"created_at": "2014-07-16T00:00:0.000000",
"desc": "Tome of Heroes Open-Gaming License Content by Kobold Press",
"license": "Open Gaming License",
"license_url": "http://open5e.com/legal",
Expand All @@ -188,7 +174,6 @@
{
"author": "Matthew Mercer with James Haeck",
"copyright": "Critical Role: Tal\u2019Dorei Campaign Setting is \u00a92017 Green Ronin Publishing, LLC. All rights reserved.",
"created_at": "2014-07-16T00:00:0.000000",
"desc": "Critical Role: Tal\u2019Dorei Campaign Setting by Green Ronin Publishing",
"license": "Open Gaming License",
"license_url": "http://open5e.com/legal",
Expand All @@ -201,7 +186,6 @@
{
"author": "Kobold Press",
"copyright": "ORC NOTICE: This product is licensed under the ORC License, located at the Library of Congress at TX 9-307-067, and available online at various locations including koboldpress.com/orclicense and others. All warranties are disclaimed as set forth therein.",
"created_at": "2014-07-16T00:00:0.000000",
"desc": "Black Flag Roleplaying Reference Document v0.2, \u00a9 Open Design LLC d/b/a Kobold Press",
"license": "ORC License",
"license_url": "https://paizo.com/orclicense",
Expand All @@ -214,7 +198,6 @@
{
"author": "Dan Dillon, Chris Harris, Rodrigo Garcia Carmona, Wolfgang Baur",
"copyright": "Tome of Beasts. 2023 Open Design LLC. All rights reserved.",
"created_at": "2014-07-16T00:00:0.000000",
"desc": "Tome of Beasts Open-Gaming License Content by Kobold Press",
"license": "Open Gaming License",
"license_url": "http://open5e.com/legal",
Expand Down
7 changes: 1 addition & 6 deletions api/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@

API_BASE = f"http://localhost:8000"

def scrub_date(data):
documents: list[dict] = data["results"]
for doc in documents:
doc["created_at"] = "2014-07-16T00:00:0.000000"


def scrub_img_url(data):
"""img url is inconsistent across platforms. needs to fixed in the api at a later date."""
Expand Down Expand Up @@ -53,7 +48,7 @@ def test_conditions(self):
self._verify("/conditions")

def test_documents(self):
self._verify("/documents", scrub_date)
self._verify("/documents")

def test_feats(self):
self._verify("/feats")
Expand Down
5 changes: 1 addition & 4 deletions api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,10 +285,7 @@ class ConditionViewSet(viewsets.ReadOnlyModelViewSet):
queryset = models.Condition.objects.all().order_by("pk")
serializer_class = serializers.ConditionSerializer
search_fields = ['name', 'desc']
filterset_fields=(
'name',
'document__slug',
)
filterset_class = filters.ConditionFilter


class RaceViewSet(viewsets.ReadOnlyModelViewSet):
Expand Down
Loading

0 comments on commit 0af100b

Please sign in to comment.