diff --git a/edxval/admin.py b/edxval/admin.py index 19d57f84..bca28634 100644 --- a/edxval/admin.py +++ b/edxval/admin.py @@ -81,6 +81,8 @@ class TranscriptPreferenceAdmin(admin.ModelAdmin): class ThirdPartyTranscriptCredentialsStateAdmin(admin.ModelAdmin): + list_display = ('org', 'provider', 'exists', 'created', 'modified') + model = ThirdPartyTranscriptCredentialsState verbose_name = 'Organization Transcript Credential State' verbose_name_plural = 'Organization Transcript Credentials State' diff --git a/edxval/migrations/0008_auto_20171026_0359.py b/edxval/migrations/0008_auto_20171026_0359.py new file mode 100644 index 00000000..40a37644 --- /dev/null +++ b/edxval/migrations/0008_auto_20171026_0359.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('edxval', '0007_transcript_credentials_state'), + ] + + operations = [ + migrations.RemoveField( + model_name='subtitle', + name='video', + ), + migrations.DeleteModel( + name='Subtitle', + ), + ] diff --git a/edxval/models.py b/edxval/models.py index 6b50ed74..72dfef5d 100644 --- a/edxval/models.py +++ b/edxval/models.py @@ -482,47 +482,6 @@ def __unicode__(self): return u'{lang} Transcript for {video}'.format(lang=self.language_code, video=self.video_id) -SUBTITLE_FORMATS = ( - ('srt', 'SubRip'), - ('sjson', 'SRT JSON') -) - - -class Subtitle(models.Model): - """ - Subtitle for video - - Attributes: - video: the video that the subtitles are for - fmt: the format of the subttitles file - """ - created = models.DateTimeField(auto_now_add=True) - modified = models.DateTimeField(auto_now=True) - video = models.ForeignKey(Video, related_name="subtitles") - fmt = models.CharField(max_length=20, db_index=True, choices=SUBTITLE_FORMATS) - language = models.CharField(max_length=8, db_index=True) - content = models.TextField(default='') - - def __str__(self): - return '%s Subtitle for %s' % (self.language, self.video) - - def get_absolute_url(self): - """ - Returns the full url link to the edx_video_id - """ - return reverse('subtitle-content', args=[self.video.edx_video_id, self.language]) - - @property - def content_type(self): - """ - Sjson is returned as application/json, otherwise text/plain - """ - if self.fmt == 'sjson': - return 'application/json' - else: - return 'text/plain' - - class Cielo24Turnaround(object): """ Cielo24 turnarounds. diff --git a/edxval/tests/constants.py b/edxval/tests/constants.py index 3f14ed60..e4568c94 100644 --- a/edxval/tests/constants.py +++ b/edxval/tests/constants.py @@ -66,7 +66,6 @@ edx_video_id="thisis12char-thisis7", status="test", encoded_videos=[], - subtitles=[] ) VIDEO_DICT_BEE_INVALID = dict( client_video_id="Barking Bee", @@ -80,7 +79,6 @@ edx_video_id="sloppy/sloth!!", status="test", encoded_videos=[], - subtitles=[] ) ENCODED_VIDEO_DICT_NEGATIVE_FILESIZE = dict( url="http://www.meowmix.com", @@ -101,7 +99,6 @@ edx_video_id="ID", status="test", encoded_videos=[], - subtitles=[] ) VIDEO_DICT_NON_LATIN_ID = dict( client_video_id="Hungry Hamster", @@ -109,22 +106,9 @@ edx_video_id="밥줘", status="test", encoded_videos=[], - subtitles=[] ) PROFILE_INVALID_NAME = "lo/lol" -""" -Subtitles -""" -SUBTITLE_DICT_SRT = dict( - fmt="srt", - language="en", - content="0:0:0\nhello" -) -SUBTITLE_DICT_SJSON = dict( - fmt="sjson", - language="fr", - content='{"start": "00:00:00"}' -) + """ Fish """ @@ -199,7 +183,6 @@ ENCODED_VIDEO_DICT_FISH_MOBILE, ENCODED_VIDEO_DICT_FISH_DESKTOP ], - subtitles=[SUBTITLE_DICT_SRT, SUBTITLE_DICT_SJSON], **VIDEO_DICT_FISH ) COMPLETE_SET_FISH_WITH_HLS = dict( @@ -208,7 +191,6 @@ ENCODED_VIDEO_DICT_FISH_DESKTOP, ENCODED_VIDEO_DICT_FISH_HLS, ], - subtitles=[SUBTITLE_DICT_SRT, SUBTITLE_DICT_SJSON], **VIDEO_DICT_FISH ) COMPLETE_SET_TWO_MOBILE_FISH = dict( @@ -216,7 +198,6 @@ ENCODED_VIDEO_DICT_FISH_MOBILE, ENCODED_VIDEO_DICT_FISH_MOBILE ], - subtitles=[SUBTITLE_DICT_SRT], **VIDEO_DICT_FISH ) COMPLETE_SET_UPDATE_FISH = dict( @@ -225,7 +206,6 @@ ENCODED_VIDEO_DICT_UPDATE_FISH_DESKTOP, ENCODED_VIDEO_DICT_UPDATE_FISH_HLS, ], - subtitles=[SUBTITLE_DICT_SRT], **VIDEO_DICT_FISH ) COMPLETE_SET_DIFFERENT_ID_UPDATE_FISH = dict( @@ -233,7 +213,6 @@ ENCODED_VIDEO_DICT_UPDATE_FISH_MOBILE, ENCODED_VIDEO_DICT_UPDATE_FISH_DESKTOP ], - subtitles=[SUBTITLE_DICT_SRT, SUBTITLE_DICT_SJSON], **VIDEO_DICT_DIFFERENT_ID_FISH ) COMPLETE_SET_FIRST_HALF_UPDATE_FISH = dict( @@ -241,14 +220,12 @@ ENCODED_VIDEO_DICT_UPDATE_FISH_MOBILE, ENCODED_VIDEO_DICT_FISH_DESKTOP ], - subtitles=[SUBTITLE_DICT_SRT, SUBTITLE_DICT_SJSON], **VIDEO_DICT_FISH ) COMPLETE_SET_UPDATE_ONLY_DESKTOP_FISH = dict( encoded_videos=[ ENCODED_VIDEO_DICT_UPDATE_FISH_DESKTOP ], - subtitles=[SUBTITLE_DICT_SRT], **VIDEO_DICT_FISH ) COMPLETE_SET_INVALID_ENCODED_VIDEO_FISH = dict( @@ -256,7 +233,6 @@ ENCODED_VIDEO_DICT_FISH_MOBILE, ENCODED_VIDEO_DICT_FISH_INVALID_PROFILE ], - subtitles=[SUBTITLE_DICT_SRT], **VIDEO_DICT_FISH ) COMPLETE_SET_INVALID_VIDEO_FISH = dict( @@ -268,7 +244,6 @@ ENCODED_VIDEO_DICT_FISH_MOBILE, ENCODED_VIDEO_DICT_FISH_DESKTOP ], - subtitles=[SUBTITLE_DICT_SRT] ) COMPLETE_SETS_ALL_INVALID = [ @@ -300,14 +275,12 @@ encoded_videos=[ ENCODED_VIDEO_DICT_STAR ], - subtitles=[SUBTITLE_DICT_SRT], **VIDEO_DICT_STAR ) COMPLETE_SET_UPDATE_STAR = dict( encoded_videos=[ ENCODED_VIDEO_UPDATE_DICT_STAR ], - subtitles=[SUBTITLE_DICT_SRT], **VIDEO_DICT_STAR ) COMPLETE_SET_WITH_COURSE_KEY = dict( @@ -315,7 +288,6 @@ encoded_videos=[ ENCODED_VIDEO_DICT_STAR ], - subtitles=[SUBTITLE_DICT_SRT], **VIDEO_DICT_STAR ) COMPLETE_SET_WITH_SOME_INVALID_COURSE_KEY = dict( @@ -323,7 +295,6 @@ encoded_videos=[ ENCODED_VIDEO_DICT_STAR ], - subtitles=[SUBTITLE_DICT_SRT], **VIDEO_DICT_STAR ) COMPLETE_SET_WITH_OTHER_COURSE_KEYS = dict( @@ -331,7 +302,6 @@ encoded_videos=[ ENCODED_VIDEO_DICT_STAR ], - subtitles=[SUBTITLE_DICT_SRT], **VIDEO_DICT_STAR ) COMPLETE_SET_NOT_A_LIST = dict( @@ -341,7 +311,6 @@ bitrate=42, profile=1 ), - subtitles=[SUBTITLE_DICT_SRT], **VIDEO_DICT_STAR ) COMPLETE_SET_EXTRA_VIDEO_FIELD = dict( @@ -354,7 +323,6 @@ video="This should be overridden by parent video field" ) ], - subtitles=[SUBTITLE_DICT_SRT], **VIDEO_DICT_STAR ) """ @@ -378,7 +346,6 @@ edx_video_id="zestttt", status="test", encoded_videos=[], - subtitles=[] ) VIDEO_DICT_ANIMAL = dict( client_video_id="Average Animal", @@ -386,7 +353,6 @@ edx_video_id="mediocrity", status="test", encoded_videos=[], - subtitles=[] ) VIDEO_DICT_UPDATE_ANIMAL = dict( client_video_id="Above Average Animal", @@ -394,7 +360,6 @@ edx_video_id="mediocrity", status="test", encoded_videos=[], - subtitles=[] ) VIDEO_TRANSCRIPT_CIELO24 = dict( diff --git a/edxval/tests/test_views.py b/edxval/tests/test_views.py index b11a6cdd..e777e004 100644 --- a/edxval/tests/test_views.py +++ b/edxval/tests/test_views.py @@ -209,33 +209,6 @@ def test_update_one_of_two_encoded_videos(self): ) self.assertEqual(len(videos[0].encoded_videos.all()), 1) - @unittest.skip("Skipping for now. We may need this later when we create transcripts alongwith video") - def test_update_remove_subtitles(self): - # Create some subtitles - self._create_videos(constants.COMPLETE_SET_STAR) - - # Sanity check that the subtitles have been created - videos = Video.objects.all() - self.assertEqual(len(videos), 1) - self.assertEqual(len(videos[0].subtitles.all()), 1) - - # Update with an empty list of subtitles - url = reverse( - 'video-detail', - kwargs={"edx_video_id": constants.COMPLETE_SET_STAR.get("edx_video_id")} - ) - response = self.client.put( - url, - dict(subtitles=[], encoded_videos=[], **constants.VIDEO_DICT_STAR), - format='json' - ) - self.assertEqual(response.status_code, status.HTTP_200_OK) - - # Expect that subtitles have been removed - videos = Video.objects.all() - self.assertEqual(len(videos), 1) - self.assertEqual(len(videos[0].subtitles.all()), 0) - def test_update_remove_encoded_videos(self): # Create some encoded videos self._create_videos(constants.COMPLETE_SET_STAR) @@ -626,7 +599,6 @@ def test_lookup_youtube(self): 'bitrate': 6767, } ], - 'subtitles': [], 'courses': ['youtube'], 'client_video_id': "Funny Cats", 'duration': 122 @@ -734,89 +706,6 @@ def test_queries_for_get(self): self.client.get("/edxval/videos/").data -@unittest.skip("Skipping for now. We may need these later when we create transcripts alongwith video") -class SubtitleDetailTest(APIAuthTestCase): - """ - Tests for subtitle API - """ - def setUp(self): - Profile.objects.create(profile_name=constants.PROFILE_MOBILE) - Profile.objects.create(profile_name=constants.PROFILE_DESKTOP) - super(SubtitleDetailTest, self).setUp() - - def test_get_subtitle_content(self): - """ - Get subtitle content - """ - url = reverse('video-list') - response = self.client.post( - url, constants.COMPLETE_SET_FISH, format='json' - ) - self.assertEqual(response.status_code, status.HTTP_201_CREATED) - video = self.client.get("/edxval/videos/").data - self.assertEqual(len(video), 1) - self.assertEqual(len(video[0].get("subtitles")), 2) - - video_subtitles = video[0]['subtitles'][0] - response = self.client.get(video_subtitles['content_url']) - self.assertEqual(response.content, constants.SUBTITLE_DICT_SRT['content']) - self.assertEqual(response['Content-Type'], 'text/plain') - - video_subtitles = video[0]['subtitles'][1] - response = self.client.get(video_subtitles['content_url']) - self.assertEqual(response.content, constants.SUBTITLE_DICT_SJSON['content']) - self.assertEqual(response['Content-Type'], 'application/json') - - def test_update_subtitle(self): - """ - Update an SRT subtitle - """ - url = reverse('video-list') - response = self.client.post( - url, constants.COMPLETE_SET_FISH, format='json' - ) - self.assertEqual(response.status_code, status.HTTP_201_CREATED) - video = response.data - video_subtitles = video['subtitles'][0] - url = reverse('subtitle-detail', kwargs={'video__edx_video_id': video['edx_video_id'], 'language': video_subtitles['language']}) - - video_subtitles['content'] = 'testing 123' - response = self.client.put( - url, video_subtitles, format='json' - ) - - self.assertEqual(response.status_code, status.HTTP_200_OK) - self.assertEqual(self.client.get(video_subtitles['content_url']).content, 'testing 123') - - def test_update_json_subtitle(self): - """ - Update a JSON subtitle - """ - url = reverse('video-list') - response = self.client.post( - url, constants.COMPLETE_SET_FISH, format='json' - ) - self.assertEqual(response.status_code, status.HTTP_201_CREATED) - video = response.data - video_subtitles = video['subtitles'][1] - url = reverse('subtitle-detail', kwargs={'video__edx_video_id': video['edx_video_id'], 'language': video_subtitles['language']}) - - video_subtitles['content'] = 'testing 123' - response = self.client.put( - url, video_subtitles, format='json' - ) - # not in json format - self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) - - video_subtitles['content'] = """{"start": "00:00:00" - - }""" - response = self.client.put( - url, video_subtitles, format='json' - ) - self.assertEqual(self.client.get(video_subtitles['content_url']).content, '{"start": "00:00:00"}') - - @ddt class VideoImagesViewTest(APIAuthTestCase): """