Skip to content

Commit

Permalink
Merge branch 'pod_V4' into django-tinyMCE
Browse files Browse the repository at this point in the history
  • Loading branch information
Badatos committed Nov 21, 2024
2 parents 6f1f918 + 097edab commit 922e7b1
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 36 deletions.
2 changes: 1 addition & 1 deletion pod/live/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
6 changes: 3 additions & 3 deletions pod/main/configuration.json
Original file line number Diff line number Diff line change
Expand Up @@ -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/)",
Expand Down
11 changes: 6 additions & 5 deletions pod/main/test_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"):
Expand Down
26 changes: 4 additions & 22 deletions pod/video_search/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
7 changes: 2 additions & 5 deletions pod/video_search/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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", {})


Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 922e7b1

Please sign in to comment.