Skip to content

Commit

Permalink
Fixup. Format code with Black
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions committed Nov 10, 2023
1 parent 3040f59 commit d9cab36
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 25 deletions.
11 changes: 7 additions & 4 deletions pod/enrichment/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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)
12 changes: 10 additions & 2 deletions pod/enrichment/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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"))
Expand Down
15 changes: 6 additions & 9 deletions pod/playlist/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
)
20 changes: 11 additions & 9 deletions pod/playlist/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '<div id="more-script">%s</div>' % 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 = "<title>%s - %s</title>" % (
__TITLE_SITE__,
render_to_string(templates["page_title"], context, request),
Expand Down
4 changes: 3 additions & 1 deletion pod/video/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down

0 comments on commit d9cab36

Please sign in to comment.