Skip to content

Commit

Permalink
Preview fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Shruti1229 committed Nov 8, 2023
1 parent cc651ec commit 7138af0
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 5 deletions.
22 changes: 20 additions & 2 deletions backend/transcript/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -389,9 +389,27 @@ def retrieve_transcription(request):
status=status.HTTP_200_OK,
)
else:
return Response(
{"message": "No transcript found"}, status=status.HTTP_404_NOT_FOUND
task = (
Task.objects.filter(video=video)
.filter(task_type="TRANSCRIPTION_EDIT")
.first()
)
transcript_obj = get_transcript_id(task)
if transcript_obj is not None:
transcript_payload = transcript_obj.payload
data = {}
data["payload"] = []
for segment in transcript_payload["payload"]:
if "text" in segment.keys() and len(segment["text"]) > 0:
data["payload"].append(segment)
return Response(
{"id": transcript_obj.id, "data": data},
status=status.HTTP_200_OK,
)
else:
return Response(
{"message": "No transcript found"}, status=status.HTTP_404_NOT_FOUND
)


def generate_transcription(video, lang, user, transcript_type, task, payload):
Expand Down
25 changes: 22 additions & 3 deletions backend/translation/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ def export_translation(request):
@api_view(["GET"])
def retrieve_translation(request):
"""
Endpoint to retrive a transcription for a transcription entry
Endpoint to retrive a translation for a translation entry
"""

# Check if video_id and language and transcript_type has been passed
Expand Down Expand Up @@ -296,9 +296,28 @@ def retrieve_translation(request):
status=status.HTTP_200_OK,
)
else:
return Response(
{"message": "No translation found"}, status=status.HTTP_404_NOT_FOUND
task = (
Task.objects.filter(video=video)
.filter(target_language=target_language)
.filter(task_type="TRANSLATION_EDIT")
.first()
)
translation_obj = get_translation_id(task)
if translation_obj is not None:
translation_payload = translation_obj.payload
data = {}
data["payload"] = []
for segment in translation_payload["payload"]:
if "target_text" in segment.keys() and len(segment["target_text"]) > 0:
data["payload"].append(segment)
return Response(
{"id": translation_obj.id, "data": data},
status=status.HTTP_200_OK,
)
else:
return Response(
{"message": "No translation found"}, status=status.HTTP_404_NOT_FOUND
)


def get_translation_id(task):
Expand Down

0 comments on commit 7138af0

Please sign in to comment.