From 75194838dafc8797883b5350ce48f8db69ea5c17 Mon Sep 17 00:00:00 2001
From: Olivier Bado-Faustin <12731381+Badatos@users.noreply.github.com>
Date: Fri, 10 Jan 2025 10:13:05 +0100
Subject: [PATCH] Code cleaning for 3.9.0 (#1238)
* Remove useless html comments
* Translate html comments
* Remove duplicated function get_storage_path_video from video.utils
* Replace '/' by os.path.join in video models
* Remove duplicated code in video-script?html
---
pod/live/templates/live/event-info.html | 3 ++-
pod/main/templates/base.html | 3 +--
pod/main/templates/navbar.html | 2 +-
.../playlist/playlist-list-modal.html | 4 ++--
pod/video/forms.py | 3 +--
pod/video/models.py | 4 ++--
.../templates/videos/video-all-info.html | 2 +-
pod/video/templates/videos/video-element.html | 1 -
pod/video/templates/videos/video-script.html | 3 ---
pod/video/urls.py | 1 +
pod/video/utils.py | 20 +------------------
pod/video_encode_transcript/models.py | 3 +--
12 files changed, 13 insertions(+), 36 deletions(-)
diff --git a/pod/live/templates/live/event-info.html b/pod/live/templates/live/event-info.html
index aec2f1b631..7f3eb1b499 100644
--- a/pod/live/templates/live/event-info.html
+++ b/pod/live/templates/live/event-info.html
@@ -58,7 +58,8 @@
- {% if event.is_draft == False or event.owner == request.user or request.user in event.additional_owners.all or request.user.is_superuser %}
+ {% if event.is_draft == False or event.owner == request.user or request.user in event.additional_owners.all or request.user.is_superuser %}
+
diff --git a/pod/main/templates/base.html b/pod/main/templates/base.html
index 9085d07dda..325ce5f4b5 100644
--- a/pod/main/templates/base.html
+++ b/pod/main/templates/base.html
@@ -63,10 +63,9 @@
{% if PRE_HEADER_TEMPLATE %}{% include PRE_HEADER_TEMPLATE %}{% endif %}
-
{% include 'navbar.html' %}
-
+
{% include 'navbar_collapse.html' %}
{% block content %}
diff --git a/pod/main/templates/navbar.html b/pod/main/templates/navbar.html
index 60fb6993df..997da58b8f 100644
--- a/pod/main/templates/navbar.html
+++ b/pod/main/templates/navbar.html
@@ -402,5 +402,5 @@
{% trans 'Your statistics' %}
{% endif %}
{% endif %}
-
+
{% endspaceless %}
diff --git a/pod/playlist/templates/playlist/playlist-list-modal.html b/pod/playlist/templates/playlist/playlist-list-modal.html
index 86acd1a5dd..854de0a586 100644
--- a/pod/playlist/templates/playlist/playlist-list-modal.html
+++ b/pod/playlist/templates/playlist/playlist-list-modal.html
@@ -7,7 +7,7 @@
{% endblock page_extra_head %}
-
+
-
+
{% block more_script %}
diff --git a/pod/video/forms.py b/pod/video/forms.py
index 3bc613f457..1f6c25762b 100644
--- a/pod/video/forms.py
+++ b/pod/video/forms.py
@@ -10,13 +10,12 @@
from django.utils.deconstruct import deconstructible
from django.utils.translation import ugettext_lazy as _
from django.template.defaultfilters import filesizeformat
-from .models import Video, VideoVersion
+from .models import Video, VideoVersion, get_storage_path_video
from .models import Channel
from .models import Theme
from .models import Type
from .models import Discipline
from .models import Notes, AdvancedNotes, NoteComments
-from .utils import get_storage_path_video
from pod.video_encode_transcript.models import PlaylistVideo
from pod.video_encode_transcript import encode
from pod.video_encode_transcript.models import EncodingVideo, EncodingAudio
diff --git a/pod/video/models.py b/pod/video/models.py
index d321beb881..9a7cada19a 100644
--- a/pod/video/models.py
+++ b/pod/video/models.py
@@ -262,9 +262,9 @@ def get_storage_path_video(instance, filename) -> str:
return os.path.join(
VIDEOS_DIR,
instance.owner.owner.hashkey,
- "%s/%s.%s"
+ os.path.dirname(fname),
+ "%s.%s"
% (
- os.path.dirname(fname),
slugify(os.path.basename(fname)),
extension,
),
diff --git a/pod/video/templates/videos/video-all-info.html b/pod/video/templates/videos/video-all-info.html
index b5e406d266..cb65ee247a 100644
--- a/pod/video/templates/videos/video-all-info.html
+++ b/pod/video/templates/videos/video-all-info.html
@@ -17,7 +17,7 @@
{% endif %}
-
+
{% tags_for_object video as tag_list %}
{% if third_app %}
diff --git a/pod/video/templates/videos/video-element.html b/pod/video/templates/videos/video-element.html
index 9ab123213b..a2d827e67f 100644
--- a/pod/video/templates/videos/video-element.html
+++ b/pod/video/templates/videos/video-element.html
@@ -10,7 +10,6 @@
{% endif %}
{% if request.GET.loop and request.GET.loop == 'true' %} loop {% endif %} {% endspaceless %}
>
-
{%blocktrans%}To view this video please enable JavaScript, and consider upgrading to a web browser that supports HTML5 video {%endblocktrans%}
diff --git a/pod/video/templates/videos/video-script.html b/pod/video/templates/videos/video-script.html
index d741008f21..abfc9fefcd 100644
--- a/pod/video/templates/videos/video-script.html
+++ b/pod/video/templates/videos/video-script.html
@@ -198,9 +198,6 @@
player.vttThumbnails({
src: '{% if request.is_secure %}https://{% else %}http://{% endif %}{{request.get_host}}{{video.overview.url}}?date={{video.overview|file_date_created}}'
});
- player.vttThumbnails({
- src: '{% if request.is_secure %}https://{% else %}http://{% endif %}{{request.get_host}}{{video.overview.url}}?date={{video.overview|file_date_created}}'
- });
{% endif %}
{% if video.overlay_set.all %}
diff --git a/pod/video/urls.py b/pod/video/urls.py
index 99525a0308..45a6254a53 100644
--- a/pod/video/urls.py
+++ b/pod/video/urls.py
@@ -1,3 +1,4 @@
+"""Esup-Pod Video Urls."""
from django.conf import settings
from django.conf.urls import url
from django.urls import include, path
diff --git a/pod/video/utils.py b/pod/video/utils.py
index efe465047b..158f694c20 100644
--- a/pod/video/utils.py
+++ b/pod/video/utils.py
@@ -271,25 +271,7 @@ def get_storage_path_video(instance, filename) -> str:
Instance needs to implement owner
"""
- fname, dot, extension = filename.rpartition(".")
- try:
- fname.index("/")
- return os.path.join(
- VIDEOS_DIR,
- instance.owner.owner.hashkey,
- "%s/%s.%s"
- % (
- os.path.dirname(fname),
- slugify(os.path.basename(fname)),
- extension,
- ),
- )
- except ValueError:
- return os.path.join(
- VIDEOS_DIR,
- instance.owner.owner.hashkey,
- "%s.%s" % (slugify(fname), extension),
- )
+ Video.get_storage_path_video(instance, filename)
def verify_field_length(field, field_name: str = "title", max_length: int = 100) -> list:
diff --git a/pod/video_encode_transcript/models.py b/pod/video_encode_transcript/models.py
index 31342c3c2c..66af65ecea 100644
--- a/pod/video_encode_transcript/models.py
+++ b/pod/video_encode_transcript/models.py
@@ -10,8 +10,7 @@
from django.contrib.sites.models import Site
from django.dispatch import receiver
from django.db.models.signals import post_save
-from pod.video.models import Video
-from pod.video.utils import get_storage_path_video
+from pod.video.models import Video, get_storage_path_video
ENCODING_CHOICES = getattr(
settings,