Skip to content

Commit

Permalink
[DONE] Fix dressing Watermark path (#1048)
Browse files Browse the repository at this point in the history
* * Replace `settings.BASE_DIR` by watermark.file.path for video dressing watermark
* Some code formatting & docs

* Send email to admin on encoding error

* * Setup of Video & Audio encoding test case is only called once (This testCase will be 4x faster)

* another try to run setup only once

* Fix small bug

* correct typo

* small correction

* modify encoding test

* * Polish `change video owner` template
* move every "mandatory fields" help messagre in a main template to be included
* Small change on encoding error handling

* Minor QoC

* correct typos

* Corrections after peer review:
* Use django url block
* Use {{ owner }} and {{ user }} default str
* Various QoC

* Add missing parameter types

* Specify types of some lists in functions hints

* Remove every list content type hint, as they appear only in python >= 3.9
  • Loading branch information
Badatos authored Feb 15, 2024
1 parent 55004fd commit 2d982a8
Show file tree
Hide file tree
Showing 68 changed files with 570 additions and 678 deletions.
10 changes: 5 additions & 5 deletions pod/bbb/templates/bbb/list_meeting.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@

{% block page_extra_head %}
<link rel="stylesheet" href="{% static 'css/bbb.css' %}?ver={{VERSION}}">
<script>
window.setInterval("location.reload(true)",30000);
</script>
{% endblock %}

{% block breadcrumbs %}
Expand All @@ -18,8 +15,8 @@

<h2 class="h3">{% trans "Create a video from a BigBlueButton presentation" %}</h2>
{% if records.paginator.count == 0 %}
<h3 class="h4">{% trans "No record found"%}</h3>
<p class="alert alert-info" role="alert">{% trans 'There are no BigBlueButton records.'%}</p>
<h3 class="h4">{% trans "No record found" %}</h3>
<p class="alert alert-info" role="alert">{% trans "There are no BigBlueButton records." %}</p>
{% else %}
<h3 class="h4">{% blocktrans count counter=records.paginator.count %}{{ counter }} record found{% plural %}{{ counter }} records found{% endblocktrans %}</h4>
{% trans "This is the list of the recorded BigBlueButton sessions for which you were moderator. This module allows you to create a video from a BigBlueButton presentation." %}<br>
Expand Down Expand Up @@ -61,6 +58,9 @@ <h2 class="modal-title" id="previewModalLabel">{% trans "BigBlueButton presentat
{% block page_aside %}{% endblock page_aside %}

{% block more_script %}
<script>
window.setInterval("location.reload(true)",30000);
</script>
<script src="{% static 'waypoints/lib/jquery.waypoints.min.js' %}?ver={{VERSION}}"></script>
<script src="{% static 'waypoints/lib/shortcuts/infinite.min.js' %}?ver={{VERSION}}"></script>
<script>
Expand Down
2 changes: 1 addition & 1 deletion pod/bbb/templates/bbb/live_list_meeting.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ <h2 class="h3">{% blocktrans count counter=records.paginator.count %}{{ counter
</p>

{% if records.paginator.count == 0 %}
<p class="alert alert-info" role="alert">{% trans 'There are no BigBlueButton sessions in progress.'%}</p>
<p class="alert alert-info" role="alert">{% trans "There are no BigBlueButton sessions in progress." %}</p>
{% else %}
{% include "bbb/live_record_list.html" %}
{% endif %}
Expand Down
3 changes: 2 additions & 1 deletion pod/bbb/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class MeetingTestCase(TestCase):
]

def setUp(self):
"""Set up MeetingTestCase."""
Meeting.objects.create(
id=1,
meeting_id="id1",
Expand All @@ -32,8 +33,8 @@ def setUp(self):

print(" ---> SetUp of MeetingTestCase: OK!")

# Test attributes
def test_attributes(self):
"""Test Meeting attributes."""
meeting = Meeting.objects.get(id=1)
self.assertEqual(meeting.meeting_name, "Session BBB1")
self.assertEqual(meeting.internal_meeting_id, "internalid1")
Expand Down
32 changes: 12 additions & 20 deletions pod/chapter/templates/video_chapter.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,10 @@
{% block page_title %}{% trans 'Chapter video' %} "{{video.title}}" {% endblock page_title %}
{% block page_extra_head %}
{% include 'videos/video-header.html' %}
<script src="{% static 'js/chapters.js' %}?ver={{VERSION}}"></script>
<script>
const video_duration = {{ video.duration }};
</script>
{% endblock page_extra_head %}
{% block breadcrumbs %}
{{block.super}}
<li class="breadcrumb-item"><a href="{% url 'video:dashboard'%}">{% trans 'Dashboard' %}</a></li>
<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 %}" title="{{video.title}}">
{{video.title|title|truncatechars:45}}
Expand All @@ -39,7 +35,7 @@
</div>
<span class="float-end">
<a href="{% url 'video:video' slug=video.slug %}" title="{% blocktrans with video_title=video.title %}Back to the video “{{ video_title }}”{% endblocktrans %}" class="btn btn btn-secondary btn-sm" data-bs-toggle="tooltip" data-bs-placement="bottom">
<i class="bi bi-film" aria-hidden="true"></i>&nbsp;{% trans "Back to the video"%}
<i class="bi bi-film" aria-hidden="true"></i>&nbsp;{% trans "Back to the video" %}
</a>
</span>
{% if not form_chapter %}
Expand Down Expand Up @@ -67,22 +63,18 @@ <h2 class="card-header card-title pod-card__title h4">{% trans "Help"%}</h2>
{% trans 'Chapters' %}
</button>
<div id="collapse-0" class="card-body collapse card-text small">
<p>{% trans '“Add a new chapter” allows you to add a chapter to the video, “modify” allows you to edit it and “delete” allows you to remove the chapter.' %}</p>
<p>{% trans 'Start playback of the video, pause the video and click on “Get time from the player” to fill in the field untitled “Start time”.' %}</p>
<p>{% trans 'The chapters cannot start at the same time.' %}</p>
<p>{% trans 'You must save your chapters to view the result.' %}</p>
</div>
</div>
<div class="card mt-1" id="card-mandatory-fields">
<h2 class="h4 card-header card-title pl-2">{% trans "Mandatory fields" %}</h2>
<div class="card-body card-text">
<p>
<span class="required_star">*</span>
{% trans "Fields marked with an asterisk are mandatory." %}
</p>
<p>{% trans "“Add a new chapter” allows you to add a chapter to the video, “modify” allows you to edit it and “delete” allows you to remove the chapter." %}</p>
<p>{% trans "Start playback of the video, pause the video and click on “Get time from the player” to fill in the field untitled “Start time”." %}</p>
<p>{% trans "The chapters cannot start at the same time." %}</p>
<p>{% trans "You must save your chapters to view the result." %}</p>
</div>
</div>
{% include "main/mandatory_fields.html" %}
{% endblock page_aside %}
{% block more_script %}
{% include 'videos/video-script.html'%}
<script src="{% static 'js/chapters.js' %}?ver={{VERSION}}"></script>
<script>
const video_duration = {{ video.duration }};
</script>
{% include "videos/video-script.html" %}
{% endblock more_script %}
4 changes: 2 additions & 2 deletions pod/completion/templates/video_caption_maker.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

{% block breadcrumbs %}
{{block.super}}
<li class="breadcrumb-item"><a href="{% url 'video:dashboard' %}">{% trans 'Dashboard' %}</a></li>
<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 %}">
Expand Down Expand Up @@ -221,5 +221,5 @@ <h2 class="modal-title" id="confirmSaveLabel">{% trans "Save captions file."%}</
</script>
<script src="{% static 'js/caption_maker.js' %}?ver={{VERSION}}"></script>
<script src="{% static 'js/completion.js' %}?ver={{VERSION}}"></script>
{% include 'videos/video-script.html'%}
{% include "videos/video-script.html" %}
{% endblock more_script %}
2 changes: 1 addition & 1 deletion pod/completion/templates/video_completion.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
{% endblock page_extra_head %}
{% block breadcrumbs %}
{{block.super}}
<li class="breadcrumb-item"><a href="{% url 'video:dashboard'%}">{% trans 'Dashboard' %}</a></li>
<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 %}" title="{{video.title}}">
{{video.title|title|truncatechars:45}}
Expand Down
11 changes: 5 additions & 6 deletions pod/cut/templates/video_cut.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@

{% block breadcrumbs %}
{{block.super}}
<li class="breadcrumb-item"><a href="{% url 'video:dashboard'%}">{% trans 'Dashboard' %}</a></li>
<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 %}" title="{{video.title}}">
{{video.title|title|truncatechars:45}}
</a>
</li>

<li class="breadcrumb-item active" aria-current="page">
{% trans 'Cut the video' %}
{% trans "Cut the video" %}
</li>

{% endblock %}
Expand Down Expand Up @@ -133,7 +133,6 @@ <h2 class="card-header card-title pod-card__title h4">{% trans "Help"%}</h2>
{% endblock page_aside %}

{% block more_script %}
{% include 'videos/video-script.html'%}
<script src="{% static 'js/video_cut.js' %}?ver={{VERSION}}"></script>

{% endblock more_script %}
{% include "videos/video-script.html" %}
<script src="{% static 'js/video_cut.js' %}?ver={{VERSION}}"></script>
{% endblock more_script %}
4 changes: 4 additions & 0 deletions pod/dressing/admin.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
"""Esup-Pod dressing admin page."""
from django.contrib import admin
from .models import Dressing
from .forms import DressingAdminForm
Expand All @@ -7,6 +8,7 @@ class DressingAdmin(admin.ModelAdmin):
"""Dressing admin page."""

def get_form(self, request, obj=None, **kwargs):
"""Get the dressing admin form."""
ModelForm = super(DressingAdmin, self).get_form(request, obj, **kwargs)

class ModelFormMetaClass(ModelForm):
Expand All @@ -33,6 +35,8 @@ def __new__(cls, *args, **kwargs):
]

class Media:
"""Media to add to admin dressing page."""

css = {
"all": (
# "bootstrap/dist/css/bootstrap.min.css",
Expand Down
4 changes: 4 additions & 0 deletions pod/dressing/apps.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
"""Esup-Pod dressing apps."""

from django.apps import AppConfig
from django.utils.translation import gettext_lazy as _


class DressingConfig(AppConfig):
"""Video dressing config app."""

default_auto_field = "django.db.models.BigAutoField"
name = "pod.dressing"
verbose_name = _("Video dressings")
18 changes: 12 additions & 6 deletions pod/dressing/forms.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
"""Esup-Pod dressing forms."""
from django import forms
from django.conf import settings
from pod.main.forms_utils import add_placeholder_and_asterisk
Expand All @@ -19,7 +20,7 @@


class AddOwnerWidget(s2forms.ModelSelect2MultipleWidget):
"""Class AddOwnerWidget."""
"""Widget to add a dressing owner."""

search_fields = [
"username__icontains",
Expand All @@ -28,7 +29,7 @@ class AddOwnerWidget(s2forms.ModelSelect2MultipleWidget):


class AddAccessGroupWidget(s2forms.ModelSelect2MultipleWidget):
"""Class AddAccessGroupWidget."""
"""Widget to add an access group to dressing."""

search_fields = [
"display_name__icontains",
Expand All @@ -37,7 +38,7 @@ class AddAccessGroupWidget(s2forms.ModelSelect2MultipleWidget):


class AddVideoHoldWidget(s2forms.ModelSelect2Widget):
"""Class AddVideoHoldWidget."""
"""Widget to add video hold to dressing."""

search_fields = ["slug__icontains", "title__icontains"]

Expand All @@ -50,7 +51,7 @@ class DressingForm(forms.ModelForm):
admin_form = True

def __init__(self, *args, **kwargs):
"""Init method."""
"""Init dressing form."""
self.is_staff = (
kwargs.pop("is_staff") if "is_staff" in kwargs.keys() else self.is_staff
)
Expand All @@ -77,7 +78,7 @@ def __init__(self, *args, **kwargs):
self.fields["opening_credits"].queryset = query_videos.all()
self.fields["ending_credits"].queryset = query_videos.all()

# change ckeditor config for no staff user
# change CKEditor config for no staff user
if not hasattr(self, "admin_form") and (
self.is_staff is False and self.is_superuser is False
):
Expand All @@ -91,7 +92,7 @@ def __init__(self, *args, **kwargs):
self.fields["owners"].initial = self.user

class Meta(object):
"""Meta class."""
"""Video dressing metadata."""

model = Dressing
fields = "__all__"
Expand All @@ -115,6 +116,7 @@ class DressingDeleteForm(forms.Form):
)

def __init__(self, *args, **kwargs):
"""Init a delete dressing form."""
super(DressingDeleteForm, self).__init__(*args, **kwargs)
self.fields = add_placeholder_and_asterisk(self.fields)

Expand All @@ -123,15 +125,19 @@ class DressingAdminForm(forms.ModelForm):
"""Form for admin panel."""

def __init__(self, *args, **kwargs):
"""Init admin dressing form."""
self.request = kwargs.pop("request", None)
super(DressingAdminForm, self).__init__(*args, **kwargs)
if __FILEPICKER__ and self.fields.get("watermark"):
self.fields["watermark"].widget = CustomFileWidget(type="image")

def clean(self):
"""Clean admin dressing form."""
super(DressingAdminForm, self).clean()

class Meta(object):
"""Admin dressing form metadata."""

model = Dressing
fields = "__all__"
exclude = ["videos"]
Expand Down
4 changes: 2 additions & 2 deletions pod/dressing/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class Dressing(models.Model):
help_text=_(
"Please choose a title as short and accurate as "
"possible, reflecting the main subject / context "
"of the content.(max length: 100 characters)"
"of the content. (max length: 100 characters)"
),
)

Expand Down Expand Up @@ -115,7 +115,7 @@ class Meta:
verbose_name_plural = _("Video dressings")

def to_json(self):
"""Convert to json format for encoding logs"""
"""Convert to json format for encoding logs."""
return {
"id": self.id,
"title": self.title,
Expand Down
7 changes: 2 additions & 5 deletions pod/dressing/templates/dressing_edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,12 @@ <h2 class="accordion-header">
<div class="text-center">
<button type="submit" class="btn btn-primary">{% trans "Save" %}</button>
<a href="{% url 'dressing:my_dressings' %}" class="btn btn-secondary">{% trans "Back" %}</a>

</div>
</form>
{% endblock page_content %}

{% block collapse_page_aside %}
{% endblock collapse_page_aside %}
{% block page_aside %}
{% endblock page_aside %}
{% block collapse_page_aside %}{% endblock collapse_page_aside %}
{% block page_aside %}{% endblock page_aside %}

{% block more_script %}
<script src="/admin/jsi18n/"></script>
Expand Down
Loading

0 comments on commit 2d982a8

Please sign in to comment.