Skip to content

Commit

Permalink
Change "hidden" default behavior, reflecting new frontend design with
Browse files Browse the repository at this point in the history
only one table
  • Loading branch information
JonasKs committed Apr 13, 2022
1 parent 2efd398 commit 5f180ba
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions app/api/api_v2/endpoints/video/list_videos.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ async def get_all_files(
user: CognitoUser | None = Depends(cognito_scheme_or_anonymous),
username: Optional[str] = None,
name: Optional[str] = None,
hidden: bool = False,
hidden: Optional[bool] = None,
tag: list[str] = Query(default=[]),
offset: int = 0,
limit: int = Query(default=100, lte=100),
Expand All @@ -43,11 +43,22 @@ async def get_all_files(
video_statement = video_statement.where(Video.user.has(name=username)) # type: ignore
if name:
video_statement = video_statement.where(Video.display_name.contains(name)) # type: ignore
if user and hidden:

if user and hidden is None:
# Default behavior, include your own hidden videos
video_statement = video_statement.where(
or_(
and_(Video.hidden == True, Video.user.has(name=user.username)), # type:ignore # noqa
Video.hidden == False,
)
)
elif user and hidden:
# Only show your own hidden videos
video_statement = video_statement.where(
and_(Video.hidden == True, Video.user.has(name=user.username)), # type:ignore # noqa
)
else:
# Do not show any hidden videos
video_statement = video_statement.where(Video.hidden == False) # noqa

if tag:
Expand Down

0 comments on commit 5f180ba

Please sign in to comment.