From 924af8a2f950d5ad216388ab58602eebfedbbdfa Mon Sep 17 00:00:00 2001 From: Aymeric Jakobowski <106442526+AymericJak@users.noreply.github.com> Date: Mon, 29 Apr 2024 15:03:34 +0200 Subject: [PATCH] [DONE] Fix bugfixes for 3.6.0 (#1117) * Fix notification error & improve upload file form * Improve video tokens page (messages & titles) * Fix some h1 titles in completion page * Improve video infos * Make some improvements * Improve dashboard (remove required action, improve reset button) * Show different message when dashboard action is "delete" * Fix duplicate ID in dashboard table view * Reset dashboard action when submit changes * Fix navbar splitting in 2 lines when there's profile picture * Add some improvements * PR requests & fix unit tests * Improve cards & aside collapse * Fix video time display in video controlbar * Fix JS problems & improve podfile * Add video_dreessing help informations * Change page_title in video completion page * Add translations & reformat files * Remove dressings permissions & improve QoC * Update translations * Add some views tests for dressings --- pod/chapter/templates/video_chapter.html | 1 + .../contributor/list_contributor.html | 4 +- .../templates/video_completion.html | 3 +- pod/completion/views.py | 70 ++- pod/cut/views.py | 2 +- pod/dressing/templates/dressing_delete.html | 8 +- pod/dressing/templates/dressing_edit.html | 66 ++- pod/dressing/templates/my_dressings.html | 190 ++++---- pod/dressing/templates/video_dressing.html | 221 +++++---- pod/dressing/tests/test_views.py | 70 +++ pod/dressing/views.py | 30 +- pod/import_video/views.py | 4 +- pod/live/templates/live/event-info.html | 3 - pod/locale/fr/LC_MESSAGES/django.mo | Bin 198918 -> 201297 bytes pod/locale/fr/LC_MESSAGES/django.po | 240 ++++++---- pod/locale/fr/LC_MESSAGES/djangojs.mo | Bin 20668 -> 20963 bytes pod/locale/fr/LC_MESSAGES/djangojs.po | 12 +- pod/locale/nl/LC_MESSAGES/django.mo | Bin 1985 -> 1923 bytes pod/locale/nl/LC_MESSAGES/django.po | 183 +++++--- pod/locale/nl/LC_MESSAGES/djangojs.po | 79 +--- pod/main/forms_utils.py | 4 +- pod/main/static/css/pod.css | 35 +- pod/main/templates/aside.html | 3 - pod/main/templates/navbar.html | 4 +- .../templates/meeting/add_or_edit.html | 2 +- pod/playlist/static/playlist/css/playlist.css | 1 + .../static/playlist/js/add-or-edit.js | 9 +- .../js/filter-aside-playlist-list-refresh.js | 2 +- .../static/playlist/js/utils-playlist.js | 58 +-- .../templates/playlist/add_or_edit.html | 2 +- .../templates/playlist/playlist_card.html | 24 +- .../playlist/playlist_visibility_icon.html | 8 +- pod/podfile/static/podfile/css/podfile.css | 2 +- pod/podfile/static/podfile/js/filewidget.js | 32 +- pod/video/static/css/videojs-controlbar.css | 15 + pod/video/static/js/dashboard.js | 43 +- pod/video/static/js/video_select.js | 25 +- pod/video/templates/videos/add_video.html | 5 + pod/video/templates/videos/dashboard.html | 4 +- pod/video/templates/videos/link_video.html | 7 +- pod/video/templates/videos/video-info.html | 438 +++++++++--------- .../templates/videos/video_access_tokens.html | 6 +- pod/video/templates/videos/video_edit.html | 3 +- .../videos/video_list_grid_selectable.html | 5 +- .../templates/videos/video_row_select.html | 2 +- pod/video/tests/test_views.py | 4 +- pod/video/views.py | 4 +- 47 files changed, 1141 insertions(+), 792 deletions(-) diff --git a/pod/chapter/templates/video_chapter.html b/pod/chapter/templates/video_chapter.html index ed4640c4d7..d37b76ac4c 100644 --- a/pod/chapter/templates/video_chapter.html +++ b/pod/chapter/templates/video_chapter.html @@ -48,6 +48,7 @@ {% endblock page_content %} + {% block page_aside %} {% if video.owner == request.user or request.user.is_superuser or perms.chapter.add_chapter or request.user in video.additional_owners.all %}
diff --git a/pod/completion/templates/contributor/list_contributor.html b/pod/completion/templates/contributor/list_contributor.html index 922907664b..7164ca69db 100644 --- a/pod/completion/templates/contributor/list_contributor.html +++ b/pod/completion/templates/contributor/list_contributor.html @@ -26,13 +26,13 @@

{% trans 'List of contributors' %} ( {% csrf_token %} - +
{% csrf_token %} - +
diff --git a/pod/completion/templates/video_completion.html b/pod/completion/templates/video_completion.html index bbeaefbf95..125781dd7c 100644 --- a/pod/completion/templates/video_completion.html +++ b/pod/completion/templates/video_completion.html @@ -2,7 +2,6 @@ {% extends 'base.html' %} {% load i18n %} {% load static %} -{% block page_title %}{% trans 'Video additions' %} "{{video.title}}"{% endblock page_title %} {% block page_extra_head %} @@ -36,7 +35,7 @@   {% if form_contributor %} - {% include 'contributor/form_contributor.html' with form_contributor=form_contributor %} + {% include 'contributor/form_contributor.html' with form_contributor=form_contributor %} {% endif %}
diff --git a/pod/completion/views.py b/pod/completion/views.py index 0535bc7553..248a9d4fd9 100644 --- a/pod/completion/views.py +++ b/pod/completion/views.py @@ -11,6 +11,7 @@ from django.contrib.auth.decorators import login_required from django.contrib.admin.views.decorators import staff_member_required from django.core.exceptions import PermissionDenied +from django.core.handlers.wsgi import WSGIRequest from pod.video.models import Video from .models import Contributor from .forms import ContributorForm @@ -47,6 +48,11 @@ } +def get_completion_home_page_title(video: Video): + """Get page title.""" + return _("Additions for the video “%s”") % video.title + + @csrf_protect @staff_member_required(redirect_field_name="referrer") def video_caption_maker(request, slug): @@ -169,9 +175,10 @@ def video_caption_maker_save(request, video): @csrf_protect @login_required(redirect_field_name="referrer") -def video_completion(request, slug): +def video_completion(request: WSGIRequest, slug: str): """Video Completion view.""" video = get_object_or_404(Video, slug=slug, sites=get_current_site(request)) + page_title = get_completion_home_page_title(video) if ( request.user != video.owner and not ( @@ -202,12 +209,12 @@ def video_completion(request, slug): request, "video_completion.html", { + "page_title": page_title, "video": video, "list_contributor": list_contributor, "list_track": list_track, "list_document": list_document, "list_overlay": list_overlay, - "page_title": _("Video additions"), }, ) else: @@ -215,18 +222,19 @@ def video_completion(request, slug): request, "video_completion.html", { + "page_title": page_title, "video": video, "list_contributor": list_contributor, - "page_title": _("Video additions"), }, ) @csrf_protect @login_required(redirect_field_name="referrer") -def video_completion_contributor(request, slug): +def video_completion_contributor(request: WSGIRequest, slug: str): """View to manage contributors of a video.""" video = get_object_or_404(Video, slug=slug, sites=get_current_site(request)) + page_title = get_completion_home_page_title(video) if request.user != video.owner and not ( request.user.is_superuser or request.user.has_perm("completion.add_contributor") @@ -256,12 +264,12 @@ def video_completion_contributor(request, slug): request, "video_completion.html", { + "page_title": page_title, "video": video, "list_contributor": list_contributor, "list_track": list_track, "list_document": list_document, "list_overlay": list_overlay, - "page_title": _("Video additions"), }, ) else: @@ -269,22 +277,27 @@ def video_completion_contributor(request, slug): request, "video_completion.html", { + "page_title": page_title, "video": video, "list_contributor": list_contributor, - "page_title": _("Video additions"), }, ) -def video_completion_contributor_new(request, video): +def video_completion_contributor_new(request: WSGIRequest, video: Video): """View to add new contributor to a video.""" form_contributor = ContributorForm(initial={"video": video}) context = get_video_completion_context(video, form_contributor=form_contributor) + context["page_title"] = _("Add a new contributor to the video “%s”") % video.title if request.is_ajax(): return render( request, "contributor/form_contributor.html", - {"form_contributor": form_contributor, "video": video}, + { + "page_title": context["page_title"], + "form_contributor": form_contributor, + "video": video, + }, ) else: return render( @@ -294,7 +307,7 @@ def video_completion_contributor_new(request, video): ) -def video_completion_contributor_save(request, video): +def video_completion_contributor_save(request: WSGIRequest, video: Video): """View to save contributors of a video.""" form_contributor = None if request.POST.get("contributor_id") and request.POST["contributor_id"] != "None": @@ -309,7 +322,12 @@ def video_completion_contributor_save(request, video): some_data_to_dump = { "list_data": render_to_string( "contributor/list_contributor.html", - {"list_contributor": list_contributor, "video": video}, + { + "page_title": _("Add a new contributor to the video “%s”") + % video.title, + "list_contributor": list_contributor, + "video": video, + }, request=request, ), } @@ -319,6 +337,10 @@ def video_completion_contributor_save(request, video): context = get_video_completion_context( video, list_contributor=list_contributor ) + context["page_title"] = get_completion_home_page_title(video) + messages.add_message( + request, messages.SUCCESS, _("The contributor has been saved.") + ) return render( request, "video_completion.html", @@ -330,13 +352,19 @@ def video_completion_contributor_save(request, video): "errors": "{0}".format(_("Please correct errors")), "form": render_to_string( "contributor/form_contributor.html", - {"video": video, "form_contributor": form_contributor}, + { + "page_title": _("Add a new contributor to the video “%s”") + % video.title, + "video": video, + "form_contributor": form_contributor, + }, request=request, ), } data = json.dumps(some_data_to_dump) return HttpResponse(data, content_type="application/json") context = get_video_completion_context(video, form_contributor=form_contributor) + context["page_title"] = get_completion_home_page_title(video) return render( request, "video_completion.html", @@ -344,17 +372,23 @@ def video_completion_contributor_save(request, video): ) -def video_completion_contributor_modify(request, video): +def video_completion_contributor_modify(request: WSGIRequest, video: Video): """View to modify a video contributor.""" contributor = get_object_or_404(Contributor, id=request.POST["id"]) form_contributor = ContributorForm(instance=contributor) + page_title = _("Edit the contributor “%s”") % contributor.name if request.is_ajax(): return render( request, "contributor/form_contributor.html", - {"form_contributor": form_contributor, "video": video}, + { + "page_title": page_title, + "form_contributor": form_contributor, + "video": video, + }, ) context = get_video_completion_context(video, form_contributor=form_contributor) + context["page_title"] = page_title return render( request, "video_completion.html", @@ -362,22 +396,28 @@ def video_completion_contributor_modify(request, video): ) -def video_completion_contributor_delete(request, video): +def video_completion_contributor_delete(request: WSGIRequest, video: Video): """View to delete a video contributor.""" contributor = get_object_or_404(Contributor, id=request.POST["id"]) contributor.delete() + page_title = get_completion_home_page_title(video) list_contributor = video.contributor_set.all() if request.is_ajax(): some_data_to_dump = { "list_data": render_to_string( "contributor/list_contributor.html", - {"list_contributor": list_contributor, "video": video}, + { + "page_title": page_title, + "list_contributor": list_contributor, + "video": video, + }, request=request, ) } data = json.dumps(some_data_to_dump) return HttpResponse(data, content_type="application/json") context = get_video_completion_context(video) + context["page_title"] = page_title return render( request, "video_completion.html", diff --git a/pod/cut/views.py b/pod/cut/views.py index b1150f4418..6bff49b9ac 100644 --- a/pod/cut/views.py +++ b/pod/cut/views.py @@ -79,7 +79,7 @@ def cut_video(request, slug): # noqa: C901 start_encode(video.id) - messages.add_message(request, messages.INFO, _("The cut was made.")) + messages.add_message(request, messages.SUCCESS, _("The cut was made.")) return redirect(reverse("video:dashboard")) else: diff --git a/pod/dressing/templates/dressing_delete.html b/pod/dressing/templates/dressing_delete.html index e36e0ccd4d..e6366402ce 100644 --- a/pod/dressing/templates/dressing_delete.html +++ b/pod/dressing/templates/dressing_delete.html @@ -4,8 +4,12 @@ {% block breadcrumbs %} {{ block.super }} - - + + {% endblock %} {% block page_content %} diff --git a/pod/dressing/templates/dressing_edit.html b/pod/dressing/templates/dressing_edit.html index f07ed87eba..0c38c1cccd 100644 --- a/pod/dressing/templates/dressing_edit.html +++ b/pod/dressing/templates/dressing_edit.html @@ -7,23 +7,21 @@ {% endblock page_extra_head %} -{% block breadcrumbs %}{{ block.super }} - +{% block breadcrumbs %} + {{ block.super }} + - + {% endblock %} {% block page_content %} - + {% csrf_token %}

@@ -33,30 +31,30 @@

{% trans "One or more errors have been found in the form." %}

{% endif %} {% for field_hidden in form.hidden_fields %} - {{field_hidden}} + {{ field_hidden }} {% endfor %} {% for field in form.visible_fields %} - {% spaceless %} -
-
-
- {{ field.errors }} - {% if "form-check-input" in field.field.widget.attrs.class %} -
- {{ field }} -
- {% else %} - - {{ field }} - {% endif %} - {% if field.help_text %} - {{ field.help_text|safe }} - {% endif %} - {% if field.field.required %}
{% trans "Please provide a valid value for this field." %}
{% endif %} + {% spaceless %} +
+
+
+ {{ field.errors }} + {% if "form-check-input" in field.field.widget.attrs.class %} +
+ {{ field }} +
+ {% else %} + + {{ field }} + {% endif %} + {% if field.help_text %} + {{ field.help_text|safe }} + {% endif %} + {% if field.field.required %}
{% trans "Please provide a valid value for this field." %}
{% endif %} +
-
- {% endspaceless %} + {% endspaceless %} {% endfor %}
@@ -74,5 +72,5 @@

- {{form.media}} + {{ form.media }} {% endblock more_script %} diff --git a/pod/dressing/templates/my_dressings.html b/pod/dressing/templates/my_dressings.html index 8cfcb966de..14711c212f 100644 --- a/pod/dressing/templates/my_dressings.html +++ b/pod/dressing/templates/my_dressings.html @@ -7,108 +7,108 @@ {% endblock page_extra_head %} {% block breadcrumbs %} - {{block.super}} + {{ block.super }} {% endblock %} {% block page_content %} -
- - - - - - - - - - - - - - - - - - {% for dressing in dressings %} +
+
{% trans 'Available video dressings' %}
{% trans 'Title' %}{% trans 'Owners' %}{% trans 'Users' %}{% trans 'Allow to Groups' %}{% trans 'Watermark' %}{% trans 'Position' %}{% trans 'Opacity' %}{% trans 'Opening credits' %}{% trans 'Ending credits' %}{% trans 'Actions' %}
+ + - - + + + + + + + + + + - {% empty %} - - - - {% endfor %} - -
{% trans 'Available video dressings' %}
{{ dressing.title }} - {% for owner in dressing.owners.all %} - {{ owner }} - {% if not forloop.last %}, {% endif %} - {% empty %} - {% trans 'No owners' %} - {% endfor %} - - {% for user in dressing.users.all %} - {{ user }} - {% if not forloop.last %}, {% endif %} - {% empty %} - {% trans 'No users' %} - {% endfor %} - - {% for group in dressing.allow_to_groups.all %} - {{ group }}{% if not forloop.last %}, {% endif %} - {% empty %} - {% trans 'No groups' %} - {% endfor %} - - {% if dressing.watermark %} - {{ dressing.watermark.name }} - {% else %} - {% trans 'None' %} - {% endif %} - - {% if dressing.watermark %} - {{ dressing.get_position_display }} - {% else %} -
- -
- {% endif %} -
- {% if dressing.watermark %} - {{ dressing.opacity }} - {% else %} -
- -
- {% endif %} -
- {% if dressing.opening_credits %} - {{ dressing.opening_credits }} - {% else %} - {% trans 'None' %} - {% endif %} - - {% if dressing.ending_credits %} - {{ dressing.ending_credits }} - {% else %} - {% trans 'None' %} - {% endif %} - - - {% trans 'Title' %}{% trans 'Owners' %}{% trans 'Users' %}{% trans 'Allow to Groups' %}{% trans 'Watermark' %}{% trans 'Position' %}{% trans 'Opacity' %}{% trans 'Opening credits' %}{% trans 'Ending credits' %}{% trans 'Actions' %}
{% trans 'No dressings found.' %}
-
-{% trans 'Add new dressing' %} + + + {% for dressing in dressings %} + + {{ dressing.title }} + + {% for owner in dressing.owners.all %} + {{ owner }} + {% if not forloop.last %}, {% endif %} + {% empty %} + {% trans 'No owners' %} + {% endfor %} + + {% for user in dressing.users.all %} + {{ user }} + {% if not forloop.last %}, {% endif %} + {% empty %} + {% trans 'No users' %} + {% endfor %} + + {% for group in dressing.allow_to_groups.all %} + {{ group }}{% if not forloop.last %}, {% endif %} + {% empty %} + {% trans 'No groups' %} + {% endfor %} + + {% if dressing.watermark %} + {{ dressing.watermark.name }} + {% else %} + {% trans 'None' %} + {% endif %} + + {% if dressing.watermark %} + {{ dressing.get_position_display }} + {% else %} +
+ +
+ {% endif %} + + {% if dressing.watermark %} + {{ dressing.opacity }} + {% else %} +
+ +
+ {% endif %} + + {% if dressing.opening_credits %} + {{ dressing.opening_credits }} + {% else %} + {% trans 'None' %} + {% endif %} + + {% if dressing.ending_credits %} + {{ dressing.ending_credits }} + {% else %} + {% trans 'None' %} + {% endif %} + + + + + {% empty %} + + {% trans 'No dressings found.' %} + + {% endfor %} + + +

+ {% trans 'Add new dressing' %} {% endblock page_content %} {% block collapse_page_aside %}{% endblock collapse_page_aside %} diff --git a/pod/dressing/templates/video_dressing.html b/pod/dressing/templates/video_dressing.html index 3271cd16cc..5cf342b5bf 100644 --- a/pod/dressing/templates/video_dressing.html +++ b/pod/dressing/templates/video_dressing.html @@ -24,116 +24,143 @@ {% endblock %} {% block page_content %} + {% if video.encoding_in_progress %} + + {% endif %} -{% if video.encoding_in_progress %} - -{% endif %} - - - {% include 'videos/video-element.html' %} - + + {% include 'videos/video-element.html' %} + - - {% csrf_token %} -
- {% trans 'Pick a dressing below' %} - - - - - - - - - - - - - - - {% for dressing in dressings %} + + {% csrf_token %} +
+ {% trans 'Pick a dressing below' %} +
{% trans 'Available video dressings' %}
{% trans 'Select' %}{% trans 'Title' %}{% trans 'Watermark' %}{% trans 'Position' %}{% trans 'Opacity' %}{% trans 'Opening credits' %}{% trans 'Ending credits' %}
+ + - - - - - + + + + + + + - {% empty %} - - - - {% endfor %} - -
{% trans 'Available video dressings' %}
- - - {% if dressing.watermark %} - {{ dressing.watermark.name }} - {% else %} - {% trans 'None' %} - {% endif %} - - {% if dressing.watermark %} - {{ dressing.get_position_display }} - {% else %} -
- -
- {% endif %} -
- {% if dressing.watermark %} - {{ dressing.opacity }} - {% else %} -
- -
- {% endif %} -
- {% if dressing.opening_credits %} - {{ dressing.opening_credits }} - {% else %} - {% trans 'None' %} - {% endif %} - - {% if dressing.ending_credits %} - {{ dressing.ending_credits }} - {% else %} - {% trans 'None' %} - {% endif %} - {% trans 'Select' %}{% trans 'Title' %}{% trans 'Watermark' %}{% trans 'Position' %}{% trans 'Opacity' %}{% trans 'Opening credits' %}{% trans 'Ending credits' %}
{% trans 'No dressings found.' %}
-
- - - - - -  {% trans 'My dressings' %} - -  {% trans 'Back to the video' %} - - + + + {% for dressing in dressings %} + + + + + + + {% if dressing.watermark %} + {{ dressing.watermark.name }} + {% else %} + {% trans 'None' %} + {% endif %} + + + {% if dressing.watermark %} + {{ dressing.get_position_display }} + {% else %} +
+   +
+ {% endif %} + + + {% if dressing.watermark %} + {{ dressing.opacity }} + {% else %} +
+   +
+ {% endif %} + + + {% if dressing.opening_credits %} + {{ dressing.opening_credits }} + {% else %} + {% trans 'None' %} + {% endif %} + + + {% if dressing.ending_credits %} + {{ dressing.ending_credits }} + {% else %} + {% trans 'None' %} + {% endif %} + + + {% empty %} + + {% trans 'No dressings found.' %} + + {% endfor %} + + + + + + + +  {% trans 'My dressings' %} + +  {% trans 'Back to the video' %} + + {% endblock page_content %} {% block page_aside %} - {% if access_not_allowed == True %} - {% else %} -
-

 {% trans "Manage video" %}

-
- {% include "videos/link_video.html" with hide_favorite_link=True %} -
+
+

 {% trans "Manage video" %}

+
+ {% include "videos/link_video.html" with hide_favorite_link=True %}
- {% endif %} +
+ +
+

{% trans "Help"%}

+ +
+

+ {% trans "Dressings are a way to customize your video. You can add a watermark, opening and ending credits" %} +

+
+ + +
+

+ {% trans "A watermark is an image that will be displayed on the video. You can choose the position and the opacity of the watermark." %} +

+
+ + +
+

+ {% trans "Opening and ending credits are videos that will be displayed at the beginning or at the end of the video." %} +

+
+
{% endblock page_aside %} {% block more_script %} diff --git a/pod/dressing/tests/test_views.py b/pod/dressing/tests/test_views.py index 8fdd78855a..ca32b15aa8 100644 --- a/pod/dressing/tests/test_views.py +++ b/pod/dressing/tests/test_views.py @@ -61,6 +61,43 @@ def test_video_dressing_page(self): self.assertTemplateUsed(response, "video_dressing.html") print(" ---> test_video_dressing_page ok") + def test_video_encoding_in_progress(self): + """Test video encoding in progress in VideoDressingViewTest.""" + self.first_video.encoding_in_progress = True + self.first_video.save() + self.client.force_login(self.user) + response = self.client.get( + reverse("dressing:video_dressing", args=[self.first_video.slug]) + ) + messages = [m for m in get_messages(response.wsgi_request)] + + self.assertEqual(response.status_code, 403) + self.assertEqual(len(messages), 1) + self.assertEqual(messages[0].tags, "error") + self.assertEqual( + messages[0].message, _("The video is currently being encoded.") + ) + print(" ---> test_video_encoding_in_progress ok") + + def test_video_dressing_permission_denied(self): + """Test test_video_dressing_permission_denied in VideoDressingViewTest.""" + user_without_permission = User.objects.create_user( + username="useless_user", password="testpass" + ) + self.client.force_login(user_without_permission) + response = self.client.get( + reverse("dressing:video_dressing", args=[self.first_video.slug]) + ) + messages = [m for m in get_messages(response.wsgi_request)] + + self.assertEqual(response.status_code, 403) + self.assertEqual(len(messages), 1) + self.assertEqual(messages[0].tags, "error") + self.assertEqual( + messages[0].message, _("You cannot dress this video.") + ) + print(" ---> test_video_dressing_permission_denied ok") + class MyDressingViewTest(TestCase): """My dressing page tests case.""" @@ -109,6 +146,23 @@ def test_my_dressing_page(self): self.assertTemplateUsed(response, "my_dressings.html") print(" ---> test_my_dressing_page ok") + def test_my_dressing_permission_denied(self): + """Test test_my_dressing_permission_denied in MyDressingViewTest.""" + user_without_permission = User.objects.create_user( + username="useless_user", password="testpass" + ) + self.client.force_login(user_without_permission) + response = self.client.get(reverse("dressing:my_dressings")) + messages = [m for m in get_messages(response.wsgi_request)] + + self.assertEqual(response.status_code, 403) + self.assertEqual(len(messages), 1) + self.assertEqual(messages[0].tags, "error") + self.assertEqual( + messages[0].message, _("You cannot access this page.") + ) + print(" ---> test_my_dressing_permission_denied ok") + class DressingEditViewTest(TestCase): """Dressing edit page tests case.""" @@ -180,6 +234,22 @@ def setUp(self) -> None: self.dressing.users.set([self.user]) self.dressing.videos.set([self.first_video]) + def test_maintenance(self): + """Test Pod maintenance mode in VideoDressingViewTest.""" + self.client.force_login(self.user) + url = reverse("dressing:dressing_delete", args=[self.dressing.id]) + response = self.client.get(url) + self.assertEqual(response.status_code, 200) + + conf = Configuration.objects.get(key="maintenance_mode") + conf.value = "1" + conf.save() + + response = self.client.get(url) + self.assertEqual(response.status_code, 302) + self.assertRedirects(response, "/maintenance/") + print(" ---> test_maintenance ok") + def test_dressing_delete_view_get(self): """Test test_dressing_delete_view_get.""" self.client.force_login(self.user) diff --git a/pod/dressing/views.py b/pod/dressing/views.py index c7e65a274b..cfbfa415ba 100644 --- a/pod/dressing/views.py +++ b/pod/dressing/views.py @@ -25,6 +25,7 @@ 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.") @@ -36,7 +37,6 @@ def video_dressing(request, slug): if not ( request.user.is_superuser or request.user.is_staff - or request.user.has_perm("dressing.video_dressing") ): messages.add_message(request, messages.ERROR, _("You cannot dress this video.")) raise PermissionDenied @@ -67,10 +67,10 @@ def video_dressing(request, slug): request, "video_dressing.html", { + "page_title": _("Dress the video “%s”") % video.title, "video": video, "dressings": dressings, "current": current, - "page_title": _("Dress the video “%s”") % video.title, }, ) @@ -85,7 +85,6 @@ def dressing_edit(request, dressing_id): not ( request.user.is_superuser or request.user.is_staff - or request.user.has_perm("dressing.dressing_edit") ) ): messages.add_message(request, messages.ERROR, _("You cannot edit this dressing.")) @@ -110,14 +109,14 @@ def dressing_edit(request, dressing_id): ) form_dressing.save() return redirect(reverse("dressing:my_dressings")) - page_title = f'{_("Editing the dressing")} "{dressing_edit.title}"' + page_title = _("Edit the dressing “%s”") % dressing_edit.title return render( request, "dressing_edit.html", { + "page_title": page_title, "dressing_edit": dressing_edit, "form": form_dressing, - "page_title": page_title, }, ) @@ -129,7 +128,6 @@ def dressing_create(request): if not ( request.user.is_superuser or request.user.is_staff - or request.user.has_perm("dressing.my_dressings") ): messages.add_message( request, messages.ERROR, _("You cannot create a video dressing.") @@ -148,8 +146,8 @@ def dressing_create(request): request, "dressing_edit.html", { - "dressing_create": dressing_create, "page_title": _("Create a new dressing"), + "dressing_create": dressing_create, "form": form_dressing, }, ) @@ -160,12 +158,13 @@ def dressing_create(request): def dressing_delete(request, dressing_id): """Delete the dressing identified by 'id'.""" dressing = get_object_or_404(Dressing, id=dressing_id) + if in_maintenance(): + return redirect(reverse("maintenance")) if dressing and ( not ( request.user.is_superuser or request.user.is_staff - or request.user.has_perm("dressing.dressing_delete") ) ): messages.add_message( @@ -194,9 +193,9 @@ def dressing_delete(request, dressing_id): request, "dressing_delete.html", { + "page_title": _("Deleting the dressing “%s”") % dressing.title, "dressing": dressing, "form": form, - "page_title": _("Deleting the dressing “%s”") % dressing.title, }, ) @@ -205,19 +204,22 @@ def dressing_delete(request, dressing_id): @login_required(redirect_field_name="referrer") def my_dressings(request): """Render the logged user's dressings.""" + if in_maintenance(): + return redirect(reverse("maintenance")) + if not ( request.user.is_superuser or request.user.is_staff - or request.user.has_perm("dressing.my_dressings") ): messages.add_message(request, messages.ERROR, _("You cannot access this page.")) raise PermissionDenied - if in_maintenance(): - return redirect(reverse("maintenance")) - dressings = get_dressings(request.user, request.user.owner.accessgroup_set.all()) + dressings = get_dressings(request.user, request.user.owner.accessgroup_set.all()) return render( request, "my_dressings.html", - {"dressings": dressings, "page_title": _("My dressings")}, + { + "page_title": _("My dressings"), + "dressings": dressings, + }, ) diff --git a/pod/import_video/views.py b/pod/import_video/views.py index c312bd663c..1e045a27a0 100644 --- a/pod/import_video/views.py +++ b/pod/import_video/views.py @@ -287,7 +287,7 @@ def add_or_edit_external_recording(request, id=None): if form.is_valid(): recording = save_recording_form(request, form) display_message_with_icon( - request, messages.INFO, _("The changes have been saved.") + request, messages.SUCCESS, _("The changes have been saved.") ) return redirect(reverse("import_video:external_recordings")) else: @@ -348,7 +348,7 @@ def delete_external_recording(request, id: int): msg += args["message"] if delete and msg == "": msg += _("The external recording has been deleted.") - display_message_with_icon(request, messages.INFO, msg) + display_message_with_icon(request, messages.SUCCESS, msg) else: display_message_with_icon(request, messages.ERROR, msg) return redirect(reverse("import_video:external_recordings", args=())) diff --git a/pod/live/templates/live/event-info.html b/pod/live/templates/live/event-info.html index 8bf28ec9b1..9d4f44fdbb 100644 --- a/pod/live/templates/live/event-info.html +++ b/pod/live/templates/live/event-info.html @@ -93,19 +93,16 @@
diff --git a/pod/main/templates/navbar.html b/pod/main/templates/navbar.html index 53d339e57d..f3e0526a7f 100644 --- a/pod/main/templates/navbar.html +++ b/pod/main/templates/navbar.html @@ -202,7 +202,7 @@
{% trans 'Configuration' %}
{% if user.is_authenticated %} - {% endif %} + +
    + {% for vid in video.get_video_mp4 %} + {% if vid.source_file|file_exists %} +
  • +
    + {% csrf_token %} + + +
    +
  • + {% endif %} {% endfor %}
- - + {% if video.get_video_mp3 %} {% trans 'Audio file:' %}
    @@ -275,173 +278,180 @@

{% endif %} - - {% endif %} - - {% if video.document_set.all %} - {% trans 'Document:' %} -
    - {% for doc in video.document_set.all %} - {% if request.user.is_superuser or not doc.private %} -
  • -
    - {% csrf_token %} - - - {% if request.user.is_superuser %} - {% if doc.private %} - - {% else %} - - {% endif %} + {% if video.document_set.all %} + +  {% trans 'Document:' %} + +
      + {% for doc in video.document_set.all %} + {% if request.user.is_superuser or not doc.private %} +
    • + + {% csrf_token %} + + + {% if request.user.is_superuser %} + {% if doc.private %} + + {% else %} + {% endif %} -
    • - - {% endif %} - {% endfor%} -
    - {% endif %} - + {% endif %} + +
  • + {% endif %} + {% endfor%} +
+ {% endif %}

-{% if video.is_draft == False or video.owner == request.user or request.user in video.additional_owners.all%} -