diff --git a/edxval/api.py b/edxval/api.py index b7455066..363a8ad5 100644 --- a/edxval/api.py +++ b/edxval/api.py @@ -382,7 +382,7 @@ def create_or_update_video_transcript(video_id, language_code, metadata, file_da raise InvalidTranscriptFormat(f'{file_format} transcript format is not supported') provider = metadata.get('provider') - if provider and provider not in list(dict(TranscriptProviderType.CHOICES).keys()): + if provider and provider not in list(dict(TranscriptProviderType.TRANSCRIPT_MODEL_CHOICES).keys()): raise InvalidTranscriptProvider(f'{provider} transcript provider is not supported') try: diff --git a/edxval/migrations/0004_add_edx_ai_translations_provider.py b/edxval/migrations/0004_add_edx_ai_translations_provider.py new file mode 100644 index 00000000..1750ef32 --- /dev/null +++ b/edxval/migrations/0004_add_edx_ai_translations_provider.py @@ -0,0 +1,18 @@ +# Generated by Django 4.2.16 on 2024-11-27 17:14 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('edxval', '0003_delete_transcriptcredentials'), + ] + + operations = [ + migrations.AlterField( + model_name='videotranscript', + name='provider', + field=models.CharField(choices=[('Custom', 'Custom'), ('3PlayMedia', '3PlayMedia'), ('Cielo24', 'Cielo24'), ('edx_ai_translations', 'edx_ai_translations')], default='Custom', max_length=30), + ), + ] diff --git a/edxval/models.py b/edxval/models.py index 56b0ac9b..78d7ac68 100644 --- a/edxval/models.py +++ b/edxval/models.py @@ -378,6 +378,7 @@ class for providing tuple choices. CUSTOM = 'Custom' THREE_PLAY_MEDIA = '3PlayMedia' CIELO24 = 'Cielo24' + EDX_AI_TRANSLATIONS = 'edx_ai_translations' CHOICES = ( (CUSTOM, CUSTOM), @@ -385,6 +386,12 @@ class for providing tuple choices. (CIELO24, CIELO24), ) + # Choices specififcally for only the VideoTranscript model + TRANSCRIPT_MODEL_CHOICES = ( + *CHOICES, + (EDX_AI_TRANSLATIONS, EDX_AI_TRANSLATIONS), + ) + class CustomizableFileField(models.FileField): """ @@ -425,7 +432,7 @@ class VideoTranscript(TimeStampedModel): language_code = models.CharField(max_length=50, db_index=True) provider = models.CharField( max_length=30, - choices=TranscriptProviderType.CHOICES, + choices=TranscriptProviderType.TRANSCRIPT_MODEL_CHOICES, default=TranscriptProviderType.CUSTOM, ) file_format = models.CharField(max_length=20, db_index=True, choices=TranscriptFormat.CHOICES) diff --git a/edxval/tests/test_views.py b/edxval/tests/test_views.py index 6d1b8dd2..ddc65fea 100644 --- a/edxval/tests/test_views.py +++ b/edxval/tests/test_views.py @@ -882,7 +882,7 @@ def test_update_existing_transcript(self): 'file_format': TranscriptFormat.SRT }, 'message': '"xyz" provider is not supported. Supported transcription providers are "{}"'.format( - sorted(dict(TranscriptProviderType.CHOICES).keys()) + sorted(dict(TranscriptProviderType.TRANSCRIPT_MODEL_CHOICES).keys()) ) }, ) diff --git a/edxval/views.py b/edxval/views.py index 0a340451..3ca29f9b 100644 --- a/edxval/views.py +++ b/edxval/views.py @@ -161,7 +161,7 @@ def post(self, request): ).format(format=file_format, supported_formats=supported_formats) return Response(status=status.HTTP_400_BAD_REQUEST, data={'message': message}) - supported_providers = sorted(dict(TranscriptProviderType.CHOICES).keys()) + supported_providers = sorted(dict(TranscriptProviderType.TRANSCRIPT_MODEL_CHOICES).keys()) if provider not in supported_providers: message = ( '"{provider}" provider is not supported. Supported transcription providers are "{supported_providers}"'