From 73ed68aa8d661db9edd6cbc367343b95f2207911 Mon Sep 17 00:00:00 2001 From: Olivier Bado-Faustin Date: Thu, 24 Oct 2024 12:10:56 +0200 Subject: [PATCH 01/51] * UPGRADE Django to v4.2.16 * Upgrade securtity dependances * Remove deprecated django-tagging * Add new django-tagulous * Elasticsearch default version is Now 8 (remove compatibility with ES 6) * Replace deprecated ugettext_lazy by gettext_lazy * Add some temporary deprecations Hacks for cas-client & Chunked-upload * Replace deprecated url() by re_path() * Disable all Pods apps by default * Correct error handling for ElasticSearch --- pod/ai_enhancement/forms.py | 4 +- pod/ai_enhancement/utils.py | 4 +- pod/authentication/admin.py | 2 +- pod/authentication/forms.py | 2 +- pod/authentication/models.py | 2 +- pod/authentication/tests/test_views.py | 2 +- pod/authentication/urls.py | 12 +-- pod/authentication/views.py | 2 +- pod/chapter/urls.py | 4 +- pod/completion/admin.py | 2 +- pod/completion/forms.py | 2 - pod/completion/models.py | 2 +- pod/completion/tests/test_models.py | 2 +- pod/completion/tests/test_views.py | 2 +- pod/completion/urls.py | 16 +-- pod/completion/views.py | 47 ++++----- pod/cut/context_processors.py | 2 +- pod/cut/models.py | 2 +- pod/cut/templates/video_cut.html | 1 - pod/cut/tests/test_views.py | 2 +- pod/dressing/context_processors.py | 2 +- pod/dressing/forms.py | 2 +- pod/dressing/models.py | 2 +- pod/dressing/templates/dressing_edit.html | 1 - pod/dressing/templates/video_dressing.html | 1 - pod/dressing/tests/test_views.py | 2 +- pod/enrichment/apps.py | 2 +- pod/enrichment/forms.py | 2 +- pod/enrichment/urls.py | 10 +- pod/enrichment/views.py | 11 ++- pod/import_video/context_processors.py | 2 +- pod/import_video/forms.py | 2 +- pod/import_video/models.py | 2 +- pod/import_video/tests/test_views.py | 2 +- pod/import_video/views.py | 4 +- pod/live/admin.py | 2 +- pod/live/forms.py | 2 +- pod/live/models.py | 2 +- pod/live/pilotingInterface.py | 3 +- pod/live/templates/live/event-all-info.html | 1 - pod/live/templates/live/event-info.html | 1 - pod/live/templates/live/filter_aside.html | 1 - pod/live/templatetags/event_tags.py | 2 +- pod/live/urls.py | 52 +++++----- pod/live/utils.py | 2 +- pod/live/views.py | 2 +- pod/lti/views.py | 2 +- pod/main/admin.py | 2 +- pod/main/configuration.json | 24 ++--- pod/main/context_processors.py | 4 +- pod/main/forms.py | 2 +- pod/main/forms_utils.py | 2 +- pod/main/lang_settings.py | 2 +- pod/main/models.py | 2 +- pod/main/rest_router.py | 28 +++--- pod/main/rest_views.py | 4 + pod/main/templates/aside.html | 11 +-- pod/main/templates/maintenance.html | 1 - .../templatetags/flat_page_edito_filter.py | 2 +- pod/main/tests/test_views.py | 2 +- pod/main/views.py | 5 +- pod/meeting/admin.py | 2 +- pod/meeting/forms.py | 2 +- pod/meeting/models.py | 2 +- pod/meeting/urls.py | 5 +- pod/meeting/utils.py | 2 +- pod/meeting/views.py | 8 +- pod/meeting/webinar.py | 2 +- pod/meeting/webinar_utils.py | 2 +- pod/playlist/context_processors.py | 6 +- pod/playlist/forms.py | 4 +- pod/playlist/signals.py | 2 +- .../templatetags/favorites_playlist.py | 2 +- pod/playlist/views.py | 4 +- pod/podfile/forms.py | 2 +- pod/podfile/urls.py | 34 +++---- pod/podfile/views.py | 2 +- pod/quiz/context_processors.py | 2 +- pod/quiz/tests/test_views.py | 2 +- pod/recorder/admin.py | 2 +- pod/recorder/forms.py | 2 +- pod/recorder/models.py | 4 +- pod/recorder/studio_urls.py | 26 ++--- pod/recorder/studio_urls_digest.py | 32 +++--- pod/recorder/views.py | 5 +- pod/settings.py | 31 +++++- pod/speaker/forms.py | 2 +- pod/urls.py | 99 +++++++++---------- pod/video/admin.py | 2 +- pod/video/feeds.py | 2 +- pod/video/forms.py | 2 +- pod/video/models.py | 10 +- pod/video/templates/videos/add_video.html | 1 - pod/video/templates/videos/filter_aside.html | 23 +---- .../templates/videos/video-all-info.html | 3 +- pod/video/templates/videos/video-iframe.html | 1 - pod/video/templates/videos/video-info.html | 2 - pod/video/templates/videos/video.html | 1 - pod/video/templates/videos/video_edit.html | 1 - .../templates/videos/video_row_select.html | 1 - pod/video/templatetags/video_tags.py | 24 ++--- pod/video/tests/test_models.py | 2 +- pod/video/tests/test_views.py | 2 +- pod/video/translation.py | 2 +- pod/video/urls-rss.py | 14 +-- pod/video/urls.py | 66 ++++++------- pod/video/utils.py | 2 +- pod/video/views.py | 21 ++-- pod/video_encode_transcript/encode.py | 2 +- pod/video_encode_transcript/models.py | 2 +- pod/video_encode_transcript/utils.py | 2 +- pod/video_search/forms.py | 2 +- .../management/commands/create_pod_index.py | 10 +- pod/video_search/urls.py | 4 +- pod/video_search/utils.py | 14 +-- pod/video_search/views.py | 5 +- requirements.txt | 16 +-- 117 files changed, 423 insertions(+), 428 deletions(-) diff --git a/pod/ai_enhancement/forms.py b/pod/ai_enhancement/forms.py index bb18df55f7..774ccd5149 100644 --- a/pod/ai_enhancement/forms.py +++ b/pod/ai_enhancement/forms.py @@ -2,8 +2,8 @@ from django import forms from django.conf import settings -from django.utils.translation import ugettext_lazy as _ -from tagging.fields import TagField +from django.utils.translation import gettext_lazy as _ +from tagulous.models import TagField from pod.main.forms_utils import add_placeholder_and_asterisk from pod.video.models import Video, Discipline diff --git a/pod/ai_enhancement/utils.py b/pod/ai_enhancement/utils.py index ecab02890e..cf4e56847c 100644 --- a/pod/ai_enhancement/utils.py +++ b/pod/ai_enhancement/utils.py @@ -7,7 +7,7 @@ from django.conf import settings from requests import Response from django.urls import reverse -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from pod.ai_enhancement.models import AIEnhancement from pod.main.utils import extract_json_from_str from pod.video.models import Discipline, Video @@ -27,7 +27,7 @@ AI_ENHANCEMENT_API_URL = getattr(settings, "AI_ENHANCEMENT_API_URL", "") AI_ENHANCEMENT_API_VERSION = getattr(settings, "AI_ENHANCEMENT_API_VERSION", "") -USE_NOTIFICATIONS = getattr(settings, "USE_NOTIFICATIONS", True) +USE_NOTIFICATIONS = getattr(settings, "USE_NOTIFICATIONS", False) EMAIL_ON_ENHANCEMENT_COMPLETION = getattr( settings, "EMAIL_ON_ENHANCEMENT_COMPLETION", True ) diff --git a/pod/authentication/admin.py b/pod/authentication/admin.py index 80967ad8c3..aba9678355 100644 --- a/pod/authentication/admin.py +++ b/pod/authentication/admin.py @@ -2,7 +2,7 @@ from django.contrib import admin from django.contrib.auth.admin import UserAdmin as BaseUserAdmin from django.contrib.auth.models import User -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from django.utils.html import format_html from django.contrib.sites.shortcuts import get_current_site from django.contrib.auth.models import Group diff --git a/pod/authentication/forms.py b/pod/authentication/forms.py index 11159d5a5b..490481bca3 100644 --- a/pod/authentication/forms.py +++ b/pod/authentication/forms.py @@ -4,7 +4,7 @@ from django.contrib.auth import get_user_model from django.contrib.admin.widgets import FilteredSelectMultiple from django.contrib.auth.models import Group -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from django.contrib.sites.models import Site __FILEPICKER__ = False diff --git a/pod/authentication/models.py b/pod/authentication/models.py index a09a6541ef..6474dbb93a 100644 --- a/pod/authentication/models.py +++ b/pod/authentication/models.py @@ -1,7 +1,7 @@ """Esup-Pod authentication models.""" from django.db import models -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from django.contrib.auth.models import User, Permission, Group from django.conf import settings from django.dispatch import receiver diff --git a/pod/authentication/tests/test_views.py b/pod/authentication/tests/test_views.py index 7ead289664..77fb0baf7d 100644 --- a/pod/authentication/tests/test_views.py +++ b/pod/authentication/tests/test_views.py @@ -7,7 +7,7 @@ from django.test import Client from django.contrib.auth.models import User from django.conf import settings -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ class authenticationViewsTestCase(TestCase): diff --git a/pod/authentication/urls.py b/pod/authentication/urls.py index b0c2206fd0..dffd8e5260 100644 --- a/pod/authentication/urls.py +++ b/pod/authentication/urls.py @@ -2,25 +2,25 @@ from .views import authentication_logout from .views import authentication_login_gateway -from django.conf.urls import url +from django.urls import re_path app_name = "authentication" urlpatterns = [ # auth cas - url( + re_path( r"^login/$", authentication_login, name="authentication_login", ), - url( + re_path( r"^logout/$", authentication_logout, name="authentication_logout", ), - # url(r"^login/$", authentication_login, name="login"), - # url(r"^logout/$", authentication_logout, name="logout"), - url( + # re_path(r"^login/$", authentication_login, name="login"), + # re_path(r"^logout/$", authentication_logout, name="logout"), + re_path( r"^login_gateway/$", authentication_login_gateway, name="authentication_login_gateway", diff --git a/pod/authentication/views.py b/pod/authentication/views.py index 2376b5c751..fefb77f550 100644 --- a/pod/authentication/views.py +++ b/pod/authentication/views.py @@ -6,7 +6,7 @@ from django.urls import reverse from django.conf import settings from django.core.exceptions import SuspiciousOperation -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from cas.decorators import gateway from django.contrib import auth diff --git a/pod/chapter/urls.py b/pod/chapter/urls.py index ab3486d690..cfb60bce40 100644 --- a/pod/chapter/urls.py +++ b/pod/chapter/urls.py @@ -1,10 +1,10 @@ -from django.conf.urls import url +from django.urls import re_path from pod.chapter.views import video_chapter app_name = "chapter" urlpatterns = [ - url( + re_path( r"^(?P[\-\d\w]+)/$", video_chapter, name="video_chapter", diff --git a/pod/completion/admin.py b/pod/completion/admin.py index 12de1b4dbf..8d4f79ea0f 100644 --- a/pod/completion/admin.py +++ b/pod/completion/admin.py @@ -2,7 +2,7 @@ from django.conf import settings from django.contrib import admin -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from pod.completion.models import Contributor from pod.completion.models import Document from pod.completion.models import Overlay diff --git a/pod/completion/forms.py b/pod/completion/forms.py index 69c387e22f..433ec4c5cc 100644 --- a/pod/completion/forms.py +++ b/pod/completion/forms.py @@ -4,8 +4,6 @@ from django.conf import settings from django.forms.widgets import HiddenInput -# from django.utils.translation import ugettext_lazy as _ - from pod.completion.models import Contributor from pod.completion.models import Document from pod.completion.models import Track diff --git a/pod/completion/models.py b/pod/completion/models.py index 0217471364..e4867ad097 100644 --- a/pod/completion/models.py +++ b/pod/completion/models.py @@ -5,7 +5,7 @@ from django.db import models from django.conf import settings from django.core.exceptions import ValidationError -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from django.template.defaultfilters import slugify from ckeditor.fields import RichTextField from pod.video.models import Video diff --git a/pod/completion/tests/test_models.py b/pod/completion/tests/test_models.py index 245c89792c..7831e1138d 100644 --- a/pod/completion/tests/test_models.py +++ b/pod/completion/tests/test_models.py @@ -12,7 +12,7 @@ from django.contrib.auth.models import User from django.core.files.uploadedfile import SimpleUploadedFile from django.core.exceptions import ValidationError -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from pod.video.models import Video from pod.video.models import Type from pod.completion.models import Contributor diff --git a/pod/completion/tests/test_views.py b/pod/completion/tests/test_views.py index 1310eb157f..5d3213b612 100644 --- a/pod/completion/tests/test_views.py +++ b/pod/completion/tests/test_views.py @@ -8,7 +8,7 @@ from django.contrib.auth.models import User from django.core.files.uploadedfile import SimpleUploadedFile from django.contrib.auth import authenticate -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from pod.video.models import Video, Type from ..models import Contributor from ..models import Document diff --git a/pod/completion/urls.py b/pod/completion/urls.py index bd3151e722..87a18cb3e5 100644 --- a/pod/completion/urls.py +++ b/pod/completion/urls.py @@ -1,6 +1,6 @@ """Esup-Pod Video completion urls.""" -from django.conf.urls import url +from django.urls import re_path from .views import video_completion from .views import video_caption_maker from .views import video_completion_contributor @@ -12,37 +12,37 @@ app_name = "completion" urlpatterns = [ - url( + re_path( r"^caption_maker/(?P[\-\d\w]+)/$", video_caption_maker, name="video_caption_maker", ), - url( + re_path( r"^contributor/(?P[\-\d\w]+)/$", video_completion_contributor, name="video_completion_contributor", ), - url( + re_path( r"^speaker/(?P[\-\d\w]+)/$", video_completion_speaker, name="video_completion_speaker", ), - url( + re_path( r"^document/(?P[\-\d\w]+)/$", video_completion_document, name="video_completion_document", ), - url( + re_path( r"^track/(?P[\-\d\w]+)/$", video_completion_track, name="video_completion_track", ), - url( + re_path( r"^overlay/(?P[\-\d\w]+)/$", video_completion_overlay, name="video_completion_overlay", ), - url( + re_path( r"^(?P[\-\d\w]+)/$", video_completion, name="video_completion", diff --git a/pod/completion/views.py b/pod/completion/views.py index 2d2db01bf5..58b60d78d5 100644 --- a/pod/completion/views.py +++ b/pod/completion/views.py @@ -13,6 +13,7 @@ from django.core.exceptions import PermissionDenied from django.core.handlers.wsgi import WSGIRequest from pod.video.models import Video +from pod.main.utils import is_ajax from .models import Contributor from .forms import ContributorForm from .models import Document @@ -293,7 +294,7 @@ def video_completion_contributor_new(request: WSGIRequest, video: Video): form_contributor = ContributorForm(initial={"video": video}) context = get_video_completion_context(video, form_contributor=form_contributor) context["page_title"] = _("Add a new contributor to the video “%s”") % video.title - if request.is_ajax(): + if is_ajax(request): return render( request, "contributor/form_contributor.html", @@ -322,7 +323,7 @@ def video_completion_contributor_save(request: WSGIRequest, video: Video): if form_contributor.is_valid(): form_contributor.save() list_contributor = video.contributor_set.all() - if request.is_ajax(): + if is_ajax(request): some_data_to_dump = { "list_data": render_to_string( "contributor/list_contributor.html", @@ -351,7 +352,7 @@ def video_completion_contributor_save(request: WSGIRequest, video: Video): context, ) else: - if request.is_ajax(): + if is_ajax(request): some_data_to_dump = { "errors": "{0}".format(_("Please correct errors")), "form": render_to_string( @@ -381,7 +382,7 @@ def video_completion_contributor_modify(request: WSGIRequest, video: Video): contributor = get_object_or_404(Contributor, id=request.POST["id"]) form_contributor = ContributorForm(instance=contributor) page_title = _("Edit the contributor “%s”") % contributor.name - if request.is_ajax(): + if is_ajax(request): return render( request, "contributor/form_contributor.html", @@ -406,7 +407,7 @@ def video_completion_contributor_delete(request: WSGIRequest, video: Video): contributor.delete() page_title = get_completion_home_page_title(video) list_contributor = video.contributor_set.all() - if request.is_ajax(): + if is_ajax(request): some_data_to_dump = { "list_data": render_to_string( "contributor/list_contributor.html", @@ -491,7 +492,7 @@ def video_completion_speaker_new(request: WSGIRequest, video: Video): form_speaker = JobVideoForm(initial={"video": video}) context = get_video_completion_context(video, form_speaker=form_speaker) context["page_title"] = _("Add a new contributor to the video “%s”") % video.title - if request.is_ajax(): + if is_ajax(request): return render( request, "speaker/form_speaker.html", @@ -516,7 +517,7 @@ def video_completion_speaker_save(request: WSGIRequest, video: Video): if form_speaker.is_valid(): form_speaker.save() list_speaker = get_video_speakers(video) - if request.is_ajax(): + if is_ajax(request): some_data_to_dump = { "list_data": render_to_string( "speaker/list_speaker.html", @@ -543,7 +544,7 @@ def video_completion_speaker_save(request: WSGIRequest, video: Video): context, ) else: - if request.is_ajax(): + if is_ajax(request): some_data_to_dump = { "errors": "{0}".format(_("Please correct errors")), "form": render_to_string( @@ -574,7 +575,7 @@ def video_completion_speaker_delete(request: WSGIRequest, video: Video): speaker.delete() page_title = get_completion_home_page_title(video) list_speaker = get_video_speakers(video) - if request.is_ajax(): + if is_ajax(request): some_data_to_dump = { "list_data": render_to_string( "speaker/list_speaker.html", @@ -632,7 +633,7 @@ def video_completion_document_new(request, video): """View to add new document to a video.""" form_document = DocumentForm(initial={"video": video}) context = get_video_completion_context(video, form_document=form_document) - if request.is_ajax(): + if is_ajax(request): return render( request, "document/form_document.html", @@ -658,7 +659,7 @@ def video_completion_document_save(request, video): if form_document.is_valid(): form_document.save() list_document = video.document_set.all() - if request.is_ajax(): + if is_ajax(request): some_data_to_dump = { "list_data": render_to_string( "document/list_document.html", @@ -675,7 +676,7 @@ def video_completion_document_save(request, video): context, ) else: - if request.is_ajax(): + if is_ajax(request): some_data_to_dump = { "errors": "{0}".format(_("Please correct errors")), "form": render_to_string( @@ -698,7 +699,7 @@ def video_completion_document_modify(request, video): """View to modify a document associated to a video.""" document = get_object_or_404(Document, id=request.POST["id"]) form_document = DocumentForm(instance=document) - if request.is_ajax(): + if is_ajax(request): return render( request, "document/form_document.html", @@ -718,7 +719,7 @@ def video_completion_document_delete(request, video): document = get_object_or_404(Document, id=request.POST["id"]) document.delete() list_document = video.document_set.all() - if request.is_ajax(): + if is_ajax(request): some_data_to_dump = { "list_data": render_to_string( "document/list_document.html", @@ -772,7 +773,7 @@ def video_completion_track_new(request, video): """View to add new track to a video.""" form_track = TrackForm(initial={"video": video}) context = get_video_completion_context(video, form_track=form_track) - if request.is_ajax(): + if is_ajax(request): return render( request, "track/form_track.html", @@ -799,7 +800,7 @@ def video_completion_get_form_track(request): def toggle_form_track_is_valid__video_completion_track(request, video, list_track): """Toggle form_track is valid.""" - if request.is_ajax(): + if is_ajax(request): some_data_to_dump = { "list_data": render_to_string( "track/list_track.html", @@ -829,7 +830,7 @@ def video_completion_track_save(request, video): request, video, list_track ) else: - if request.is_ajax(): + if is_ajax(request): some_data_to_dump = { "errors": "{0}".format("Please correct errors"), "form": render_to_string( @@ -855,7 +856,7 @@ def video_completion_track_modify(request, video): """View to modify a track associated to a video.""" track = get_object_or_404(Track, id=request.POST["id"]) form_track = TrackForm(instance=track) - if request.is_ajax(): + if is_ajax(request): return render( request, "track/form_track.html", @@ -956,7 +957,7 @@ def video_completion_overlay_new(request, video): """Form to create a new completion overlay.""" form_overlay = OverlayForm(initial={"video": video}) context = get_video_completion_context(video, form_overlay=form_overlay) - if request.is_ajax(): + if is_ajax(request): return render( request, "overlay/form_overlay.html", @@ -985,7 +986,7 @@ def video_completion_overlay_save(request, video): if form_overlay.is_valid(): form_overlay.save() list_overlay = video.overlay_set.all() - if request.is_ajax(): + if is_ajax(request): some_data_to_dump = { "list_data": render_to_string( "overlay/list_overlay.html", @@ -1003,7 +1004,7 @@ def video_completion_overlay_save(request, video): context, ) else: - if request.is_ajax(): + if is_ajax(request): some_data_to_dump = { "errors": "{0}".format(_("Please correct errors")), "form": render_to_string( @@ -1032,7 +1033,7 @@ def video_completion_overlay_modify(request, video): overlay = get_simple_url(overlay) form_overlay = OverlayForm(instance=overlay) - if request.is_ajax(): + if is_ajax(request): return render( request, "overlay/form_overlay.html", @@ -1051,7 +1052,7 @@ def video_completion_overlay_delete(request, video): overlay = get_object_or_404(Overlay, id=request.POST["id"]) overlay.delete() list_overlay = video.overlay_set.all() - if request.is_ajax(): + if is_ajax(request): some_data_to_dump = { "list_data": render_to_string( "overlay/list_overlay.html", diff --git a/pod/cut/context_processors.py b/pod/cut/context_processors.py index 2fe8f4bde6..8e82955f69 100644 --- a/pod/cut/context_processors.py +++ b/pod/cut/context_processors.py @@ -2,7 +2,7 @@ from django.conf import settings as django_settings -USE_CUT = getattr(django_settings, "USE_CUT", True) +USE_CUT = getattr(django_settings, "USE_CUT", False) def context_settings(request): diff --git a/pod/cut/models.py b/pod/cut/models.py index 074dd64c56..ab829c6728 100644 --- a/pod/cut/models.py +++ b/pod/cut/models.py @@ -1,7 +1,7 @@ from django.db import models from django.forms import ValidationError -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from pod.video.models import Video from pod.video_encode_transcript.utils import time_to_seconds diff --git a/pod/cut/templates/video_cut.html b/pod/cut/templates/video_cut.html index 6dbb8ceb64..71c8998247 100644 --- a/pod/cut/templates/video_cut.html +++ b/pod/cut/templates/video_cut.html @@ -1,7 +1,6 @@ {% extends 'base.html' %} {% load i18n %} {% load static %} -{% load tagging_tags %} {% load thumbnail %} {% load video_filters %} {% load video_tags %} diff --git a/pod/cut/tests/test_views.py b/pod/cut/tests/test_views.py index 189d68a389..de28435fa8 100644 --- a/pod/cut/tests/test_views.py +++ b/pod/cut/tests/test_views.py @@ -8,7 +8,7 @@ from pod.main.models import Configuration from datetime import time from django.contrib.messages import get_messages -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from .. import views from importlib import reload diff --git a/pod/dressing/context_processors.py b/pod/dressing/context_processors.py index fa36733113..d5a2f1cd1d 100644 --- a/pod/dressing/context_processors.py +++ b/pod/dressing/context_processors.py @@ -2,7 +2,7 @@ from django.conf import settings as django_settings -USE_DRESSING = getattr(django_settings, "USE_DRESSING", True) +USE_DRESSING = getattr(django_settings, "USE_DRESSING", False) def context_settings(request): diff --git a/pod/dressing/forms.py b/pod/dressing/forms.py index 8d620e9d6d..79974b1bb9 100644 --- a/pod/dressing/forms.py +++ b/pod/dressing/forms.py @@ -6,7 +6,7 @@ from django.contrib.sites.models import Site from django_select2 import forms as s2forms from django.db.models import Q -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from django.contrib import admin from django.contrib.admin import widgets diff --git a/pod/dressing/models.py b/pod/dressing/models.py index 140cfa9647..c69a0418ee 100644 --- a/pod/dressing/models.py +++ b/pod/dressing/models.py @@ -6,7 +6,7 @@ from django.contrib.auth.models import User from pod.authentication.models import AccessGroup from pod.podfile.models import CustomImageModel -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from pod.video.models import Video diff --git a/pod/dressing/templates/dressing_edit.html b/pod/dressing/templates/dressing_edit.html index 0c38c1cccd..72719d6021 100644 --- a/pod/dressing/templates/dressing_edit.html +++ b/pod/dressing/templates/dressing_edit.html @@ -1,7 +1,6 @@ {% extends 'base.html' %} {% load i18n %} {% load static %} -{% load tagging_tags %} {% load thumbnail %} {% block page_extra_head %} diff --git a/pod/dressing/templates/video_dressing.html b/pod/dressing/templates/video_dressing.html index 5cf342b5bf..f8bb83d91d 100644 --- a/pod/dressing/templates/video_dressing.html +++ b/pod/dressing/templates/video_dressing.html @@ -1,7 +1,6 @@ {% extends 'base.html' %} {% load i18n %} {% load static %} -{% load tagging_tags %} {% load thumbnail %} {% load video_filters %} {% load video_tags %} diff --git a/pod/dressing/tests/test_views.py b/pod/dressing/tests/test_views.py index 18f7cf65e1..1a7ebde117 100644 --- a/pod/dressing/tests/test_views.py +++ b/pod/dressing/tests/test_views.py @@ -1,7 +1,7 @@ """Unit tests for Esup-Pod dressing views.""" from django.contrib.auth.models import User -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from django.contrib.messages import get_messages from django.test import TestCase from django.urls import reverse diff --git a/pod/enrichment/apps.py b/pod/enrichment/apps.py index 7739973b68..9b58c08bf6 100644 --- a/pod/enrichment/apps.py +++ b/pod/enrichment/apps.py @@ -1,5 +1,5 @@ from django.apps import AppConfig -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ class EnrichmentConfig(AppConfig): diff --git a/pod/enrichment/forms.py b/pod/enrichment/forms.py index fc79c3905c..f650c23d10 100644 --- a/pod/enrichment/forms.py +++ b/pod/enrichment/forms.py @@ -2,7 +2,7 @@ from django.conf import settings from django.forms.widgets import HiddenInput from django.contrib.admin import widgets -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from django.utils.safestring import mark_safe from .models import Enrichment, EnrichmentGroup, EnrichmentVtt from django.contrib.auth.models import Group diff --git a/pod/enrichment/urls.py b/pod/enrichment/urls.py index d4864b9290..0a9a317010 100644 --- a/pod/enrichment/urls.py +++ b/pod/enrichment/urls.py @@ -1,4 +1,4 @@ -from django.conf.urls import url +from django.urls import re_path from .views import edit_enrichment from .views import video_enrichment from .views import group_enrichment @@ -6,18 +6,18 @@ app_name = "enrichment" urlpatterns = [ - url(r"^edit/(?P[\-\d\w]+)/$", edit_enrichment, name="edit_enrichment"), - url( + re_path(r"^edit/(?P[\-\d\w]+)/$", edit_enrichment, name="edit_enrichment"), + re_path( r"^group/(?P[\-\d\w]+)/$", group_enrichment, name="group_enrichment", ), - url( + re_path( r"^video/(?P[\-\d\w]+)/$", video_enrichment, name="video_enrichment", ), - url( + re_path( r"^video/(?P[\-\d\w]+)/(?P[\-\d\w]+)/$", video_enrichment, name="video_enrichment_private", diff --git a/pod/enrichment/views.py b/pod/enrichment/views.py index 0c91e45a96..75fe8be348 100644 --- a/pod/enrichment/views.py +++ b/pod/enrichment/views.py @@ -16,6 +16,7 @@ from pod.video.models import Video from pod.video.utils import sort_videos_list from pod.video.views import render_video +from pod.main.utils import is_ajax from .models import Enrichment, EnrichmentGroup from .forms import EnrichmentForm, EnrichmentGroupForm @@ -108,7 +109,7 @@ def edit_enrichment_new(request, video): list_enrichment = video.enrichment_set.all() form_enrichment = EnrichmentForm(initial={"video": video, "start": 0, "end": 1}) - if request.is_ajax(): + if is_ajax(request): return render( request, "enrichment/form_enrichment.html", @@ -143,7 +144,7 @@ def edit_enrichment_save(request, video): form_enrichment.save() # list_enrichment = video.enrichment_set.all() # enrichment_to_vtt(list_enrichment, video) - if request.is_ajax(): + if is_ajax(request): some_data_to_dump = { "list_enrichment": render_to_string( "enrichment/list_enrichment.html", @@ -160,7 +161,7 @@ def edit_enrichment_save(request, video): {"video": video, "list_enrichment": list_enrichment}, ) else: - if request.is_ajax(): + if is_ajax(request): some_data_to_dump = { "errors": "{0}".format(_("Please correct errors.")), "form": render_to_string( @@ -188,7 +189,7 @@ def edit_enrichment_modify(request, video): enrich = get_object_or_404(Enrichment, id=request.POST["id"]) form_enrichment = EnrichmentForm(instance=enrich) - if request.is_ajax(): + if is_ajax(request): return render( request, "enrichment/form_enrichment.html", @@ -212,7 +213,7 @@ def edit_enrichment_delete(request, video): list_enrichment = video.enrichment_set.all() # if list_enrichment: # enrichment_to_vtt(list_enrichment, video) - if request.is_ajax(): + if is_ajax(request): some_data_to_dump = { "list_enrichment": render_to_string( "enrichment/list_enrichment.html", diff --git a/pod/import_video/context_processors.py b/pod/import_video/context_processors.py index d72e775b31..9e2dbc4b25 100644 --- a/pod/import_video/context_processors.py +++ b/pod/import_video/context_processors.py @@ -2,7 +2,7 @@ from django.conf import settings as django_settings -USE_IMPORT_VIDEO = getattr(django_settings, "USE_IMPORT_VIDEO", True) +USE_IMPORT_VIDEO = getattr(django_settings, "USE_IMPORT_VIDEO", False) RESTRICT_EDIT_IMPORT_VIDEO_ACCESS_TO_STAFF_ONLY = getattr( django_settings, "RESTRICT_EDIT_IMPORT_VIDEO_ACCESS_TO_STAFF_ONLY", True diff --git a/pod/import_video/forms.py b/pod/import_video/forms.py index 1a858eb0d9..0b8ad7d422 100644 --- a/pod/import_video/forms.py +++ b/pod/import_video/forms.py @@ -5,7 +5,7 @@ from django.contrib.sites.models import Site from django.core.validators import URLValidator from django.core.exceptions import ValidationError -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from pod.import_video.models import ExternalRecording from pod.main.forms_utils import add_placeholder_and_asterisk from pod.main.forms_utils import OwnerWidget, AddOwnerWidget diff --git a/pod/import_video/models.py b/pod/import_video/models.py index b28a3615f7..68e6b77334 100644 --- a/pod/import_video/models.py +++ b/pod/import_video/models.py @@ -12,7 +12,7 @@ from django.db.models.signals import pre_save from django.dispatch import receiver from django.utils import timezone -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from pod.meeting.utils import ( api_call, diff --git a/pod/import_video/tests/test_views.py b/pod/import_video/tests/test_views.py index 28baa1cc14..e70858a13e 100644 --- a/pod/import_video/tests/test_views.py +++ b/pod/import_video/tests/test_views.py @@ -14,7 +14,7 @@ from django.test import TestCase from django.test import Client from django.urls import reverse -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from http import HTTPStatus # Directory that will contain the video files generated by bbb-recorder diff --git a/pod/import_video/views.py b/pod/import_video/views.py index 77b711ee45..8c82936a00 100644 --- a/pod/import_video/views.py +++ b/pod/import_video/views.py @@ -40,7 +40,7 @@ from django.views.decorators.csrf import ensure_csrf_cookie from pod.import_video.utils import manage_download from pod.main.views import in_maintenance -from pod.main.utils import secure_post_request, display_message_with_icon +from pod.main.utils import secure_post_request, display_message_with_icon, is_ajax # For Youtube download from pytube import YouTube @@ -1213,7 +1213,7 @@ def recording_with_token(request, id): # JSON format data = '{"presentationUrl": "%s", "videoUrl": "%s"}' % (presentation_url, video_url) - if request.is_ajax(): + if is_ajax(request): return HttpResponse(data, content_type="application/json") else: return HttpResponseBadRequest() diff --git a/pod/live/admin.py b/pod/live/admin.py index 6f6898bb1e..bfe2aef599 100644 --- a/pod/live/admin.py +++ b/pod/live/admin.py @@ -4,7 +4,7 @@ from django.contrib.sites.shortcuts import get_current_site from django.urls import reverse from django.utils.html import format_html -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from js_asset import static from sorl.thumbnail import get_thumbnail diff --git a/pod/live/forms.py b/pod/live/forms.py index b580737a51..eba64d14cc 100644 --- a/pod/live/forms.py +++ b/pod/live/forms.py @@ -1,7 +1,7 @@ from django import forms from django.conf import settings from django.db.models import Q -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from django.contrib.admin import widgets from pod.live.models import ( Broadcaster, diff --git a/pod/live/models.py b/pod/live/models.py index 9af42db514..dd58d22339 100644 --- a/pod/live/models.py +++ b/pod/live/models.py @@ -19,7 +19,7 @@ from django.urls import reverse from django.utils import timezone from django.utils.html import format_html -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from pod.main.lang_settings import ALL_LANG_CHOICES as __ALL_LANG_CHOICES__ from pod.main.lang_settings import PREF_LANG_CHOICES as __PREF_LANG_CHOICES__ diff --git a/pod/live/pilotingInterface.py b/pod/live/pilotingInterface.py index a37676402d..bc87ed1294 100644 --- a/pod/live/pilotingInterface.py +++ b/pod/live/pilotingInterface.py @@ -16,6 +16,7 @@ from .models import Broadcaster, Event from .utils import date_string_to_second +from pod.main.utils import is_ajax DEFAULT_EVENT_PATH = getattr(settings, "DEFAULT_EVENT_PATH", "") @@ -140,7 +141,7 @@ def get_stream_rtmp_infos(self) -> dict: def ajax_get_mandatory_parameters(request): """Return the mandatory parameters as a json response.""" - if request.method == "GET" and request.is_ajax(): + if request.method == "GET" and is_ajax(request): impl_name = request.GET.get("impl_name", None) params = get_mandatory_parameters(impl_name) params_json = {} diff --git a/pod/live/templates/live/event-all-info.html b/pod/live/templates/live/event-all-info.html index 004246ff38..3332e34116 100644 --- a/pod/live/templates/live/event-all-info.html +++ b/pod/live/templates/live/event-all-info.html @@ -1,5 +1,4 @@ {% load i18n %} -{% load tagging_tags %}