From b84f5f10dafbcf9f9dc4ebc38028b31b72dc44cd Mon Sep 17 00:00:00 2001 From: Olivier Bado-Faustin Date: Tue, 21 May 2024 11:09:32 +0200 Subject: [PATCH] [DONE] BS 5 Accordion in completions (#1136) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Replace the old accordion in video completions by BS 5 Accordion (Thank's to Apolline Vandaele’s UX audit ;) * add line at end of file * Correct completion unit tests --- pod/completion/static/css/completion.css | 132 +++------- pod/completion/static/js/completion.js | 69 ++---- .../contributor/list_contributor.html | 77 +++--- .../templates/document/list_document.html | 76 +++--- .../templates/overlay/list_overlay.html | 78 +++--- .../templates/track/form_track.html | 48 ++-- .../templates/track/list_track.html | 107 ++++----- .../templates/video_completion.html | 226 +++++++++--------- pod/completion/tests/test_views.py | 76 +++--- pod/completion/utils.py | 3 + pod/completion/views.py | 2 +- 11 files changed, 399 insertions(+), 495 deletions(-) diff --git a/pod/completion/static/css/completion.css b/pod/completion/static/css/completion.css index b228cbff4f..f715213cb6 100644 --- a/pod/completion/static/css/completion.css +++ b/pod/completion/static/css/completion.css @@ -2,87 +2,12 @@ * Esup-Pod completion styles */ -/** Table scroll **/ -table.scroll { - width: 100%; - border-collapse: collapse; - border-spacing: 0; -} - -table.scroll .btn-sm, -table.scroll .btn-group-sm > .btn { - border-radius: 4px; - font-size: 14px; - line-height: 1.4; - padding: 0.2em 0.4em; -} - -table.scroll tbody { - max-height: 100px; - overflow-y: auto; - overflow-x: hidden; -} - -table.scroll tbody td, -table.scroll thead th { - width: 10%; - height: 20px; - line-height: 20px; - border-bottom: 0; -} - -table.scroll thead tr th { - height: 27px; - line-height: 27px; - text-align: left; -} - /** Table contributor **/ -table#table_list_contributors tbody td.contributor_name, -table#table_list_contributors thead th.contributor_name { +table#list-contributor tbody td.contributor-name, +table#list-contributor thead th.contributor-name { width: 20%; } -/** Accordeon for lists **/ -#accordeon li, -#accordeon div { - list-style: none; -} - -/** Lists style **/ -#list_contributor .panel-heading, -#list_track .panel-heading, -#list_document .panel-heading, -#list_overlay .panel-heading { - border-bottom: 1px solid transparent; - border-top-left-radius: 3px; - border-top-right-radius: 3px; - padding: 4px 15px; -} - -#id_background { - margin-left: 0.25rem; - position: inherit; -} - -.contenuTitre { - display: flex; - flex-direction: column; -} - -.contenuTitre #list_track { - order: 1; -} - -.contenuTitre .breadcrumb { - padding: 0; -} - -.contenuTitre .btn { - margin-bottom: 1rem; - margin-right: 1rem; -} - /***** Override track list *****/ .grid-list-track .division { @@ -90,36 +15,44 @@ table#table_list_contributors thead th.contributor_name { border-bottom: 1px solid #ccc; } -.grid-list-track .track_kind.options .btn { +.track-kind.options .btn { + margin: 0; + padding: 0.2em 0.4em; + font-size: 1rem; + box-sizing: border-box; +} + +.grid-list-track .track-kind.options .btn { font-size: 14px; } -.grid-list-track .track_kind.options a.btn { +.grid-list-track .track-kind.options a.btn { overflow: unset; align-self: self-start; } -.grid-list-track .track_kind.options .dropdown #dropdownMenuButton { +.grid-list-track .track-kind.options .dropdown #track-menu-button { background-color: var(--pod-primary); color: #fff; border-color: var(--pod-primary); border-radius: 4px; } -.grid-list-track .track_kind.options .dropdown .dropdown-item { +.grid-list-track .track-kind.options .dropdown .dropdown-item { background-color: #fff; } -.grid-list-track .track_kind.options .dropdown .btn { + +.grid-list-track .track-kind.options .dropdown .btn { width: 100%; } -.grid-list-track .track_kind.options .dropdown { +.grid-list-track .track-kind.options .dropdown { display: none; background-color: #fff; } -.grid-list-track .thead_title { +.grid-list-track .thead-title { margin: 0; padding-right: 20px; color: var(--pod-primary); @@ -139,30 +72,23 @@ table#table_list_contributors thead th.contributor_name { margin-top: 1em; } -.grid-list-track .track_kind.file { +.grid-list-track .track-kind.file { word-break: break-word; } -.track_kind.options { +.track-kind.options { display: grid; grid-template-columns: repeat(3, 1fr); grid-column-gap: 10px; } -.track_kind.options .btn { - margin: 0; - padding: 0.2em 0.4em; - font-size: 1rem; - box-sizing: border-box; -} - -@media only screen and (max-width: 840px) { - .grid-list-track .track_kind.options .dropdown { +@media only screen and (width <= 840px) { + .grid-list-track .track-kind.options .dropdown { display: inline-block; } - .grid-list-track .track_kind.options > form, - .grid-list-track .track_kind.options > #modifCapSubFile { + .grid-list-track .track-kind.options > form, + .grid-list-track .track-kind.options > #modif-cap-sub-file { display: none; } } @@ -174,11 +100,9 @@ ul.css-tabs a { box-sizing: content-box; } -textarea#id_description { - line-height: normal; -} - -/** Bootstrap override **/ -.card-title { - margin: 0.45rem; +.caption{ + padding-top: .5rem; + color: var(--bs-secondary-color); + text-align: left; + font-size: 1em; } diff --git a/pod/completion/static/js/completion.js b/pod/completion/static/js/completion.js index 06c46abe4d..19988a3a9b 100644 --- a/pod/completion/static/js/completion.js +++ b/pod/completion/static/js/completion.js @@ -7,34 +7,8 @@ global fadeIn */ -document.addEventListener("DOMContentLoaded", function () { - document.querySelectorAll("li.contenuTitre").forEach(function (element) { - element.style.display = "none"; - }); - var accordeon_head = document.querySelectorAll("#accordeon li a.title"); - if (accordeon_head.length <= 0) return; - accordeon_head[0].classList.add("active"); - let sibling = accordeon_head[0].parentNode.nextElementSibling; - slideDown(sibling, 500); - - // Click on .titre - accordeon_head.forEach((element) => { - addEventListener("click", (event) => { - if (event.target != element) return; - event.preventDefault(); - if (element.getAttribute("class") != "title active") { - slideToggle(element.parentNode.nextElementSibling); - element.classList.add("active"); - } else if (element.getAttribute("class") == "title active") { - slideUp(element.parentNode.nextElementSibling); - element.classList.remove("active"); - } - }); - }); -}); - // Video form -var num = 0; +//var num = 0; var name = ""; function show_form(data, form) { @@ -45,7 +19,6 @@ function show_form(data, form) { form_el.querySelectorAll("script").forEach((item) => { if (item.src) { // external script - let script = document.createElement("script"); script.src = item.src; document.body.appendChild(script); @@ -85,7 +58,7 @@ document.addEventListener("submit", (e) => { return; e.preventDefault(); - var jqxhr = ""; + // var jqxhr = ""; var exp = /_([a-z]*)\s?/g; var id_form = e.target.getAttribute("id"); var name_form = ""; @@ -104,7 +77,7 @@ document.addEventListener("submit", (e) => { var list = "list_" + name_form; var action = e.target.querySelector("input[name=action]").value; sendAndGetForm(e.target, action, name_form, form, list) - .then((r) => "") + .then(() => "") .catch((e) => console.log("error", e)); }); @@ -123,7 +96,6 @@ var sendAndGetForm = async function (elt, action, name, form, list) { var href = elt.getAttribute("action"); let url = window.location.origin + href; let token = elt.csrfmiddlewaretoken.value; - var id = elt.querySelector("input[name=id]").value; if (action === "new" || action === "form_save_new") { document.getElementById(form).innerHTML = @@ -197,9 +169,10 @@ var sendAndGetForm = async function (elt, action, name, form, list) { document.querySelectorAll("a.title").forEach(function (element) { element.style.display = "none"; }); - hide_others_sections(name); + //hide_others_sections(name); } if (action == "modify" || action == "form_save_modify") { + let id = elt.querySelector("input[name=id]").value; let form_data = new FormData(); form_data.append("action", action); form_data.append("id", id); @@ -234,29 +207,29 @@ var sendAndGetForm = async function (elt, action, name, form, list) { }); document.querySelector("a.title").style.display = "none"; - hide_others_sections(name); + // hide_others_sections(name); } - if (action == "delete") { + if (action === "delete") { var deleteConfirm = ""; - if (name == "track") { + if (name === "track") { deleteConfirm = confirm( gettext("Are you sure you want to delete this file?"), ); - } else if (name == "contributor") { + } else if (name === "contributor") { deleteConfirm = confirm( gettext("Are you sure you want to delete this contributor?"), ); - } else if (name == "document") { + } else if (name === "document") { deleteConfirm = confirm( gettext("Are you sure you want to delete this document?"), ); - } else if (name == "overlay") { + } else if (name === "overlay") { deleteConfirm = confirm( gettext("Are you sure you want to delete this overlay?"), ); } if (deleteConfirm) { - id = elt.querySelector("input[name=id]").value; + let id = elt.querySelector("input[name=id]").value; url = window.location.origin + href; token = document.querySelector("input[name=csrfmiddlewaretoken]").value; let form_data = new FormData(); @@ -342,7 +315,7 @@ var sendAndGetForm = async function (elt, action, name, form, list) { }; // Hide others sections -function hide_others_sections(name_form) { +/*function hide_others_sections(name_form) { var allElements = document.querySelectorAll("a.title.active"); var sections = []; let form = document.querySelector('a[id="section_' + name_form + '"]'); @@ -366,7 +339,7 @@ function hide_others_sections(name_form) { section.firstElementChild.className = "glyphicon glyphicon-chevron-down"; } } -} +}*/ // Refreshes the list function refresh_list(data, form, list) { @@ -375,9 +348,7 @@ function refresh_list(data, form, list) { document.querySelectorAll("form").forEach(function (element) { element.style.display = "block"; }); - document.querySelectorAll("a.title").forEach(function (element) { - element.style.display = "initial"; - }); + if (data.player) { document.getElementById("enrich_player").innerHTML = data.player; } @@ -434,11 +405,11 @@ function verify_fields(form) { var new_role = document.getElementById("id_role").value; var new_name = document.getElementById("id_name").value; document - .querySelectorAll("#table_list_contributors tbody > tr") + .querySelectorAll("#list-contributor tbody > tr") .forEach((tr) => { if ( id != tr.querySelector("input[name=id]").value && - tr.querySelector("td[class=contributor_name]").innerHTML == + tr.querySelector("td[class=contributor-name]").innerHTML == new_name && tr.querySelector("td[class=contributor_role]").innerHTML == new_role ) { @@ -514,18 +485,18 @@ function verify_fields(form) { var is_duplicate = false; var file_name = file_abs_path.match(/([\w\d_-]+)(\.vtt)/)[1].toLowerCase(); document - .querySelectorAll(".grid-list-track .track_kind.kind") + .querySelectorAll(".grid-list-track .track-kind.kind") .forEach((elt) => { if ( kind === elt.textContent.trim().toLowerCase() && lang === elt.parentNode - .querySelector("#" + elt.get("id") + ".track_kind.lang") + .querySelector("#" + elt.get("id") + ".track-kind.lang") .textContent.trim() .toLowerCase() && file_name === elt.parentNode - .querySelector("#" + elt.get("id") + ".track_kind.file") + .querySelector("#" + elt.get("id") + ".track-kind.file") .textContent.trim() .split(" ")[0] .toLowerCase() diff --git a/pod/completion/templates/contributor/list_contributor.html b/pod/completion/templates/contributor/list_contributor.html index 7164ca69db..285eb19eb8 100644 --- a/pod/completion/templates/contributor/list_contributor.html +++ b/pod/completion/templates/contributor/list_contributor.html @@ -1,42 +1,41 @@ {# HTML for contributor list. Don't use this file alone it must be integrated into another template! #} {% load i18n %} -
-
-

{% trans 'List of contributors' %} ({{list_contributor|length}})

-
- - - - - - - - - - - - {% for contributor in list_contributor %} - - - - - - - - {% endfor %} - -
{% trans 'Lastname / Firstname' %}{% trans 'Mail' %}{% trans 'Role' %}{% trans 'Web link' %}{% trans 'Actions' %}
{{contributor.name}}{{contributor.email_address|default_if_none:' '}}{% trans contributor.role %} -
- {% csrf_token %} - - - -
-
- {% csrf_token %} - - - -
-
+ +
+ + + + + + + + + + + + + {% for contributor in list_contributor %} + + + + + + + + {% endfor %} + +
{% trans 'List of contributors' %} ({{list_contributor|length}})
{% trans 'Lastname / Firstname' %}{% trans 'Mail' %}{% trans 'Role' %}{% trans 'Web link' %}{% trans 'Actions' %}
{{contributor.name}}{{contributor.email_address|default_if_none:' '}}{% trans contributor.role %} +
+ {% csrf_token %} + + + +
+
+ {% csrf_token %} + + + +
+
diff --git a/pod/completion/templates/document/list_document.html b/pod/completion/templates/document/list_document.html index 016d2dc9a3..87d57c2849 100644 --- a/pod/completion/templates/document/list_document.html +++ b/pod/completion/templates/document/list_document.html @@ -1,42 +1,40 @@ {# HTML for document list. Don't use this file alone it must be integrated into another template! #} {% load i18n %} -
-
-

{% trans 'List of additional resources' %} ({{list_document|length}})

-
- - - - - - - - - {% for doc in list_document %} - - - - - {% endfor %} - -
{% trans 'Document' %}{% trans 'Actions' %}
{{doc.document.name}} ({{ doc.document.file_ext }}) - {% if doc.private %} - - {% else %} - - {% endif %} - -
- {% csrf_token %} - - - -
-
- {% csrf_token %} - - - -
-
+
+ + + + + + + + + + {% for doc in list_document %} + + + + + {% endfor %} + +
{% trans 'List of additional resources' %} ({{list_document|length}})
{% trans 'Document' %}{% trans 'Actions' %}
{{doc.document.name}} ({{ doc.document.file_ext }}) + {% if doc.private %} + + {% else %} + + {% endif %} + +
+ {% csrf_token %} + + + +
+
+ {% csrf_token %} + + + +
+
diff --git a/pod/completion/templates/overlay/list_overlay.html b/pod/completion/templates/overlay/list_overlay.html index 7ab65e0a87..ec932b1499 100644 --- a/pod/completion/templates/overlay/list_overlay.html +++ b/pod/completion/templates/overlay/list_overlay.html @@ -1,42 +1,40 @@ {# HTML for Overlays list. Don't use this file alone it must be integrated into another template! #} {% load i18n %} -
-
-

{% trans 'List of overlays' %} ({{list_overlay|length}})

-
- - - - - - - - - - - - {% for overlay in list_overlay %} - - - - - - - - {% endfor %} - -
{% trans 'Title' %}{% trans 'Start' %}{% trans 'End' %}{% trans 'Position' %}{% trans 'Actions' %}
{{overlay.title}}{{overlay.time_start}}{{overlay.time_end}}{{overlay.position}} -
- {% csrf_token %} - - - -
-
- {% csrf_token %} - - - -
-
-
\ No newline at end of file +
+ + + + + + + + + + + + + {% for overlay in list_overlay %} + + + + + + + + {% endfor %} + +
{% trans 'List of overlays' %} ({{list_overlay|length}})
{% trans 'Title' %}{% trans 'Start' %}{% trans 'End' %}{% trans 'Position' %}{% trans 'Actions' %}
{{overlay.title}}{{overlay.time_start}}{{overlay.time_end}}{{overlay.position}} +
+ {% csrf_token %} + + + +
+
+ {% csrf_token %} + + + +
+
+
diff --git a/pod/completion/templates/track/form_track.html b/pod/completion/templates/track/form_track.html index 4e5af42f74..64ea5986c3 100644 --- a/pod/completion/templates/track/form_track.html +++ b/pod/completion/templates/track/form_track.html @@ -3,30 +3,30 @@ {% load static %}
- {% csrf_token %} -
- {% if form_track.errors or form_track.non_field_errors %} - {% trans 'Your form contains errors:' %}
- {% for error in form_track.non_field_errors %} - - {{error}}
- {% endfor %} - {% endif %} - {% for field_hidden in form_track.hidden_fields %} - {{field_hidden}} - {% endfor %} - {% for field in form_track.visible_fields %} -
- -
{{field}}
-
- {% endfor %} - {% if form_track.instance %} - - {% endif %} - - - {% trans 'Cancel' %} -
+ {% csrf_token %} +
+ {% if form_track.errors or form_track.non_field_errors %} + {% trans 'Your form contains errors:' %}
+ {% for error in form_track.non_field_errors %} + - {{error}}
+ {% endfor %} + {% endif %} + {% for field_hidden in form_track.hidden_fields %} + {{field_hidden}} + {% endfor %} + {% for field in form_track.visible_fields %} +
+ +
{{field}}
+
+ {% endfor %} + {% if form_track.instance %} + + {% endif %} + + + {% trans 'Cancel' %} +
{{form_track.media}}
diff --git a/pod/completion/templates/track/list_track.html b/pod/completion/templates/track/list_track.html index 42b5c6fc63..0095ca5ac4 100644 --- a/pod/completion/templates/track/list_track.html +++ b/pod/completion/templates/track/list_track.html @@ -1,59 +1,56 @@ {# HTML for track list. Don't use this file alone it must be integrated into another template! #} {% load i18n %} -
-
-

{% trans 'List of subtitle or caption files' %} ({{list_track|length}})

-
-
- {% trans 'Kind' %} - {% trans 'Language' %} - {% trans 'Video track file' %} - {% trans 'Actions' %} - {% for track in list_track %} -

{% trans track.kind %}

-

{{track.lang}}

-

{{track.src.name}} ({{track.src.file_type}})

-
-
- {% csrf_token %} - - - -
- {% trans 'Modify' %} -
- {% csrf_token %} - - - -
- -
- {% if not forloop.last %} -
- {% endif %} - {% endfor %} + +

{% trans 'List of subtitle or caption files' %} ({{list_track|length}})

+ +
+ {% trans 'Kind' %} + {% trans 'Language' %} + {% trans 'Video track file' %} + {% trans 'Actions' %} + {% for track in list_track %} +

{% trans track.kind %}

+

{{track.lang}}

+

{{track.src.name}} ({{track.src.file_type}})

+
+
+ {% csrf_token %} + + + +
+ {% trans 'Modify' %} +
+ {% csrf_token %} + + + +
+
+ {% if not forloop.last %} +
+ {% endif %} + {% endfor %}
diff --git a/pod/completion/templates/video_completion.html b/pod/completion/templates/video_completion.html index f840eb6f52..b51a5cadaf 100644 --- a/pod/completion/templates/video_completion.html +++ b/pod/completion/templates/video_completion.html @@ -10,115 +10,119 @@ {% endblock page_extra_head %} {% block breadcrumbs %} {{block.super}} - - - -{% endblock %} -{% block page_content %} - -
-
  • - - {% trans 'Contributor(s)' %}  +
  • + -
  • - - {% include 'contributor/list_contributor.html' %} - -   - - {% if form_contributor %} - {% include 'contributor/form_contributor.html' with form_contributor=form_contributor %} - {% endif %} - -
    - {% csrf_token %} - - -
    +
  • -   +{% endblock %} +{% block page_content %} + +
    +
    +

    + +

    +
    +
    + {% include 'contributor/list_contributor.html' %} + + {% if form_contributor %} + {% include 'contributor/form_contributor.html' with form_contributor=form_contributor %} + {% endif %} + +
    + {% csrf_token %} + + +
    +
    +
    +
    + {% if request.user.is_staff %} -
  • - - {% trans 'Subtitle(s) and Caption(s)' %}  - -
  • -
  • - - {% include 'track/list_track.html' with dest='video_completion_track' %} - -   -
  • -   -
  • - - {% trans 'Additional resource(s)' %}  - -
  • -
  • - - {% include 'document/list_document.html' %} - -   - - {% if form_document %} - {% include 'document/form_document.html' with form_document=form_document %} - {% endif %} - -
    - {% csrf_token %} - - -
    -
  • -   -
  • - - {% trans 'Overlay(s)' %}  - -
  • -
  • - - {% include 'overlay/list_overlay.html' %} - -   - - {% if form_overlay %} - {% include 'overlay/form_overlay.html' with form_overlay=form_overlay %} - {% endif %} - -
    - {% csrf_token %} - - -
    -
  • -   {% endif %}
    {% endblock page_content %} @@ -127,7 +131,9 @@ {% if video.owner == request.user or request.user.is_superuser or perms.video.change_video or request.user in video.additional_owners.all %}
    -

     {% trans "Manage video"%}

    +

    +  {% trans "Manage video"%} +

    {% include "videos/link_video.html" with hide_favorite_link=True %}
    @@ -158,10 +164,16 @@

    {% trans "Help"%}

    {% trans 'You will need the URL of this video to make subtitles and/or captions. This URL is a direct access to this video. Please do not communicate it outside of this site to avoid any misuse.' %}

      {% for vid in video.get_video_mp4 %} -
    • {{vid.name}}:
    • +
    • + + +
    • {% endfor %} {% if video.is_video == False and video.get_video_mp3 %} -
    • {{video.get_video_mp3.name}}:
    • +
    • + + +
    • {% endif %}
    diff --git a/pod/completion/tests/test_views.py b/pod/completion/tests/test_views.py index b439ed95e1..1310eb157f 100644 --- a/pod/completion/tests/test_views.py +++ b/pod/completion/tests/test_views.py @@ -33,6 +33,8 @@ class CompletionViewsTestCase(TestCase): + """Test cases for the Pod video completion views.""" + fixtures = [ "initial_data.json", ] @@ -78,7 +80,7 @@ def test_video_completion_user(self) -> None: self.assertEqual(response.status_code, 200) self.assertTemplateUsed(response, "video_completion.html") self.assertContains(response, "videotest") - self.assertContains(response, "list_contributor") + self.assertContains(response, "list-contributor") print(" ---> test_video_completion_user: OK!") @@ -94,10 +96,10 @@ def test_video_completion_staff(self) -> None: self.assertEqual(response.status_code, 200) self.assertTemplateUsed(response, "video_completion.html") self.assertContains(response, "videotest2") - self.assertContains(response, "list_contributor") - self.assertContains(response, "list_track") - self.assertContains(response, "list_document") - self.assertContains(response, "list_overlay") + self.assertContains(response, "list-contributor") + self.assertContains(response, "list-track") + self.assertContains(response, "list-document") + self.assertContains(response, "list-overlay") print(" ---> test_video_completion_staff: OK!") @@ -137,10 +139,10 @@ def test_video_completion_contributor(self) -> None: self.assertEqual(response.status_code, 200) self.assertTemplateUsed(response, "video_completion.html") self.assertContains(response, "videotest2") - self.assertContains(response, "list_contributor") - self.assertContains(response, "list_track") - self.assertContains(response, "list_document") - self.assertContains(response, "list_overlay") + self.assertContains(response, "list-contributor") + self.assertContains(response, "list-track") + self.assertContains(response, "list-document") + self.assertContains(response, "list-overlay") print(" [ BEGIN COMPLETION_CONTRIBUTOR VIEWS ] ") print(" ---> test_video_completion_contributor: OK!") @@ -172,7 +174,7 @@ def test_video_completion_contributor_new(self) -> None: ) self.assertEqual(response.status_code, 200) self.assertTemplateUsed(response, "video_completion.html") - self.assertContains(response, "list_contributor") + self.assertContains(response, "list-contributor") self.assertContains(response, "testcontributor") self.assertContains(response, "test@test.com") @@ -208,7 +210,7 @@ def test_video_completion_contributor_edit(self) -> None: }, ) self.assertEqual(response.status_code, 200) - self.assertContains(response, "list_contributor") + self.assertContains(response, "list-contributor") result = Contributor.objects.get(id=1) self.assertEqual(result.name, "testcontributor") response = self.client.post( @@ -230,7 +232,7 @@ def test_video_completion_contributor_edit(self) -> None: }, ) self.assertEqual(response.status_code, 200) - self.assertContains(response, "list_contributor") + self.assertContains(response, "list-contributor") self.assertContains(response, "testcontributor2") self.assertContains(response, _("editor")) result = Contributor.objects.get(id=1) @@ -264,7 +266,7 @@ def test_video_completion_contributor_delete(self) -> None: }, ) self.assertEqual(response.status_code, 200) - self.assertContains(response, "list_contributor") + self.assertContains(response, "list-contributor") result = Contributor.objects.get(id=1) self.assertEqual(result.name, "testcontributor") @@ -316,10 +318,10 @@ def test_video_completion_track(self) -> None: self.assertEqual(response.status_code, 200) self.assertTemplateUsed(response, "video_completion.html") self.assertContains(response, "videotest2") - self.assertContains(response, "list_contributor") - self.assertContains(response, "list_track") - self.assertContains(response, "list_document") - self.assertContains(response, "list_overlay") + self.assertContains(response, "list-contributor") + self.assertContains(response, "list-track") + self.assertContains(response, "list-document") + self.assertContains(response, "list-overlay") print(" [ BEGIN COMPLETION_TRACK VIEWS ] ") print(" ---> test_video_completion_track: OK!") @@ -366,7 +368,7 @@ def test_video_completion_track_new(self) -> None: ) self.assertEqual(response.status_code, 200) self.assertTemplateUsed(response, "video_completion.html") - self.assertContains(response, "list_track") + self.assertContains(response, "list-track") result = Track.objects.get(id=1) self.assertEqual(result.kind, "subtitles") self.assertTrue("testfile" in result.src.name) @@ -416,7 +418,7 @@ def test_video_completion_track_edit(self): }, ) self.assertEqual(response.status_code, 200) - self.assertContains(response, "list_track") + self.assertContains(response, "list-track") result = Track.objects.get(id=1) self.assertTrue("testfile" in result.src.name) # self.assertEqual(result.src.name, 'testfile') @@ -438,7 +440,7 @@ def test_video_completion_track_edit(self): }, ) self.assertEqual(response.status_code, 200) - self.assertContains(response, "list_track") + self.assertContains(response, "list-track") result = Track.objects.get(id=1) self.assertEqual(result.kind, "captions") self.assertEqual(result.lang, "de") @@ -486,7 +488,7 @@ def test_video_completion_track_delete(self): }, ) self.assertEqual(response.status_code, 200) - self.assertContains(response, "list_track") + self.assertContains(response, "list-track") result = Track.objects.get(id=1) self.assertTrue("testfile" in result.src.name) # self.assertEqual(result.src.name, 'testfile') @@ -538,10 +540,10 @@ def test_video_completion_document(self) -> None: self.assertEqual(response.status_code, 200) self.assertTemplateUsed(response, "video_completion.html") self.assertContains(response, "videotest2") - self.assertContains(response, "list_contributor") - self.assertContains(response, "list_track") - self.assertContains(response, "list_document") - self.assertContains(response, "list_overlay") + self.assertContains(response, "list-contributor") + self.assertContains(response, "list-track") + self.assertContains(response, "list-document") + self.assertContains(response, "list-overlay") print(" [ BEGIN COMPLETION_DOCUMENT VIEWS ] ") print(" ---> test_video_completion_document: OK!") @@ -587,7 +589,7 @@ def test_video_completion_document_new(self) -> None: self.assertEqual(response.status_code, 200) self.assertTemplateUsed(response, "video_completion.html") - self.assertContains(response, "list_document") + self.assertContains(response, "list-document") result = Document.objects.get(id=1) # self.assertEqual(result.document.name, 'testfile') self.assertTrue("testfile" in result.document.name) @@ -636,7 +638,7 @@ def test_video_completion_document_edit(self) -> None: self.assertEqual(response.status_code, 200) self.assertTemplateUsed(response, "video_completion.html") - self.assertContains(response, "list_document") + self.assertContains(response, "list-document") result = Document.objects.get(id=1) # self.assertEqual(result.document.name, 'testfile') self.assertTrue("testfile" in result.document.name) @@ -672,7 +674,7 @@ def test_video_completion_document_edit(self) -> None: }, ) self.assertEqual(response.status_code, 200) - self.assertContains(response, "list_document") + self.assertContains(response, "list-document") result = Document.objects.get(id=1) # self.assertEqual(result.document.name, 'testfile2') self.assertTrue("testfile2" in result.document.name) @@ -717,7 +719,7 @@ def test_video_completion_document_delete(self) -> None: }, ) self.assertEqual(response.status_code, 200) - self.assertContains(response, "list_document") + self.assertContains(response, "list-document") result = Document.objects.get(id=1) # self.assertEqual(result.document.name, 'testfile') self.assertTrue("testfile" in result.document.name) @@ -766,10 +768,10 @@ def test_video_completion_overlay(self) -> None: self.assertEqual(response.status_code, 200) self.assertTemplateUsed(response, "video_completion.html") self.assertContains(response, "videotest2") - self.assertContains(response, "list_contributor") - self.assertContains(response, "list_track") - self.assertContains(response, "list_document") - self.assertContains(response, "list_overlay") + self.assertContains(response, "list-contributor") + self.assertContains(response, "list-track") + self.assertContains(response, "list-document") + self.assertContains(response, "list-overlay") print(" [ BEGIN COMPLETION_OVERLAY VIEWS ] ") print(" ---> test_video_completion_overlay: OK!") @@ -800,7 +802,7 @@ def test_video_completion_overlay_new(self) -> None: ) self.assertEqual(response.status_code, 200) self.assertTemplateUsed(response, "video_completion.html") - self.assertContains(response, "list_overlay") + self.assertContains(response, "list-overlay") result = Overlay.objects.get(id=1) self.assertEqual(result.title, "testoverlay") @@ -835,7 +837,7 @@ def test_video_completion_overlay_edit(self) -> None: ) self.assertEqual(response.status_code, 200) self.assertTemplateUsed(response, "video_completion.html") - self.assertContains(response, "list_overlay") + self.assertContains(response, "list-overlay") result = Overlay.objects.get(id=1) self.assertEqual(result.title, "testoverlay") response = self.client.post( @@ -859,7 +861,7 @@ def test_video_completion_overlay_edit(self) -> None: }, ) self.assertEqual(response.status_code, 200) - self.assertContains(response, "list_overlay") + self.assertContains(response, "list-overlay") result = Overlay.objects.get(id=1) self.assertEqual(result.title, "testoverlay2") self.assertEqual(result.time_end, 3) @@ -895,7 +897,7 @@ def test_video_completion_overlay_delete(self) -> None: }, ) self.assertEqual(response.status_code, 200) - self.assertContains(response, "list_overlay") + self.assertContains(response, "list-overlay") result = Overlay.objects.get(id=1) self.assertEqual(result.title, "testoverlay") response = self.client.post( diff --git a/pod/completion/utils.py b/pod/completion/utils.py index 512bf7ef2f..cac57c35c0 100644 --- a/pod/completion/utils.py +++ b/pod/completion/utils.py @@ -1,5 +1,7 @@ """Esup-Pod completion app utilities.""" +from django.utils.translation import ugettext as _ + def get_video_completion_context( video, @@ -38,6 +40,7 @@ def get_video_completion_context( "form_document": form_document, "form_track": form_track, "form_overlay": form_overlay, + "page_title": _("Additions for the video “%s”") % video.title } return context diff --git a/pod/completion/views.py b/pod/completion/views.py index 81b3ecd545..dabd7c8d08 100644 --- a/pod/completion/views.py +++ b/pod/completion/views.py @@ -48,7 +48,7 @@ } -def get_completion_home_page_title(video: Video): +def get_completion_home_page_title(video: Video) -> str: """Get page title.""" return _("Additions for the video “%s”") % video.title