Skip to content

Commit

Permalink
[WIP] Bugfixes for 3.6.1 (#1120)
Browse files Browse the repository at this point in the history
* Fix DownloadFileForm

* improve encoding video model

* improve video info downloads

* add command to import encoded video

* Fix rights for dressings

* Fix unit test & flake8

* add class iframe for the body in video iframe template and remove test in encoding model

* Rename sendAndGetForm function

* Add logs

* 🐛 Fix the add contributor button in the completion page

* Improve flake8

* Improve flake8

* Fix playlists views

* Fix type

* 🐛 Fix the cancel button in the completion forms

* remove unused command

* Fix some playlist views

* Improve meetings

* Fix playlist tests

* add space between line in subtitle

* move css code to existing place

* 🐛 Fix the playlist right

* 🐛 Fix the unit tests

* Remove debug logs

* Add JSDoc

* Add line break at the file end

* Fix channel in dashboard

* bump version to 3.6.1

---------

Co-authored-by: Ptitloup <[email protected]>
Co-authored-by: SebastienCozeDev <[email protected]>
  • Loading branch information
3 people authored May 7, 2024
1 parent 4b15a31 commit f055954
Show file tree
Hide file tree
Showing 44 changed files with 351 additions and 281 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pod_dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ jobs:
# FLAKE 8
- name: Flake8 compliance
run: |
flake8 --max-complexity=7 --ignore=E501,W503,E203 --exclude .git,pod/*/migrations/*.py,*_settings.py
flake8 --max-complexity=7 --ignore=E501,W503,E203 --exclude .git,pod/*/migrations/*.py,test_settings.py,node_modules/*/*.py,pod/static/*.py,pod/custom/tenants/*/*.py
## Start remote encoding and transcoding test ##
- name: Create settings local file
Expand Down
2 changes: 1 addition & 1 deletion pod/authentication/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ def get_owners(search, limit, offset):
"first_name",
"last_name",
)
)[offset : limit + offset]
)[offset: limit + offset]

return JsonResponse(users, safe=False)
61 changes: 25 additions & 36 deletions pod/completion/static/js/completion.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,34 +28,6 @@ document.addEventListener("DOMContentLoaded", function () {
var num = 0;
var name = "";

// RESET
document.addEventListener("reset", (event) => {
if (!event.target.matches("#accordeon form.completion")) return;

var id_form = event.target.getAttribute("id");
var name_form = id_form.substring(5, id_form.length);
var form_new = "form_new_" + name_form;
var list = "list_" + name_form;
document.getElementById(id_form).innerHTML = "";
if (id_form == "form_track")
document.getElementById("form_track").style.width = "auto";
document.getElementById(form_new).style.display = "block";
document.querySelectorAll("form").forEach((form) => {
form.style.display = "block";
});
document.querySelectorAll("a.title").forEach(function (element) {
element.style.display = "initial";
});
document.querySelectorAll("table tr").forEach(function (element) {
element.classList.remove("info");
});

let fileModalDoc = document.getElementById("fileModal_id_document");
let fileModalSrc = document.getElementById("fileModal_id_src");

fileModalDoc?.remove();
fileModalSrc?.remove();
});

function show_form(data, form) {
let form_el = document.getElementById(form);
Expand Down Expand Up @@ -95,10 +67,10 @@ var ajaxfail = function (data, form) {

document.addEventListener("submit", (e) => {
if (
e.target.id != "form_new_contributor" &&
e.target.id != "form_new_document" &&
e.target.id != "form_new_track" &&
e.target.id != "form_new_overlay" &&
e.target.id !== "form_new_contributor" &&
e.target.id !== "form_new_document" &&
e.target.id !== "form_new_track" &&
e.target.id !== "form_new_overlay" &&
!e.target.matches(".form_change") &&
!e.target.matches(".form_delete")
)
Expand All @@ -123,12 +95,24 @@ document.addEventListener("submit", (e) => {
var form = "form_" + name_form;
var list = "list_" + name_form;
var action = e.target.querySelector("input[name=action]").value;
sendandgetform(e.target, action, name_form, form, list);
sendAndGetForm(e.target, action, name_form, form, list).then(r => "").catch(e => console.log("error", e));
});

var sendandgetform = async function (elt, action, name, form, list) {

/**
* Send and get form.
*
* @param elt {HTMLElement} HTML element.
* @param action {string} Action.
* @param name {string} Name.
* @param form {string} Form.
* @param list {string} List.
*
* @return {Promise<void>} The form promise.
*/
var sendAndGetForm = async function (elt, action, name, form, list) {
var href = elt.getAttribute("action");
if (action == "new" || action == "form_save_new") {
if (action === "new" || action === "form_save_new") {
document.getElementById(form).innerHTML =
'<div style="width:100%; margin: 2rem;"><div class="lds-ellipsis"><div></div><div></div><div></div><div></div></div></div>';

Expand All @@ -142,8 +126,13 @@ var sendandgetform = async function (elt, action, name, form, list) {
}).hide();
});
/* Display associated help in side menu */
console.log("name", name);
var compInfo = document.querySelector(`#${name}-info>.collapse`);
bootstrap.Collapse.getOrCreateInstance(compInfo).show();
try {
bootstrap.Collapse.getOrCreateInstance(compInfo).show();
} catch (e) {
// do nothing
}

let url = window.location.origin + href;
let token = elt.csrfmiddlewaretoken.value;
Expand Down
2 changes: 1 addition & 1 deletion pod/completion/templates/contributor/form_contributor.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<input type="hidden" name="action" value="save">
<div class="mt-3">
<input type="submit" id="save_contributor" value="{% trans 'Save' %}" class="btn btn-primary">
<input type="reset" action="cancel" id="cancel_contributor" value="{% trans 'Cancel' %}" class="btn btn-secondary">
<a class="btn btn-secondary" action="cancel" id="cancel_document" href="{% url 'video:completion:video_completion' slug=video.slug %}">{% trans 'Cancel' %}</a>
</div>
</div>
</form>
Expand Down
2 changes: 1 addition & 1 deletion pod/completion/templates/document/form_document.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<input type="hidden" name="action" value="save">
<div class="mt-3">
<input type="submit" id="save_document" value="{% trans 'Save' %}" class="btn btn-primary">
<input type="reset" action="cancel" id="cancel_document" value="{% trans 'Cancel' %}" class="btn btn-secondary">
<a class="btn btn-secondary" action="cancel" id="cancel_document" href="{% url 'video:completion:video_completion' slug=video.slug %}">{% trans 'Cancel' %}</a>
</div>
</div>
</form>
Expand Down
2 changes: 1 addition & 1 deletion pod/completion/templates/overlay/form_overlay.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
{% endif %}
<input type="hidden" name="action" value="save">
<input type="submit" id="save_overlay" value="{% trans 'Save' %}" class="btn btn-primary">
<input type="reset" action="cancel" id="cancel_overlay" value="{% trans 'Cancel' %}" class="btn btn-secondary">
<a class="btn btn-secondary" action="cancel" id="cancel_document" href="{% url 'video:completion:video_completion' slug=video.slug %}">{% trans 'Cancel' %}</a>
</div>
</form>
</div>
2 changes: 1 addition & 1 deletion pod/completion/templates/track/form_track.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
{% endif %}
<input type="hidden" name="action" value="save">
<input type="submit" id="save_track" value="{% trans 'Save' %}" class="btn btn-primary">
<input type="reset" action="cancel" id="cancel_track" value="{% trans 'Cancel' %}" class="btn btn-secondary">
<a class="btn btn-secondary" action="cancel" id="cancel_document" href="{% url 'video:completion:video_completion' slug=video.slug %}">{% trans 'Cancel' %}</a>
</div>
</form>
{{form_track.media}}
Expand Down
13 changes: 7 additions & 6 deletions pod/dressing/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from django.views.decorators.csrf import csrf_protect
from django.contrib import messages
from django.core.exceptions import PermissionDenied
from django.core.handlers.wsgi import WSGIRequest

from pod.video.models import Video
from pod.video_encode_transcript.encode import start_encode
Expand All @@ -19,7 +20,7 @@

@csrf_protect
@login_required(redirect_field_name="referrer")
def video_dressing(request, slug):
def video_dressing(request: WSGIRequest, slug: str):
"""View for video dressing."""
if in_maintenance():
return redirect(reverse("maintenance"))
Expand All @@ -34,7 +35,7 @@ def video_dressing(request, slug):

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

if not (request.user.is_superuser or request.user.is_staff):
if not (request.user.is_superuser or (request.user == video.owner and request.user.is_staff)):
messages.add_message(request, messages.ERROR, _("You cannot dress this video."))
raise PermissionDenied

Expand Down Expand Up @@ -74,7 +75,7 @@ def video_dressing(request, slug):

@csrf_protect
@login_required(redirect_field_name="referrer")
def dressing_edit(request, dressing_id):
def dressing_edit(request: WSGIRequest, dressing_id: int):
"""Edit a dressing object."""
dressing_edit = get_object_or_404(Dressing, id=dressing_id)

Expand Down Expand Up @@ -115,7 +116,7 @@ def dressing_edit(request, dressing_id):

@csrf_protect
@login_required(redirect_field_name="referrer")
def dressing_create(request):
def dressing_create(request: WSGIRequest):
"""Create a dressing object."""
if not (request.user.is_superuser or request.user.is_staff):
messages.add_message(
Expand Down Expand Up @@ -144,7 +145,7 @@ def dressing_create(request):

@csrf_protect
@login_required(redirect_field_name="referrer")
def dressing_delete(request, dressing_id):
def dressing_delete(request: WSGIRequest, dressing_id: int):
"""Delete the dressing identified by 'id'."""
dressing = get_object_or_404(Dressing, id=dressing_id)
if in_maintenance():
Expand Down Expand Up @@ -186,7 +187,7 @@ def dressing_delete(request, dressing_id):

@csrf_protect
@login_required(redirect_field_name="referrer")
def my_dressings(request):
def my_dressings(request: WSGIRequest):
"""Render the logged user's dressings."""
if in_maintenance():
return redirect(reverse("maintenance"))
Expand Down
2 changes: 1 addition & 1 deletion pod/live/live_transcript.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def transcribe(url, slug, model, filepath): # noqa: C901
" "
), current_caption_text.split(" ")
current_caption_words1 = current_caption_words[
1 : len(current_caption_words)
1: len(current_caption_words)
]

for i in range(len(last_caption_words) - 1, 0, -1):
Expand Down
Binary file modified pod/locale/fr/LC_MESSAGES/django.mo
Binary file not shown.
41 changes: 23 additions & 18 deletions pod/locale/fr/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ msgid ""
msgstr ""
"Project-Id-Version: Pod\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-04-29 10:28+0000\n"
"POT-Creation-Date: 2024-05-06 12:37+0000\n"
"PO-Revision-Date: \n"
"Last-Translator: obado <[email protected]>\n"
"Language-Team: Pod Team [email protected]\n"
Expand Down Expand Up @@ -1907,7 +1907,7 @@ msgid "Cut the video"
msgstr "Découper la vidéo"

#: pod/cut/templates/video_cut.html pod/dressing/templates/video_dressing.html
#: pod/dressing/views.py
#: pod/dressing/tests/test_views.py pod/dressing/views.py
#: pod/enrichment/templates/enrichment/group_enrichment.html
#: pod/video/templates/videos/video_edit.html
#: pod/video/templates/videos/video_page_content.html
Expand Down Expand Up @@ -2224,6 +2224,14 @@ msgstr ""
"Les génériques de début et de fin sont des vidéos qui s'affichent au début "
"ou à la fin de la vidéo."

#: pod/dressing/tests/test_views.py pod/dressing/views.py
msgid "You cannot dress this video."
msgstr "Vous ne pouvez pas habiller cette vidéo."

#: pod/dressing/tests/test_views.py pod/dressing/views.py
msgid "You cannot access this page."
msgstr "Vous ne pouvez pas accéder à cette page."

#: pod/dressing/tests/test_views.py pod/dressing/views.py
msgid "You cannot edit this dressing."
msgstr "Vous ne pouvez pas éditer cet habillage."
Expand All @@ -2236,10 +2244,6 @@ msgstr "L’habillage a été supprimé."
msgid "You cannot create a video dressing."
msgstr "Vous ne pouvez pas créer d’habillage de vidéo."

#: pod/dressing/views.py
msgid "You cannot dress this video."
msgstr "Vous ne pouvez pas habiller cette vidéo."

#: pod/dressing/views.py
#, python-format
msgid "Dress the video “%s”"
Expand Down Expand Up @@ -2268,10 +2272,6 @@ msgstr "Vous ne pouvez pas supprimer cet habillage."
msgid "Deleting the dressing “%s”"
msgstr "Supprimer l’habillage « %s »"

#: pod/dressing/views.py
msgid "You cannot access this page."
msgstr "Vous ne pouvez pas accéder à cette page."

#: pod/enrichment/apps.py pod/enrichment/models.py
msgid "Enrichments"
msgstr "Enrichissements"
Expand Down Expand Up @@ -6194,10 +6194,6 @@ msgstr "Veuillez confirmer que vous souhaitez supprimer l’enregistrement"
msgid "Delete the recording"
msgstr "Supprimer l’enregistrement"

#: pod/meeting/templates/meeting/invite.html
msgid "Send invitations to the meeting"
msgstr "Envoyer des invitations à la réunion"

#: pod/meeting/templates/meeting/invite.html
msgid ""
"Add emails addresses in the form below and click send to invite to your "
Expand Down Expand Up @@ -6468,6 +6464,11 @@ msgstr "Vous ne pouvez pas consulter les enregistrements de cette réunion."
msgid "The recording has been deleted."
msgstr "L’enregistrement a été supprimé."

#: pod/meeting/views.py
#, python-format
msgid "Send invitations to the meeting “%s”"
msgstr "Envoyer des invitations à la réunion « %s »"

#: pod/meeting/views.py
msgid "You cannot invite for this meeting."
msgstr "Vous ne pouvez pas inviter à cette réunion."
Expand Down Expand Up @@ -6594,22 +6595,22 @@ msgstr "Vous ne pouvez pas redémarrer ce webinaire en direct."
#: pod/meeting/webinar.py
#, python-format
msgid "Webinar mode has been successfully started for “%s” meeting."
msgstr "Le mode webinaire a bien été démarré pour la réunion “%s”."
msgstr "Le mode webinaire a bien été démarré pour la réunion « %s »."

#: pod/meeting/webinar.py
#, python-format
msgid "Error to start webinar mode for “%s” meeting: %s"
msgstr "Erreur de démarrage du mode webinaire pour la réunion “%s” : %s"
msgstr "Erreur de démarrage du mode webinaire pour la réunion « %s » : %s"

#: pod/meeting/webinar.py
#, python-format
msgid "Webinar mode has been successfully stopped for “%s” meeting."
msgstr "Le mode webinaire a bien été arrêté pour la réunion “%s”."
msgstr "Le mode webinaire a bien été arrêté pour la réunion « %s »."

#: pod/meeting/webinar.py
#, python-format
msgid "Error to stop webinar mode for “%s” meeting: %s"
msgstr "Erreur dans l’arrêt du mode webinaire pour la réunion “%s” : %s"
msgstr "Erreur dans l’arrêt du mode webinaire pour la réunion « %s » : %s"

#: pod/meeting/webinar.py
msgid ""
Expand Down Expand Up @@ -7166,6 +7167,10 @@ msgstr "Liste de lecture : %(name)s"
msgid "The playlist has been deleted."
msgstr "La liste de lecture a été supprimée."

#: pod/playlist/views.py
msgid "You cannot access this playlist."
msgstr "Vous ne pouvez pas accéder à cette liste de lecture."

#: pod/playlist/views.py
#, python-format
msgid "Edit the playlist “%(pname)s”"
Expand Down
2 changes: 1 addition & 1 deletion pod/locale/fr/LC_MESSAGES/djangojs.po
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ msgid ""
msgstr ""
"Project-Id-Version: Esup-Pod\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-04-29 07:03+0000\n"
"POT-Creation-Date: 2024-05-06 12:38+0000\n"
"PO-Revision-Date: \n"
"Last-Translator: obado <[email protected]>\n"
"Language-Team: \n"
Expand Down
Loading

0 comments on commit f055954

Please sign in to comment.