diff --git a/pod/live/admin.py b/pod/live/admin.py index f9fe2c7453..431ee4f090 100644 --- a/pod/live/admin.py +++ b/pod/live/admin.py @@ -5,8 +5,8 @@ from django.urls import reverse from django.utils.html import format_html from django.utils.translation import gettext_lazy as _ -from js_asset import static from sorl.thumbnail import get_thumbnail +from django.templatetags.static import static from pod.live.forms import BuildingAdminForm, EventAdminForm, BroadcasterAdminForm from pod.live.models import ( diff --git a/pod/main/configuration.json b/pod/main/configuration.json index 962a879a4a..295d7951eb 100644 --- a/pod/main/configuration.json +++ b/pod/main/configuration.json @@ -3668,15 +3668,15 @@ "pod_version_init": "3.1.0" }, "ES_VERSION": { - "default_value": 6, + "default_value": 7, "description": { "en": [ "" ], "fr": [ "Version d’ElasticSearch.", - "valeurs possibles 6, 7 ou 8 correspondant à la version du Elasticsearch utilisé.", - "Pour utiliser la version 7 ou 8, faire une mise à jour du paquet elasticsearch-py ", + "valeurs possibles 7 ou 8 correspondant à la version du serveur Elasticsearch utilisé.", + "Attention, le paquet elasticsearch-py doit correspondre à la version du serveur. ", "Pour la 7, `pip3 install elasticsearch==7.17.7`,", "et pour la 8, `pip3 install elasticsearch==8.8.1`.", "Voir [elasticsearch-py.readthedocs.io](https://elasticsearch-py.readthedocs.io/)", diff --git a/pod/main/test_settings.py b/pod/main/test_settings.py index 49abb770db..08e02fdf66 100644 --- a/pod/main/test_settings.py +++ b/pod/main/test_settings.py @@ -20,16 +20,17 @@ os.path.join(settings_base_dir, "custom", "static", "opencast") ) USE_DOCKER = True -path = "pod/custom/settings_local.py" ES_URL = ["http://elasticsearch.localhost:9200/"] -ES_VERSION = 6 +ES_VERSION = 7 +ES_INDEX = "pod-test" +path = "pod/custom/settings_local.py" if os.path.exists(path): _temp = __import__("pod.custom", globals(), locals(), ["settings_local"]) - USE_DOCKER = getattr(_temp.settings_local, "USE_DOCKER", True) + USE_DOCKER = getattr(_temp.settings_local, "USE_DOCKER", USE_DOCKER) ES_URL = getattr( - _temp.settings_local, "ES_URL", ["http://elasticsearch.localhost:9200/"] + _temp.settings_local, "ES_URL", ES_URL ) - ES_VERSION = getattr(_temp.settings_local, "ES_VERSION", 6) + ES_VERSION = getattr(_temp.settings_local, "ES_VERSION", ES_VERSION) for application in INSTALLED_APPS: if application.startswith("pod"): diff --git a/pod/video_search/utils.py b/pod/video_search/utils.py index 094a906892..c603621f57 100644 --- a/pod/video_search/utils.py +++ b/pod/video_search/utils.py @@ -34,16 +34,7 @@ def index_es(video): try: data = video.get_json_to_index() if data != "{}": - if ES_VERSION in [7, 8]: - res = es.index(index=ES_INDEX, id=video.id, body=data, refresh=True) - else: - res = es.index( - index=ES_INDEX, - id=video.id, - doc_type="pod", - body=data, - refresh=True, - ) + res = es.index(index=ES_INDEX, id=video.id, body=data, refresh=True) if DEBUG: logger.info(res) return res @@ -66,18 +57,9 @@ def delete_es(video): ) if es.ping(): try: - if ES_VERSION in [7, 8]: - delete = es.delete( - index=ES_INDEX, id=video.id, refresh=True, ignore=[400, 404] - ) - else: - delete = es.delete( - index=ES_INDEX, - doc_type="pod", - id=video.id, - refresh=True, - ignore=[400, 404], - ) + delete = es.delete( + index=ES_INDEX, id=video.id, refresh=True, ignore=[400, 404] + ) if DEBUG: logger.info(delete) return delete diff --git a/pod/video_search/views.py b/pod/video_search/views.py index d164472a3c..e8e6dd8cea 100644 --- a/pod/video_search/views.py +++ b/pod/video_search/views.py @@ -16,7 +16,7 @@ ES_INDEX = getattr(settings, "ES_INDEX", "pod") ES_TIMEOUT = getattr(settings, "ES_TIMEOUT", 30) ES_MAX_RETRIES = getattr(settings, "ES_MAX_RETRIES", 10) -ES_VERSION = getattr(settings, "ES_VERSION", 6) +ES_VERSION = getattr(settings, "ES_VERSION", 7) ES_OPTIONS = getattr(settings, "ES_OPTIONS", {}) @@ -238,10 +238,7 @@ def search_videos(request): list_videos_id = [hit["_id"] for hit in result["hits"]["hits"]] videos = Video.objects.filter(id__in=list_videos_id) num_result = 0 - if ES_VERSION in [7, 8]: - num_result = result["hits"]["total"]["value"] - else: - num_result = result["hits"]["total"] + num_result = result["hits"]["total"]["value"] videos.has_next = ((page + 1) * size) < num_result videos.next_page_number = page + 1