diff --git a/pod/enrichment/tests/test_views.py b/pod/enrichment/tests/test_views.py index 29fca3d2e9..d322c47c64 100644 --- a/pod/enrichment/tests/test_views.py +++ b/pod/enrichment/tests/test_views.py @@ -192,14 +192,14 @@ def setUp(self): def test_access_video_enrichment(self): """Test the video enrichment access.""" self.client.force_login(self.user) - url = reverse('enrichment:video_enrichment', kwargs={'slug': self.video.slug}) + url = reverse("enrichment:video_enrichment", kwargs={"slug": self.video.slug}) response = self.client.get(url) self.assertEqual(response.status_code, 200) - self.assertTemplateUsed(response, 'enrichment/video_enrichment.html') + self.assertTemplateUsed(response, "enrichment/video_enrichment.html") def test_invalid_video_slug(self): """Test the view with invalid slug.""" - url = reverse('enrichment:video_enrichment', kwargs={'slug': 'invalid-slug'}) + url = reverse("enrichment:video_enrichment", kwargs={"slug": "invalid-slug"}) response = self.client.get(url) self.assertEqual(response.status_code, 400) @@ -211,6 +211,9 @@ def test_private_playlist_access(self): visibility="private", owner=self.user, ) - url = reverse('enrichment:video_enrichment', kwargs={'slug': self.video.slug}) + f'?playlist={playlist.slug}' + url = ( + reverse("enrichment:video_enrichment", kwargs={"slug": self.video.slug}) + + f"?playlist={playlist.slug}" + ) response = self.client.get(url) self.assertEqual(response.status_code, 403) diff --git a/pod/enrichment/views.py b/pod/enrichment/views.py index 83f93a36b8..c9f155caaa 100644 --- a/pod/enrichment/views.py +++ b/pod/enrichment/views.py @@ -237,7 +237,13 @@ def edit_enrichment_cancel(request, video): @csrf_protect @ensure_csrf_cookie -def video_enrichment(request: WSGIRequest, slug: str, slug_c: str = None, slug_t: str = None, slug_private: str = None) -> HttpResponse: +def video_enrichment( + request: WSGIRequest, + slug: str, + slug_c: str = None, + slug_t: str = None, + slug_private: str = None, +) -> HttpResponse: """ View to display a video in enrichment mode. @@ -264,7 +270,9 @@ def video_enrichment(request: WSGIRequest, slug: str, slug_c: str = None, slug_t "videos": videos, } else: - raise PermissionDenied(_("You cannot access this playlist because it is private.")) + raise PermissionDenied( + _("You cannot access this playlist because it is private.") + ) template_video = ( "enrichment/video_enrichment-iframe.html" if (request.GET.get("is_iframe")) diff --git a/pod/playlist/utils.py b/pod/playlist/utils.py index d9fcac9c71..f9e6f20a76 100644 --- a/pod/playlist/utils.py +++ b/pod/playlist/utils.py @@ -399,14 +399,11 @@ def playlist_can_be_displayed(request: WSGIRequest, playlist: Playlist) -> bool: Returns: bool: `True` if the current user can be see the playlist, `False` otherwise. """ - return ( - playlist.visibility in {"public", "protected"} - or ( - request.user.is_authenticated - and ( - playlist.owner == request.user - or playlist in get_playlists_for_additional_owner(request.user) - or request.user.is_staff - ) + return playlist.visibility in {"public", "protected"} or ( + request.user.is_authenticated + and ( + playlist.owner == request.user + or playlist in get_playlists_for_additional_owner(request.user) + or request.user.is_staff ) ) diff --git a/pod/playlist/views.py b/pod/playlist/views.py index 3027ae3525..690d4126ed 100644 --- a/pod/playlist/views.py +++ b/pod/playlist/views.py @@ -558,21 +558,23 @@ def get_video(request: WSGIRequest, video_slug: str, playlist_slug: str) -> Json "breadcrumbs": "playlist/playlist_breadcrumbs.html", "opengraph": "videos/video_opengraph.html", "more_script": "enrichment/video_enrichment_more_script.html", - "page_aside": "enrichment/video_enrichment_page_aside.html" if video_is_enrichment else "videos/video_page_aside.html", - "page_content": "enrichment/video_enrichment_page_content.html" if video_is_enrichment else "videos/video_page_content.html", - "page_title": "enrichment/video_enrichment_page_title.html" if video_is_enrichment else "videos/video_page_title.html" + "page_aside": "enrichment/video_enrichment_page_aside.html" + if video_is_enrichment + else "videos/video_page_aside.html", + "page_content": "enrichment/video_enrichment_page_content.html" + if video_is_enrichment + else "videos/video_page_content.html", + "page_title": "enrichment/video_enrichment_page_title.html" + if video_is_enrichment + else "videos/video_page_title.html", } - breadcrumbs = render_to_string( - templates["breadcrumbs"], context, request - ) + breadcrumbs = render_to_string(templates["breadcrumbs"], context, request) opengraph = render_to_string(templates["opengraph"], context, request) more_script = '
%s
' % render_to_string( templates["more_script"], context, request ) page_aside = render_to_string(templates["page_aside"], context, request) - page_content = render_to_string( - templates["page_content"], context, request - ) + page_content = render_to_string(templates["page_content"], context, request) page_title = "%s - %s" % ( __TITLE_SITE__, render_to_string(templates["page_title"], context, request), diff --git a/pod/video/views.py b/pod/video/views.py index b42e6658a3..a16ee0086e 100644 --- a/pod/video/views.py +++ b/pod/video/views.py @@ -886,7 +886,9 @@ def video(request, slug, slug_c=None, slug_t=None, slug_private=None): "videos": videos, } else: - raise PermissionDenied(_("You cannot access this playlist because it is private.")) + raise PermissionDenied( + _("You cannot access this playlist because it is private.") + ) return render_video(request, id, slug_c, slug_t, slug_private, template_video, params)