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 May 7, 2024
1 parent 72ec4b2 commit be94744
Show file tree
Hide file tree
Showing 11 changed files with 37 additions and 26 deletions.
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)
5 changes: 4 additions & 1 deletion pod/dressing/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ def video_dressing(request: WSGIRequest, slug: str):

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

if not (request.user.is_superuser or (request.user == video.owner and 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
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
6 changes: 1 addition & 5 deletions pod/meeting/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -977,11 +977,7 @@ def invite(request: WSGIRequest, meeting_id: str) -> HttpResponse:
return render(
request,
"meeting/invite.html",
{
"page_title": page_title,
"meeting": meeting,
"form": form
},
{"page_title": page_title, "meeting": meeting, "form": form},
)


Expand Down
18 changes: 12 additions & 6 deletions pod/playlist/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,9 @@ def get_count_video_added_in_playlist(video: Video) -> int:
return PlaylistContent.objects.filter(video=video).count()


def user_can_see_playlist_video(request: WSGIRequest, video: Video, playlist: Playlist) -> bool:
def user_can_see_playlist_video(
request: WSGIRequest, video: Video, playlist: Playlist
) -> bool:
"""
Check if the authenticated can see the playlist video.
Expand All @@ -338,11 +340,15 @@ def user_can_see_playlist_video(request: WSGIRequest, video: Video, playlist: Pl
or request.user.is_superuser
)
else:
return playlist.visibility == "private" and (
playlist.owner == request.user
or playlist in get_playlists_for_additional_owner(request.user)
or request.user.is_superuser
) or playlist.visibility in {"public", "protected"}
return (
playlist.visibility == "private"
and (
playlist.owner == request.user
or playlist in get_playlists_for_additional_owner(request.user)
or request.user.is_superuser
)
or playlist.visibility in {"public", "protected"}
)


def sort_playlist_list(playlist_list: list, sort_field: str, sort_direction="") -> list:
Expand Down
10 changes: 6 additions & 4 deletions pod/playlist/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,12 @@ def playlist_content(request: WSGIRequest, slug: str):
playlist.visibility == "public"
or playlist.visibility == "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_superuser)
request.user.is_authenticated
and (
playlist.owner == request.user
or playlist in get_playlists_for_additional_owner(request.user)
or request.user.is_superuser
)
)
):
return render_playlist(request, playlist, sort_field, sort_direction)
Expand Down
2 changes: 1 addition & 1 deletion pod/recorder/plugins/type_studio.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ def getElementsByName(xmldoc, name):
urlElement = element.getElementsByTagName("url")[0]
if urlElement.firstChild and urlElement.firstChild.data != "":
element_path = urlElement.firstChild.data[
urlElement.firstChild.data.index(MEDIA_URL) + len(MEDIA_URL):
urlElement.firstChild.data.index(MEDIA_URL) + len(MEDIA_URL) :
]
src = os.path.join(settings.MEDIA_ROOT, element_path)
if os.path.isfile(src):
Expand Down
4 changes: 2 additions & 2 deletions pod/recorder/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,13 +381,13 @@ def studio_pod(request):
)
head = opencast_studio_rendered[
opencast_studio_rendered.index("<head>")
+ len("<head>"): opencast_studio_rendered.index("</head>")
+ len("<head>") : opencast_studio_rendered.index("</head>")
]
scripts = re.findall('<script .[a-z="]+ src=".[a-z/.0-9]+"></script>', head)
styles = re.findall("<style>.*</style>", head)
body = opencast_studio_rendered[
opencast_studio_rendered.index("<body>")
+ len("<body>"): opencast_studio_rendered.index("</body>")
+ len("<body>") : opencast_studio_rendered.index("</body>")
]
body = "".join(scripts) + "".join(styles) + body
return render(
Expand Down
2 changes: 1 addition & 1 deletion pod/video/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ def get_videos(title, user_id, search=None, limit=12, offset=0):
results = list(
map(
lambda v: {"id": v.id, "title": v.title, "thumbnail": v.get_thumbnail_url()},
videos[offset: limit + offset],
videos[offset : limit + offset],
)
)

Expand Down
10 changes: 7 additions & 3 deletions pod/video/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ def _regroup_videos_by_theme(request, videos, channel, theme=None):
request.path, offset, limit, videos.count()
)
count = videos.count()
videos = videos[offset: limit + offset]
videos = videos[offset : limit + offset]
response = {
**response,
"videos": list(videos),
Expand Down Expand Up @@ -1084,7 +1084,9 @@ def video(request, slug, slug_c=None, slug_t=None, slug_private=None):
template_video = "videos/video-iframe.html"
elif request.GET.get("playlist"):
playlist = get_object_or_404(Playlist, slug=request.GET.get("playlist"))
if playlist_can_be_displayed(request, playlist) and user_can_see_playlist_video(request, video, playlist):
if playlist_can_be_displayed(request, playlist) and user_can_see_playlist_video(
request, video, playlist
):
videos = sort_videos_list(get_video_list_for_playlist(playlist), "rank")
params = {
"playlist_in_get": playlist,
Expand Down Expand Up @@ -1194,7 +1196,9 @@ def render_video(
if request.GET.get("playlist"):
playlist = get_object_or_404(Playlist, slug=request.GET.get("playlist"))
if not user_can_see_playlist_video(
request, video, playlist,
request,
video,
playlist,
):
toggle_render_video_when_is_playlist_player(request)
return render(
Expand Down
2 changes: 1 addition & 1 deletion pod/video_encode_transcript/transcript_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ def get_text_caption(text_caption, last_word_added):
"""Get the text for a caption."""
try:
first_index = text_caption.index(last_word_added)
return text_caption[first_index + 1:]
return text_caption[first_index + 1 :]
except ValueError:
return text_caption

Expand Down

0 comments on commit be94744

Please sign in to comment.