Skip to content

Commit

Permalink
Merge pull request #632 from AI4Bharat/reports_changes
Browse files Browse the repository at this point in the history
Modify Transliteration output and count in transcription reports
  • Loading branch information
Shruti1229 authored Jan 9, 2024
2 parents 910238f + 0a2652c commit aec8c84
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 16 deletions.
8 changes: 7 additions & 1 deletion backend/transcript/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1910,7 +1910,13 @@ def get_transcription_report(request):
"label": "Transcripted Duration (Hours)",
},
"transcripts_completed": {
"value": len(transcripts),
"value": len(
transcripts.filter(language=elem["language"]).filter(
video__project_id__organization_id__title=elem[
"video__project_id__organization_id__title"
]
)
),
"label": "Transcription Tasks Count",
},
}
Expand Down
17 changes: 15 additions & 2 deletions backend/users/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from organization.models import Invite, Organization
from organization.serializers import InviteGenerationSerializer
from organization.decorators import is_admin, is_organization_owner
from project.decorators import is_project_owner
from users.models import LANG_CHOICES, User
from rest_framework.decorators import action
from django.db.models import Q
Expand Down Expand Up @@ -531,7 +532,19 @@ def get_roles(self, request):
"""
Get all choices of role.
"""
data = [{"label": role[1], "value": role[0]} for role in User.ROLE_CHOICES]
if not request.user.is_anonymous:
user_role = request.user.role
if user_role == "ORG_OWNER":
data = [{"label": role[1], "value": role[0]} for role in User.ROLE_CHOICES[:8]]
elif user_role == "PROJECT_MANAGER":
data = [{"label": role[1], "value": role[0]} for role in User.ROLE_CHOICES[:7]]
elif user_role == "ADMIN":
data = [{"label": role[1], "value": role[0]} for role in User.ROLE_CHOICES[:9]]
else:
data = [{"label": role[1], "value": role[0]} for role in User.ROLE_CHOICES[:9]]
else:
data = [{"label": role[1], "value": role[0]} for role in User.ROLE_CHOICES[:9]]

return Response(data, status=status.HTTP_200_OK)

@swagger_auto_schema(
Expand All @@ -558,7 +571,7 @@ def get_roles(self, request):
name="Update user role",
url_name="update_user_role",
)
@is_organization_owner
@is_project_owner
def update_user_role(self, request, *args, **kwargs):
"""
API Endpoint to store parameter of youtube
Expand Down
14 changes: 1 addition & 13 deletions backend/video/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,19 +114,7 @@ def get(self, request, target_language, data, *args, **kwargs):
)

transliteration_output = response_transliteration.json()
if response_transliteration.status_code == 200:
response = {
"error": "",
"input": data,
"result": transliteration_output["output"][0]["target"],
"success": True,
}
else:
response = {"error": "", "input": data, "result": [], "success": False}
return Response(
response,
status=status.HTTP_200_OK,
)
return Response(transliteration_output, status=status.HTTP_200_OK)


@swagger_auto_schema(
Expand Down

0 comments on commit aec8c84

Please sign in to comment.