Spaces:
Running
Running
Commit ·
83a1f47
1
Parent(s): dcd633e
implement showing only videos that are either unassigned or assigned to a current user
Browse files- Functions/caption_editor_functions.py +4 -3
- Functions/video_player_functions.py +8 -2
- app.py +2 -2
Functions/caption_editor_functions.py
CHANGED
|
@@ -26,9 +26,10 @@ def save_captions_to_db(df, video_id, user, video_pointer):
|
|
| 26 |
df_json = data.to_dict(orient="index")
|
| 27 |
default_app.database().child("video_captions").child(video_id).child("captions").set(df_json)
|
| 28 |
|
| 29 |
-
# Auto-assign:
|
| 30 |
-
|
| 31 |
-
|
|
|
|
| 32 |
return get_string("save_successful")
|
| 33 |
except Exception as e:
|
| 34 |
return f"{get_string('save_failed')} {str(e)}"
|
|
|
|
| 26 |
df_json = data.to_dict(orient="index")
|
| 27 |
default_app.database().child("video_captions").child(video_id).child("captions").set(df_json)
|
| 28 |
|
| 29 |
+
# Auto-assign: only if the video isn't already assigned to someone
|
| 30 |
+
existing_assignment = default_app.database().child("videos").child(str(video_pointer)).child("assigned_to").get().val()
|
| 31 |
+
if not existing_assignment:
|
| 32 |
+
default_app.database().child("videos").child(str(video_pointer)).child("assigned_to").set(user)
|
| 33 |
return get_string("save_successful")
|
| 34 |
except Exception as e:
|
| 35 |
return f"{get_string('save_failed')} {str(e)}"
|
Functions/video_player_functions.py
CHANGED
|
@@ -28,12 +28,15 @@ def get_video_embed_by_id(video_id):
|
|
| 28 |
|
| 29 |
|
| 30 |
# ADC-IMPLEMENTS: <gc-feature-assignment-01>
|
| 31 |
-
def get_video_link_by_pointer(pointer, show_incomplete_only):
|
| 32 |
-
"""Get video link
|
| 33 |
|
| 34 |
Args:
|
| 35 |
pointer: Video index in the database
|
| 36 |
show_incomplete_only: If True, skip videos marked as complete
|
|
|
|
|
|
|
|
|
|
| 37 |
|
| 38 |
Returns:
|
| 39 |
Video URL string, or None if the video is filtered out
|
|
@@ -43,6 +46,9 @@ def get_video_link_by_pointer(pointer, show_incomplete_only):
|
|
| 43 |
return None
|
| 44 |
if show_incomplete_only and video.get("complete", False):
|
| 45 |
return None
|
|
|
|
|
|
|
|
|
|
| 46 |
return video["url"]
|
| 47 |
|
| 48 |
|
|
|
|
| 28 |
|
| 29 |
|
| 30 |
# ADC-IMPLEMENTS: <gc-feature-assignment-01>
|
| 31 |
+
def get_video_link_by_pointer(pointer, show_incomplete_only, current_user=""):
|
| 32 |
+
"""Get video link, skipping completed videos and videos assigned to other users.
|
| 33 |
|
| 34 |
Args:
|
| 35 |
pointer: Video index in the database
|
| 36 |
show_incomplete_only: If True, skip videos marked as complete
|
| 37 |
+
current_user: Username of the current user. Videos assigned to
|
| 38 |
+
other users are skipped. Unassigned videos and videos assigned
|
| 39 |
+
to current_user are returned.
|
| 40 |
|
| 41 |
Returns:
|
| 42 |
Video URL string, or None if the video is filtered out
|
|
|
|
| 46 |
return None
|
| 47 |
if show_incomplete_only and video.get("complete", False):
|
| 48 |
return None
|
| 49 |
+
assigned_to = video.get("assigned_to")
|
| 50 |
+
if assigned_to and assigned_to != current_user:
|
| 51 |
+
return None
|
| 52 |
return video["url"]
|
| 53 |
|
| 54 |
|
app.py
CHANGED
|
@@ -158,13 +158,13 @@ def get_next_components(show_incomplete_only):
|
|
| 158 |
global next_video_pointer
|
| 159 |
next_video_link = placeholder_link
|
| 160 |
if next_video_pointer != -1:
|
| 161 |
-
next_video_link = get_video_link_by_pointer(next_video_pointer, show_incomplete_only)
|
| 162 |
next_video_pointer = (next_video_pointer + 1) % n_videos
|
| 163 |
|
| 164 |
for _ in range(n_videos + 1):
|
| 165 |
if next_video_link is not None:
|
| 166 |
break
|
| 167 |
-
next_video_link = get_video_link_by_pointer(next_video_pointer, show_incomplete_only)
|
| 168 |
next_video_pointer = (next_video_pointer + 1) % n_videos
|
| 169 |
if next_video_link is None:
|
| 170 |
next_video_link = placeholder_link
|
|
|
|
| 158 |
global next_video_pointer
|
| 159 |
next_video_link = placeholder_link
|
| 160 |
if next_video_pointer != -1:
|
| 161 |
+
next_video_link = get_video_link_by_pointer(next_video_pointer, show_incomplete_only, user)
|
| 162 |
next_video_pointer = (next_video_pointer + 1) % n_videos
|
| 163 |
|
| 164 |
for _ in range(n_videos + 1):
|
| 165 |
if next_video_link is not None:
|
| 166 |
break
|
| 167 |
+
next_video_link = get_video_link_by_pointer(next_video_pointer, show_incomplete_only, user)
|
| 168 |
next_video_pointer = (next_video_pointer + 1) % n_videos
|
| 169 |
if next_video_link is None:
|
| 170 |
next_video_link = placeholder_link
|