Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DONE] Fix dressing and cutting and add unit tests 3.5.2 #1078

Merged
merged 87 commits into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from 63 commits
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
dbce8cf
Fix watermark in dressings
AymericJak Mar 18, 2024
6c653c7
Fix filewidget error
AymericJak Mar 18, 2024
908f05c
Fix get_dressing_input
AymericJak Mar 19, 2024
088cadf
Fix test_dressing_to_json
AymericJak Mar 19, 2024
2d8ebea
Add remote encoding test for dressing
AymericJak Mar 19, 2024
fc00613
change video_test to mp4 format
ptitloup Mar 19, 2024
31e762c
Modify video type & add credit video
AymericJak Mar 19, 2024
42b89ad
Add remote encoding cut test
SebastienCozeDev Mar 19, 2024
299393f
Fix flake8
SebastienCozeDev Mar 19, 2024
a280d2f
Readd settings local for docker full test
SebastienCozeDev Mar 19, 2024
65a1a0f
Add remote test calls
AymericJak Mar 19, 2024
bea56af
Merge branch 'develop' of https://github.com/EsupPortail/Esup-Pod int…
AymericJak Mar 19, 2024
5b1b677
Add str convert
SebastienCozeDev Mar 19, 2024
a230ed6
Remove the convertion
SebastienCozeDev Mar 19, 2024
dd2bb2f
Fix flake8
SebastienCozeDev Mar 19, 2024
1c3850f
Add test image & fix debug print
AymericJak Mar 19, 2024
64575b2
Prevent dressing page access when video is encoding & hide favorite b…
AymericJak Mar 20, 2024
118bd02
remove staff access for restriction but add it for thumbnail
ptitloup Mar 20, 2024
3ebb267
Add USE_DRESSING setting
AymericJak Mar 20, 2024
bf0fcc9
Fix flake8
AymericJak Mar 20, 2024
a7758ea
Add USE_CUT setting in context processors file.
SebastienCozeDev Mar 20, 2024
ac60f4b
Add USE_CUT setting
SebastienCozeDev Mar 20, 2024
df41e7c
Update configuration JSON file
SebastienCozeDev Mar 20, 2024
7a2ce04
Change video password type field to 'password'
SebastienCozeDev Mar 20, 2024
54c448d
Fix #1081
AymericJak Mar 20, 2024
669ddbd
Merge branch 'AymericJak/fix_dressing_3.6.0' of https://github.com/Ay…
AymericJak Mar 20, 2024
9580b2e
Fix the time field
SebastienCozeDev Mar 21, 2024
82b0355
Merge branch 'AymericJak/fix_dressing_2.6.0' of https://github.com/Ay…
ptitloup Mar 22, 2024
8ddd41c
remove date today from global variable and replace it in each function
ptitloup Mar 22, 2024
8321a1e
print json dressing encoding to see error
ptitloup Mar 22, 2024
3b84a69
add missing whitespace
ptitloup Mar 22, 2024
70f083b
Test ls command
SebastienCozeDev Mar 25, 2024
75b5434
Test LS
SebastienCozeDev Mar 25, 2024
6450169
Test LS
SebastienCozeDev Mar 25, 2024
ed53899
Test LS
SebastienCozeDev Mar 25, 2024
00ee3c0
Add some debug prints
SebastienCozeDev Mar 25, 2024
a5a2ead
Add some prints
SebastienCozeDev Mar 25, 2024
6495fb2
Add some prints
SebastienCozeDev Mar 25, 2024
b643c1f
Test dressing utils
AymericJak Mar 25, 2024
fd9f3b9
Merge branch 'AymericJak/fix_dressing_3.6.0' of https://github.com/Ay…
AymericJak Mar 25, 2024
1e532ef
Test dressing utils
AymericJak Mar 25, 2024
9c2556b
Test dressing utils
AymericJak Mar 25, 2024
f716acb
Test dressing utils
AymericJak Mar 25, 2024
6c9e3d3
Add debug prints
SebastienCozeDev Mar 25, 2024
424208b
Add debug prints
SebastienCozeDev Mar 25, 2024
32e43b8
Call the setUp function in the remote_encoding_cut [test]
SebastienCozeDev Mar 26, 2024
69ab27a
Add condition & prints [test]
SebastienCozeDev Mar 26, 2024
aec4e03
Remove some prints & uncomment assertions
SebastienCozeDev Mar 26, 2024
6429227
Add prints [test]
SebastienCozeDev Mar 26, 2024
f04d243
Remove test_remote_encoding_transcoding [test]
SebastienCozeDev Mar 26, 2024
153645b
Update tests
SebastienCozeDev Mar 26, 2024
447da00
Remove unnecessary prints
SebastienCozeDev Mar 26, 2024
465fc56
add decode data for completion base mail
ptitloup Mar 26, 2024
594e7a3
add pydoc and return
ptitloup Mar 26, 2024
b923e44
Replace style inline by BS class
SebastienCozeDev Mar 26, 2024
40a2b28
Remove unnecessary console.log
SebastienCozeDev Mar 26, 2024
0bbcec1
Correctly indent the template
SebastienCozeDev Mar 26, 2024
5468bc5
Put the datetime.date.today() in variable
SebastienCozeDev Mar 26, 2024
c888813
Reorganize the file
SebastienCozeDev Mar 26, 2024
d613d92
remove console.log
SebastienCozeDev Mar 26, 2024
b4fa6c4
Use today_date
SebastienCozeDev Mar 26, 2024
87fe9ee
Remove some prints
SebastienCozeDev Mar 26, 2024
5012768
Rename function
SebastienCozeDev Mar 26, 2024
acefc7b
Add test for verify_time
SebastienCozeDev Mar 27, 2024
b07be23
Fix video access tokens.
AymericJak Mar 27, 2024
43b194c
Update configuration
SebastienCozeDev Mar 27, 2024
aa6fae8
Update configuration
SebastienCozeDev Mar 27, 2024
8f561af
Merge branch 'AymericJak/fix_dressing_3.6.0' of https://github.com/Ay…
SebastienCozeDev Mar 27, 2024
470cfb0
Remove unnecessary print
SebastienCozeDev Mar 27, 2024
9c5a25e
Add unit tests for Completion model
SebastienCozeDev Mar 27, 2024
00bf697
Simplify the verify_document method
SebastienCozeDev Mar 27, 2024
670866e
Add & improve dressing views tests
AymericJak Mar 27, 2024
26d3bf8
Add some unit tests for Document model in the Completion App
SebastienCozeDev Mar 27, 2024
12c2d19
Merge branch 'AymericJak/fix_dressing_3.6.0' of https://github.com/Ay…
SebastienCozeDev Mar 27, 2024
3325908
Fix flake8
SebastienCozeDev Mar 27, 2024
61a8c91
Set the pydoc in english
SebastienCozeDev Mar 27, 2024
c225a4e
Add some unit tests for CutVideo model
SebastienCozeDev Mar 27, 2024
3f59f4e
Add cut tests & fix view
AymericJak Mar 28, 2024
0291e41
Merge branch 'AymericJak/fix_dressing_3.6.0' of https://github.com/Ay…
AymericJak Mar 28, 2024
06a98a8
Simplify verify_end_start_time method
SebastienCozeDev Mar 28, 2024
7c1d4a3
Add unit tests for enrichment
SebastienCozeDev Mar 28, 2024
4aafd42
Merge branch 'AymericJak/fix_dressing_3.6.0' of https://github.com/Ay…
SebastienCozeDev Mar 28, 2024
b3c7bc8
Improve test views for playlists
AymericJak Mar 28, 2024
584ff71
Merge branch 'AymericJak/fix_dressing_3.6.0' of https://github.com/Ay…
AymericJak Mar 28, 2024
ee94df3
add remote encoding for studio, add task, add rest views and call it …
AymericJak Mar 28, 2024
adcac51
Add USE_DEBUG_TOOLBAR setting
AymericJak Mar 28, 2024
71fbab6
remove unused recording id
ptitloup Mar 28, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 5 additions & 3 deletions pod/completion/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,13 @@ def verify_not_same_contributor(self):
def __str__(self):
return "Video:{0} - Name:{1} - Role:{2}".format(self.video, self.name, self.role)

def get_base_mail(self):
def get_base_mail(self) -> str:
"""Encode an email as base64 to prevent robots crawling."""
data = base64.b64encode(self.email_address.encode())
Badatos marked this conversation as resolved.
Show resolved Hide resolved
return data
return data.decode("utf-8")

def get_noscript_mail(self):
def get_noscript_mail(self) -> str:
"""Replace @ by __AT__ in email adress to prevent robots crawling."""
return self.email_address.replace("@", "__AT__")


Expand Down
10 changes: 10 additions & 0 deletions pod/cut/context_processors.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from django.conf import settings as django_settings
SebastienCozeDev marked this conversation as resolved.
Show resolved Hide resolved

USE_CUT = getattr(django_settings, "USE_CUT", True)


def context_settings(request):
"""Return all context settings for cut app"""
new_settings = {}
new_settings["USE_CUT"] = USE_CUT
return new_settings
14 changes: 12 additions & 2 deletions pod/cut/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@ class Meta:
model = CutVideo
fields = ["video", "start", "end", "duration"]
widgets = {
"start": forms.TimeInput(attrs={"type": "time", "step": "1"}),
"end": forms.TimeInput(attrs={"type": "time", "step": "1"}),
"start": forms.TimeInput(attrs={
"step": "1",
"required": "required",
"size": "8",
"class": "text-center",
}),
"end": forms.TimeInput(attrs={
"step": "1",
"required": "required",
"size": "8",
"class": "text-center",
}),
}
9 changes: 6 additions & 3 deletions pod/cut/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,12 @@ def verify_time(self):
return False

# Convert start and end to seconds
start = time_to_seconds(self.start)
end = time_to_seconds(self.end)
duration = time_to_seconds(self.duration)
try:
start = time_to_seconds(self.start)
end = time_to_seconds(self.end)
duration = time_to_seconds(self.duration)
except ValueError:
return False
if start < 0 or start >= end or end is None or start is None or end > duration:
return False
else:
Expand Down
2 changes: 1 addition & 1 deletion pod/cut/templates/video_cut.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@

<div id="wrapper_cut">
<div id="values_cut" class="bg-primary text-white">
<form action="{% url 'video:cut:video_cut' slug=video.slug %}" method="POST" id="time_for_cut" accept-charset="utf-8" enctype="multipart/form-data">
<form action="{% url 'cut:video_cut' slug=video.slug %}" method="POST" id="time_for_cut" accept-charset="utf-8" enctype="multipart/form-data">
{% csrf_token %}

<button id="button_start" class="btn btn-link" title="{% trans 'Get the start time from the video player' %}">
Expand Down
2 changes: 1 addition & 1 deletion pod/cut/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def setUp(self):

def test_video_cut_owner(self):
video = Video.objects.get(id=1)
url = reverse("video:cut:video_cut", kwargs={"slug": video.slug})
url = reverse("cut:video_cut", kwargs={"slug": video.slug})

self.user = User.objects.get(username="test")
self.client.force_login(self.user)
Expand Down
12 changes: 12 additions & 0 deletions pod/dressing/context_processors.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
"""Esup-Pod dressing context processor."""

from django.conf import settings as django_settings

USE_DRESSING = getattr(django_settings, "USE_DRESSING", True)


def context_settings(request):
"""Return all context settings for dressing app."""
new_settings = {}
new_settings["USE_DRESSING"] = USE_DRESSING
return new_settings
8 changes: 8 additions & 0 deletions pod/dressing/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,18 @@ def to_json(self):
"users": list(self.users.values_list("id", flat=True)),
"allow_to_groups": list(self.allow_to_groups.values_list("id", flat=True)),
"watermark": self.watermark.file.url if self.watermark else None,
"watermark_path": self.watermark.file.path if self.watermark else "",
"position": self.get_position_display(),
"position_orig": self.position,
"opacity": self.opacity,
"opening_credits": (
self.opening_credits.slug if self.opening_credits else None
),
"opening_credits_video": (
self.opening_credits.video.name if self.opening_credits else ""
),
"ending_credits": self.ending_credits.slug if self.ending_credits else None,
"ending_credits_video": (
self.ending_credits.video.name if self.ending_credits else ""
),
}
6 changes: 3 additions & 3 deletions pod/dressing/templates/video_dressing.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@
{% endblock page_extra_head %}

{% block breadcrumbs %}
{{block.super}}
{{ block.super }}

<li class="breadcrumb-item">
<a href="{% url 'video:dashboard' %}">{% trans 'Dashboard' %}</a>
</li>

<li class="breadcrumb-item">
<a href="{% url 'video:video' slug=video.slug %}">
{{video.title|title|truncatechars:45}}
{{ video.title|title|truncatechars:45 }}
</a>
</li>

Expand Down Expand Up @@ -130,7 +130,7 @@
<div class="card" id="card-managevideo">
<h2 class="card-header card-title pod-card__title h4"><i class="bi bi-gear" aria-hidden="true"></i>&nbsp;{% trans "Manage video" %}</h2>
<div class="card-body card-text text-center">
{% include "videos/link_video.html" %}
{% include "videos/link_video.html" with hide_favorite_link=True %}
</div>
</div>
{% endif %}
Expand Down
8 changes: 8 additions & 0 deletions pod/dressing/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,18 @@ def test_dressing_to_json(self):
"owners": [owner.id],
"users": [owner.id],
"watermark": dressing.watermark.file.url,
"watermark_path": dressing.watermark.file.path,
"position": dressing.get_position_display(),
"position_orig": dressing.position,
"opacity": 50,
"opening_credits": video.slug,
"opening_credits_video": (
dressing.opening_credits.video.name
),
"ending_credits": video2.slug,
"ending_credits_video": (
dressing.ending_credits.video.name
),
}
self.assertEqual(dressing_json, expected_json)
print(" ---> test_dressing_to_json: OK! --- DressingModelTest")
5 changes: 5 additions & 0 deletions pod/dressing/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ def video_dressing(request, slug):
return redirect(reverse("maintenance"))

video = get_object_or_404(Video, slug=slug, sites=get_current_site(request))
if not video.encoded and video.encoding_in_progress is True:
messages.add_message(request, messages.ERROR, _(
"The video is currently being encoded."))
raise PermissionDenied

dressings = get_dressings(request.user, request.user.owner.accessgroup_set.all())

if not (
Expand Down
62 changes: 62 additions & 0 deletions pod/main/configuration.json
Original file line number Diff line number Diff line change
Expand Up @@ -852,6 +852,68 @@
"fr": "Configuration application completion"
}
},
"cut": {
"description": {
"en": [
"Cut application to cut videos.",
"Set `USE_CUT` to True to activate this application."
],
"fr": [
"Application Cut permettant de découper des vidéos.",
"Mettre `USE_CUT` à True pour activer cette application."
]
},
"settings": {
"USE_CUT": {
"default_value": true,
"description": {
"en": [
"Activation of the cut application"
],
"fr": [
"Activation de l'application cut"
]
},
"pod_version_end": "",
"pod_version_init": "3.5.2"
}
},
"title": {
"en": "Cut application configuration",
"fr": "Configuration de l'application cut"
}
},
"dressing": {
"description": {
"en": [
"Dressing App to customize a video with watermark & credits.",
"Set `USE_DRESSING` to True to activate this application."
],
"fr": [
"Application Dressing pour customiser une vidéo avec un filigrane et des crédits.",
"Mettre `USE_DRESSING` à True pour activer cette application."
]
},
"settings": {
"USE_DRESSING": {
"default_value": true,
"description": {
"en": [
"Activation of dressings. Allows users to customize a video with watermark & credits."
],
"fr": [
"Activation des habillages. Permet aux utilisateurs de customiser une vidéo avec un filigrane et des crédits."
]
},
"pod_version_end": "",
"pod_version_init": "3.5.0"
SebastienCozeDev marked this conversation as resolved.
Show resolved Hide resolved
}
},
"title": {
"en": "Dressing application configuration",
"fr": "Configuration de l'application dressing"
}
},
"enrichment": {
"description": {},
"settings": {},
Expand Down
11 changes: 2 additions & 9 deletions pod/main/static/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -1151,10 +1151,7 @@ var restrict_access_to_groups = function () {
let id_restricted_to_groups = document.getElementById(
"id_restrict_access_to_groups",
);
let div_restricted = id_restricted_to_groups.closest(
"div.restricted_access",
);
div_restricted.style.display = "block";
id_restricted_to_groups.parentElement.classList.remove("d-none");
} else {
document
.querySelectorAll("#id_restrict_access_to_groups select")
Expand All @@ -1168,11 +1165,7 @@ var restrict_access_to_groups = function () {
let id_restricted_to_groups = document.getElementById(
"id_restrict_access_to_groups",
);
let div_restricted = id_restricted_to_groups.closest(
"div.restricted_access",
);

div_restricted.style.display = "none";
id_restricted_to_groups.parentElement.classList.add("d-none");
}
};

Expand Down
Binary file not shown.
6 changes: 4 additions & 2 deletions pod/main/templates/navbar.html
Original file line number Diff line number Diff line change
Expand Up @@ -268,8 +268,10 @@ <h5 id="pod-navbar__menuuserLabel">{% if user.get_full_name != '' %}{{ user.get_
{% if request.user.owners_channels.all %}
<a class="nav-item nav-link" href="{% url 'channels:my_channels' %}"><i class="bi bi-play-btn pod-nav-link-icon mx-1" aria-hidden="true"></i>{% trans 'My channels' %}</a>
{% endif %}
{% if request.user.is_superuser or perms.dressing.video_dressing or request.user.is_staff %}
<a class="nav-item nav-link" href="{% url 'dressing:my_dressings' %}"><i class="bi bi-palette pod-nav-link-icon mx-1" aria-hidden="true"></i>{% trans 'My dressings' %}</a>
{% if USE_DRESSING %}
{% if request.user.is_superuser or perms.dressing.video_dressing or request.user.is_staff %}
<a class="nav-item nav-link" href="{% url 'dressing:my_dressings' %}"><i class="bi bi-palette pod-nav-link-icon mx-1" aria-hidden="true"></i>{% trans 'My dressings' %}</a>
{% endif %}
{% endif %}
{% if request.user.is_staff and USE_PODFILE %}
<a class="nav-item nav-link" href="{% url 'podfile:home' %}"><i class="bi bi-folder pod-nav-link-icon mx-1" aria-hidden="true"></i>{% trans 'My files' %}</a>
Expand Down
5 changes: 4 additions & 1 deletion pod/podfile/static/podfile/js/filewidget.js
Original file line number Diff line number Diff line change
Expand Up @@ -766,7 +766,10 @@ if (typeof loaded == "undefined") {
string_html,
"text/html"
).body.firstChild;
document.getElementById("list_folders_sub").appendChild(parsedHTML);
const listFoldersSub = document.getElementById("list_folders_sub");
if (listFoldersSub) {
listFoldersSub.appendChild(parsedHTML);
}
});
if (nextPage != -1) {
search = data.search !== "" ? data.search : null;
Expand Down
2 changes: 2 additions & 0 deletions pod/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,9 @@
"pod.authentication.context_processors.context_authentication_settings",
"pod.recorder.context_processors.context_recorder_settings",
"pod.playlist.context_processors.context_settings",
"pod.dressing.context_processors.context_settings",
"pod.import_video.context_processors.context_settings",
"pod.cut.context_processors.context_settings",
],
},
},
Expand Down
44 changes: 33 additions & 11 deletions pod/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@
USE_SHIB = getattr(settings, "USE_SHIB", False)
USE_OIDC = getattr(settings, "USE_OIDC", False)
USE_NOTIFICATIONS = getattr(settings, "USE_NOTIFICATIONS", True)
USE_CUT = getattr(settings, "USE_CUT", True)
USE_MEETING = getattr(settings, "USE_MEETING", False)
USE_XAPI = getattr(settings, "USE_XAPI", False)
USE_BBB = getattr(settings, "USE_BBB", False)
USE_OPENCAST_STUDIO = getattr(settings, "USE_OPENCAST_STUDIO", False)
USE_PODFILE = getattr(settings, "USE_PODFILE", False)
USE_PLAYLIST = getattr(settings, "USE_PLAYLIST", True)
USE_DRESSING = getattr(settings, "USE_DRESSING", True)
USE_IMPORT_VIDEO = getattr(settings, "USE_IMPORT_VIDEO", True)

if USE_CAS:
from cas import views as cas_views
Expand Down Expand Up @@ -80,12 +89,8 @@
url(r"^download/$", download_file, name="download_file"),
# custom
url(r"^custom/", include("pod.custom.urls")),
# cut
url(r"^cut/", include("pod.cut.urls")),
# pwa
url("", include("pwa.urls")),
# dressing
path("dressing/", include("pod.dressing.urls", namespace="dressing")),
]

# WEBPUSH
Expand Down Expand Up @@ -117,25 +122,30 @@
]

# BBB: TODO REPLACE BBB BY MEETING
if getattr(settings, "USE_MEETING", False):
if USE_MEETING:
urlpatterns += [
url(r"^meeting/", include("pod.meeting.urls")),
]
if getattr(settings, "USE_XAPI", False):

if USE_XAPI:
urlpatterns += [
url(r"^xapi/", include("pod.xapi.urls")),
]
if getattr(settings, "USE_BBB", False):

# BBB
if USE_BBB:
urlpatterns += [
url(r"^bbb/", include("pod.bbb.urls")),
]

if getattr(settings, "USE_OPENCAST_STUDIO", False):
# RECORDER
if USE_OPENCAST_STUDIO:
urlpatterns += [
url(r"^studio/", include("pod.recorder.studio_urls")),
]

if getattr(settings, "USE_PODFILE", False):
# PODFILE
if USE_PODFILE:
urlpatterns += [
url(r"^podfile/", include("pod.podfile.urls")),
]
Expand All @@ -145,14 +155,26 @@
url(r"^" + apps + "/", include("pod.%s.urls" % apps, namespace=apps)),
]

# CUT
if USE_CUT:
urlpatterns += [
path("cut/", include("pod.cut.urls", namespace="cut")),
]

# PLAYLIST
if getattr(settings, "USE_PLAYLIST", True):
if USE_PLAYLIST:
urlpatterns += [
path("playlist/", include("pod.playlist.urls", namespace="playlist")),
]

# DRESSING
if USE_DRESSING:
urlpatterns += [
path("dressing/", include("pod.dressing.urls", namespace="dressing")),
]

# IMPORT_VIDEO
if getattr(settings, "USE_IMPORT_VIDEO", True):
if USE_IMPORT_VIDEO:
urlpatterns += [
url(
r"^import_video/", include("pod.import_video.urls", namespace="import_video")
Expand Down