diff --git a/api/migrations/0003_delete_manifest.py b/api/migrations/0003_delete_manifest.py new file mode 100644 index 000000000..cd800ff49 --- /dev/null +++ b/api/migrations/0003_delete_manifest.py @@ -0,0 +1,16 @@ +# Generated by Django 5.2.9 on 2026-02-13 11:54 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('api', '0002_document_v2_related_key'), + ] + + operations = [ + migrations.DeleteModel( + name='Manifest', + ), + ] diff --git a/api/models/__init__.py b/api/models/__init__.py index 61be33571..7b471cf0b 100644 --- a/api/models/__init__.py +++ b/api/models/__init__.py @@ -1,7 +1,6 @@ """ The initialization for models for open5e's api. """ -from .models import Manifest from .models import Document from .models import GameContent from .models import CharClass diff --git a/api/models/models.py b/api/models/models.py index e83b4280b..65f0c0814 100644 --- a/api/models/models.py +++ b/api/models/models.py @@ -7,34 +7,6 @@ from django.template.defaultfilters import slugify #from api_v2 import urls as urls_v2 -class Manifest(models.Model): - """A Manifest contains a hash based on the contents of a file. - - This is intended for folks who process and store content from our API. - When they download content, they also download the corresponding manifest. - Periodically, they check back in to see whether any manifests have changed. - If so, then they know to re-download that source. - """ - - filename = models.CharField( - max_length=255, - unique=True, - help_text='Input file name.') - type = models.CharField( - max_length=25, - help_text='Type of file (maps to a model).') - hash = models.CharField(max_length=255, - help_text='md5 hash of the file contents.') - created_at = models.DateTimeField( - auto_now_add=True, - help_text='Date that this object was added to the database.') - - @staticmethod - def plural_str() -> str: - """Return a string specifying the plural name of this model.""" - return "Manifests" - - class Document(models.Model): slug = models.CharField(max_length=255, unique=True, default=uuid.uuid1) # System Reference Document diff --git a/api/serializers.py b/api/serializers.py index 9510e4fc8..887831ca5 100644 --- a/api/serializers.py +++ b/api/serializers.py @@ -4,12 +4,6 @@ from api import models from api import search_indexes - -class ManifestSerializer(serializers.ModelSerializer): - class Meta: - model = models.Manifest - fields = ('filename', 'type', 'hash', 'created_at') - class DynamicFieldsModelSerializer(serializers.ModelSerializer): def __init__(self, *args, **kwargs): diff --git a/api/tests/approved_files/TestAPIRoot.test_root.approved.json b/api/tests/approved_files/TestAPIRoot.test_root.approved.json index 3b24c7b56..017051444 100644 --- a/api/tests/approved_files/TestAPIRoot.test_root.approved.json +++ b/api/tests/approved_files/TestAPIRoot.test_root.approved.json @@ -6,7 +6,6 @@ "documents": "http://localhost:8000/v2/documents/", "feats": "http://localhost:8000/v2/feats/", "magicitems": "http://localhost:8000/v1/magicitems/", - "manifest": "http://localhost:8000/v1/manifest/", "monsters": "http://localhost:8000/v1/monsters/", "planes": "http://localhost:8000/v1/planes/", "races": "http://localhost:8000/v1/races/", diff --git a/api/tests/test_api.py b/api/tests/test_api.py index b9661275c..1d8090a75 100644 --- a/api/tests/test_api.py +++ b/api/tests/test_api.py @@ -56,8 +56,6 @@ def test_feats(self): def test_magicitems(self): self._verify("/magicitems") - # /manifest is excluded because it's too volatile - def test_monsters(self): pass # This test is flaky, and fails on one machine, but passes on another. diff --git a/api/urls.py b/api/urls.py index 21e95e7fe..425ae81cc 100644 --- a/api/urls.py +++ b/api/urls.py @@ -6,7 +6,6 @@ from server.routers import DocumentedDefaultRouter router = DocumentedDefaultRouter() -router.register(r'manifest', views.ManifestViewSet) router.register(r'spells', views.SpellViewSet) router.register(r'spelllist',views.SpellListViewSet) router.register(r'monsters', views.MonsterViewSet) @@ -24,6 +23,5 @@ urlpatterns = [ path('', include(router.urls)), #Consider removing this after a while. - path('version/', views.get_version, name="version"), path('v1/', include(router.urls)) ] \ No newline at end of file diff --git a/api/views.py b/api/views.py index be51b2b10..946f6c66f 100644 --- a/api/views.py +++ b/api/views.py @@ -8,30 +8,6 @@ from api import serializers from api import filters - - -class ManifestViewSet(viewsets.ReadOnlyModelViewSet): - """ - list: API endpoint for returning a list of of manifests. - - For each data source file, there is a corresponding manifest containing an - MD5 hash of the data inside that file. When we update our data files, the - corresponding manifest's hash changes. If you host a service that - automatically downloads data from Open5e, you can periodically check - the manifests to determine whether your data is out of date. - - retrieve: API endpoint for returning a particular manifest. - - For each data source file, there is a corresponding manifest containing an - MD5 hash of the data inside that file. When we update our data files, the - corresponding manifest's hash changes. If you host a service that - automatically downloads data from Open5e, you can periodically check - the manifests to determine whether your data is out of date. - """ - queryset = models.Manifest.objects.all().order_by("pk") - serializer_class = serializers.ManifestSerializer - - @api_view() def get_version(_): """ diff --git a/docs/schema.md b/docs/schema.md index 562678571..33bbe7b0b 100644 --- a/docs/schema.md +++ b/docs/schema.md @@ -16,14 +16,6 @@ erDiagram TEXT copyright } - api_manifest { - INTEGER id - VARCHAR filename - VARCHAR type - VARCHAR hash - DATETIME created_at - } - auth_group { INTEGER id VARCHAR name diff --git a/server/version.py b/server/version.py deleted file mode 100644 index c6aae67d8..000000000 --- a/server/version.py +++ /dev/null @@ -1,28 +0,0 @@ -import hashlib -import os -# This file is used to serve data to the /version endpoint of the API. -# For production (and staging) deploys, this file is overwritten at build time. - -def GetHashofDirs(directory): - """ - Hash directories for - Adapted from: https://stackoverflow.com/questions/24937495/how-can-i-calculate-a-hash-for-a-filesystem-directory-using-python - """ - - digest = hashlib.sha256() - if not os.path.exists(directory): - raise IOError - - for root, _, files in os.walk(directory): - for names in files: - filepath = os.path.join(root,names) - with open(filepath, 'rb') as file: - digest = hashlib.file_digest(file, "sha256") - - - return digest.hexdigest() - -DATA_V1_HASH = GetHashofDirs("./data/v1") -DATA_V2_HASH = GetHashofDirs("./data/v2") -API_V1_HASH = GetHashofDirs("./api") -API_V2_HASH = GetHashofDirs("./api_v2")