本文整理汇总了Python中videos.models.SubtitleLanguage.is_complete方法的典型用法代码示例。如果您正苦于以下问题:Python SubtitleLanguage.is_complete方法的具体用法?Python SubtitleLanguage.is_complete怎么用?Python SubtitleLanguage.is_complete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类videos.models.SubtitleLanguage
的用法示例。
在下文中一共展示了SubtitleLanguage.is_complete方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_subtitle_language_save
# 需要导入模块: from videos.models import SubtitleLanguage [as 别名]
# 或者: from videos.models.SubtitleLanguage import is_complete [as 别名]
def test_subtitle_language_save(self):
self.assertEqual(self.video.complete_date, None)
self.assertEqual(self.video.subtitlelanguage_set.count(), 1)
self.language.is_complete = True
self.language.save()
self.video = Video.objects.get(pk=self.video.pk)
self.assertNotEqual(self.video.complete_date, None)
self.language.is_complete = False
self.language.save()
self.video = Video.objects.get(pk=self.video.pk)
self.assertEqual(self.video.complete_date, None)
#add one more SubtitleLanguage
l = SubtitleLanguage(video=self.video)
l.is_original = False
l.is_complete = True
l.save()
self.video = Video.objects.get(pk=self.video.pk)
self.assertNotEqual(self.video.complete_date, None)
self.language.is_complete = True
self.language.save()
self.video = Video.objects.get(pk=self.video.pk)
self.assertNotEqual(self.video.complete_date, None)
l.is_complete = False
l.save()
self.video = Video.objects.get(pk=self.video.pk)
self.assertNotEqual(self.video.complete_date, None)
self.language.is_complete = False
self.language.save()
self.video = Video.objects.get(pk=self.video.pk)
self.assertEqual(self.video.complete_date, None)
self.language.is_complete = True
self.language.save()
self.video = Video.objects.get(pk=self.video.pk)
self.assertNotEqual(self.video.complete_date, None)
l.is_complete = True
l.save()
self.video = Video.objects.get(pk=self.video.pk)
self.assertNotEqual(self.video.complete_date, None)
self.language.delete()
self.video = Video.objects.get(pk=self.video.pk)
self.assertNotEqual(self.video.complete_date, None)
l.delete()
self.video = Video.objects.get(pk=self.video.pk)
self.assertEqual(self.video.complete_date, None)
示例2: test_update_tvl
# 需要导入模块: from videos.models import SubtitleLanguage [as 别名]
# 或者: from videos.models.SubtitleLanguage import is_complete [as 别名]
def test_update_tvl(self):
tv = TeamVideo.objects.get(id=2)
sl = SubtitleLanguage(
language='en',
is_original=True,
is_forked=False,
is_complete=False,
video=tv.video)
sl.save()
tmodels.TeamVideoLanguage.update(tv)
tvls = tmodels.TeamVideoLanguage.objects.filter(team_video=tv)
self.assertEquals(len(settings.ALL_LANGUAGES), len(tvls))
for tvl in tvls:
self.assertFalse(tvl.is_complete)
self.assertEquals(0, tvl.percent_done)
sl = SubtitleLanguage.objects.get(id=sl.id)
sl.is_complete = True
sl.save()
tv = TeamVideo.objects.get(id=2)
tmodels.TeamVideoLanguage.update(tv)
tvls = tmodels.TeamVideoLanguage.objects.filter(team_video=tv)
self.assertEquals(len(settings.ALL_LANGUAGES), len(tvls))
for tvl in tvls:
if tvl.language != 'en':
self.assertFalse(tvl.is_complete)
else:
self.assertTrue(tvl.is_complete)
self.assertEquals(0, tvl.percent_done)
示例3: test_update_tvlp_no_dependent
# 需要导入模块: from videos.models import SubtitleLanguage [as 别名]
# 或者: from videos.models.SubtitleLanguage import is_complete [as 别名]
def test_update_tvlp_no_dependent(self):
tv = TeamVideo.objects.get(id=2)
tv.update_team_video_language_pairs()
# this video starts with no languages.
self.assertEquals(0, self._tvlp_query_set(tv).count())
sl = SubtitleLanguage(
language='en',
is_original=True,
is_forked=False,
is_complete=False,
video=tv.video)
sl.save()
tv = TeamVideo.objects.get(id=2)
tv.update_team_video_language_pairs()
# the language is not complete, so it's not a good source for translations.
self.assertEquals(0, self._tvlp_query_set(tv).count())
sl = tv.video.subtitle_language('en')
sl.is_complete = True
sl.save()
tv = TeamVideo.objects.get(id=2)
tv.update_team_video_language_pairs()
# complete, so now every language can be translated from this one.
tvlps = self._tvlp_query_set(tv)
self.assertEquals(len(settings.ALL_LANGUAGES) - 1, len(tvlps))
for tvlp in tvlps:
self.assertEquals(0, tvlp.percent_complete)
示例4: test_request_language_handler
# 需要导入模块: from videos.models import SubtitleLanguage [as 别名]
# 或者: from videos.models.SubtitleLanguage import is_complete [as 别名]
def test_request_language_handler(self):
'''
Test the signal handler which sets the requesters as language
followers when a new (requested) language is created.
'''
subrequest = self._create_requests(self.langs[2:3])[0]
# Test if the user automatically starts following
# a language if there is a pending request
original = self.video.subtitle_language()
newlang = SubtitleLanguage(
video=self.video,
language=subrequest.language,
is_original=False,
is_forked=False,
standard_language=original)
newlang.save()
self.assertEqual(self.user, newlang.followers.all()[0])
# Test if subtitle request is marked as done
newlang.is_complete = True
newlang.save()
subrequest = SubtitleRequest.objects.get(pk=subrequest.pk)
self.assertEqual(subrequest.done, True)
示例5: save_subtitles
# 需要导入模块: from videos.models import SubtitleLanguage [as 别名]
# 或者: from videos.models.SubtitleLanguage import is_complete [as 别名]
def save_subtitles(self, parser):
video = self.cleaned_data['video']
key = str(uuid4()).replace('-', '')
video._make_writelock(self.user, key)
video.save()
if not video.has_original_language():
self._save_original_language(
video, self.cleaned_data['video_language'])
language = video.subtitle_language(self.cleaned_data['language'])
if not language:
language = SubtitleLanguage(video=video, is_original=False, is_forked=True)
language.language = self.cleaned_data['language']
language.save()
try:
old_version = language.subtitleversion_set.all()[:1].get()
version_no = old_version.version_no + 1
except ObjectDoesNotExist:
old_version = None
version_no = 0
if not self.is_version_same(old_version, parser):
version = SubtitleVersion(
language=language, version_no=version_no,
datetime_started=datetime.now(), user=self.user,
note=u'Uploaded', is_forked=True, time_change=1, text_change=1)
version.save()
ids = []
for i, item in enumerate(parser):
id = int(random.random()*10e12)
while id in ids:
id = int(random.random()*10e12)
ids.append(id)
caption = Subtitle(**item)
caption.version = version
caption.subtitle_id = str(id)
caption.subtitle_order = i+1
caption.save()
version.save()
version.update_percent_done()
language.was_complete = True
language.is_complete = True
language.save()
video.release_writelock()
video.save()
return language
示例6: test_update_sl
# 需要导入模块: from videos.models import SubtitleLanguage [as 别名]
# 或者: from videos.models.SubtitleLanguage import is_complete [as 别名]
def test_update_sl(self):
tv = TeamVideo.objects.get(id=2)
sublang = SubtitleLanguage(
language='en',
is_original=True,
is_forked=False,
is_complete=False,
video=tv.video)
sublang.save()
sls = tv.searchable_languages()
self.assertEquals(len(settings.ALL_LANGUAGES), len(sls))
sublang = SubtitleLanguage.objects.get(id=sublang.id)
sublang.is_complete = True
sublang.save()
tv = TeamVideo.objects.get(id=2)
sls = tv.searchable_languages()
self.assertEquals(len(settings.ALL_LANGUAGES) - 1, len(sls))
示例7: test_update_lp_no_dependent
# 需要导入模块: from videos.models import SubtitleLanguage [as 别名]
# 或者: from videos.models.SubtitleLanguage import is_complete [as 别名]
def test_update_lp_no_dependent(self):
tv = TeamVideo.objects.get(id=2)
# this video starts with no languages.
self.assertEquals(0, len(tv.searchable_language_pairs()))
sl = SubtitleLanguage(
language='en',
is_original=True,
is_forked=False,
is_complete=False,
video=tv.video)
sl.save()
tv = TeamVideo.objects.get(id=2)
self.assertEquals(0, len(tv.searchable_language_pairs()))
sl = tv.video.subtitle_language('en')
sl.is_complete = True
sl.save()
tv = TeamVideo.objects.get(id=2)
lps = tv.searchable_language_pairs()
self.assertEquals(len(settings.ALL_LANGUAGES) - 1, len(lps))
# we expect each string to end in "_0" to indicate zero completion.
for lp in lps:
self.assertEquals("0", LANGUAGEPAIR_RE.match(lp).group(3))