From f29dff7ad023326547c220b0b139ab73f4c8af12 Mon Sep 17 00:00:00 2001 From: Jay Varner Date: Wed, 18 Sep 2024 12:44:38 -0400 Subject: [PATCH] Use index prefix from settings --- apps/iiif/manifests/documents.py | 10 ++++++---- apps/readux/documents.py | 3 ++- config/settings/local.dst | 3 ++- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/apps/iiif/manifests/documents.py b/apps/iiif/manifests/documents.py index 9c1f6197..5c372013 100644 --- a/apps/iiif/manifests/documents.py +++ b/apps/iiif/manifests/documents.py @@ -2,17 +2,19 @@ from os import environ from html import unescape + from django.conf import settings +from django.db.models.query import Prefetch +from django.utils.html import strip_tags + from django_elasticsearch_dsl import Document, fields from django_elasticsearch_dsl.registries import registry + from elasticsearch_dsl import MetaField, Keyword, analyzer -from django.db.models.query import Prefetch -from django.utils.html import strip_tags from unidecode import unidecode from apps.iiif.annotations.models import Annotation from apps.iiif.canvases.models import Canvas -from apps.iiif.kollections.models import Collection from apps.iiif.manifests.models import Manifest # TODO: Better English stemming (e.g. Rome to match Roman), multilingual stemming. @@ -55,7 +57,7 @@ class ManifestDocument(Document): class Index: """Settings for Elasticsearch""" - name = f"readux_{environ['DJANGO_ENV']}_manifests" + name = f"{settings.INDEX_PREFIX}_manifests" class Django: """Settings for automatically pulling data from Django""" diff --git a/apps/readux/documents.py b/apps/readux/documents.py index 14b3ccb2..8ae06a51 100644 --- a/apps/readux/documents.py +++ b/apps/readux/documents.py @@ -5,6 +5,7 @@ from django_elasticsearch_dsl import Document, fields from django_elasticsearch_dsl.registries import registry from django.utils.html import strip_tags +from django.conf import settings from apps.readux.models import UserAnnotation from apps.iiif.manifests.documents import stemmer @@ -25,7 +26,7 @@ class UserAnnotationDocument(Document): class Index: """Settings for Elasticsearch""" - name = f"readux_{environ['DJANGO_ENV']}_annotations" + name = f"{settings.INDEX_PREFIX}_annotations" class Django: """Settings for automatically pulling data from Django""" diff --git a/config/settings/local.dst b/config/settings/local.dst index aa08382f..b95c6da4 100644 --- a/config/settings/local.dst +++ b/config/settings/local.dst @@ -171,6 +171,7 @@ LOGGING = { # Must be configured to the host and port running Elasticsearch ELASTICSEARCH_DSL['default']['hosts'] = 'user:pass@localhost:9200' +INDEX_PREFIX = "readux_test" # Custom faceted metadata fields configuration. Must be a dict with key names # matching exactly the ingest metadata spradsheet column names to be indexed. @@ -179,7 +180,7 @@ ELASTICSEARCH_DSL['default']['hosts'] = 'user:pass@localhost:9200' # used ("separator": ";", semicolon by default). # Note that these key names will also correspond to "label" names in the Manifest # metadata list. -# +# # Example: # CUSTOM_METADATA = { # "Column Name": {