Beispiel #1
0
    def test_detail_contents_unrelated_video(self):
        from videos.models import SubtitleLanguage

        team, new_team_video = self._create_new_team_video()
        en = SubtitleLanguage(video=new_team_video.video, language='en')
        en.is_original = True
        en.is_complete = True
        en.save()
        self._set_my_languages('en', 'ru')
        # now add a Russian video with no subtitles.
        self._add_team_video(
            team, u'ru',
            u'http://upload.wikimedia.org/wikipedia/commons/6/61/CollateralMurder.ogv')

        reset_solr()

        team = Team.objects.get(id=team.id)

        self.assertEqual(2, team.teamvideo_set.count())

        # both videos should be in the list
        search_record_list = self._tv_search_record_list(team)
        self.assertEqual(2, len(search_record_list))

        # but the one with en subs should be second, since it was added earlier
        self.assertEqual('en', search_record_list[1].original_language)
Beispiel #2
0
def _create_trans(video, latest_version=None, lang_code=None, forked=False):
    translation = SubtitleLanguage()
    translation.video = video
    translation.language = lang_code
    translation.is_original = False
    translation.is_forked = forked
    if not forked:
        translation.standard_language = video.subtitle_language()
    translation.save()
    v = SubtitleVersion()
    v.language = translation
    if latest_version:
        v.version_no = latest_version.version_no + 1
    else:
        v.version_no = 1
    v.datetime_started = datetime.now()
    v.save()

    if latest_version is not None:
        for s in latest_version.subtitle_set.all():
            s.duplicate_for(v).save()
    return translation
Beispiel #3
0
def legacy_history(request, video, lang=None):
    """
    In the old days we allowed only one translation per video.
    Therefore video urls looked like /vfjdh2/en/
    Now that this constraint is removed we need to redirect old urls
    to the new view, that needs
    """
    try:
        language = video.subtitle_language(lang)
        if language is None:
            raise SubtitleLanguage.DoesNotExist("No such language")
    except sub_models.SubtitleLanguage.DoesNotExist:
        raise Http404()

    return HttpResponseRedirect(reverse("videos:translation_history", kwargs={
            'video_id': video.video_id,
            'lang_id': language.pk,
            'lang': language.language_code,
            }))
Beispiel #4
0
def _add_lang_to_video(video, props, translated_from=None):

    if props.get('is_original', False):
        video.subtitle_language().delete()
    sub_lang = SubtitleLanguage(
        video=video,
        is_original=props.get('is_original', False),
        is_complete=props.get('is_complete', False),
        language=props.get('code'),
        has_version=True,
        had_version=True,
        is_forked=True,
    )
    sub_lang.save()
    num_subs = props.get("num_subs", 0)

    if not translated_from:
        _add_subtitles(sub_lang, num_subs)

    if translated_from:
        sub_lang.is_original = False
        sub_lang.is_forked = False
        sub_lang.standard_language = translated_from
        sub_lang.save()
        _copy_subtitles(translated_from, sub_lang, num_subs)

    for translation_prop in props.get("translations", []):
        _add_lang_to_video(video, translation_prop, translated_from=sub_lang)

    sub_lang.is_complete = props.get("is_complete", False)
    sub_lang.save()
    from videos.tasks import video_changed_tasks
    video_changed_tasks.delay(sub_lang.video.id)
    return sub_lang
Beispiel #5
0
def _add_lang_to_video(video, props,  translated_from=None):

    sub_lang = SubtitleLanguage(
        video=video,
        is_original = props.get('is_original', False),
        is_complete = props.get('is_complete', False),
        language = props.get('code'),
        has_version=True,
        had_version=True,
        is_forked=True,
    )
    sub_lang.save()
    num_subs = props.get("num_subs", 0)

    if not translated_from:
        _add_subtitles(sub_lang, num_subs)

    if translated_from:
        sub_lang.is_original = False
        sub_lang.is_forked = False
        sub_lang.standard_language = translated_from
        sub_lang.save()
        _copy_subtitles(translated_from ,sub_lang,  num_subs)

    for translation_prop in props.get("translations", []):
        _add_lang_to_video(video, translation_prop, translated_from=sub_lang)


    sub_lang.update_percent_done()
    print 'adding lang ', sub_lang
    sub_lang.save()
    return sub_lang    
Beispiel #6
0
def _add_lang_to_video(video, props, translated_from=None):

    sub_lang = SubtitleLanguage(
        video=video,
        is_original=props.get('is_original', False),
        is_complete=props.get('is_complete', False),
        language=props.get('code'),
        has_version=True,
        had_version=True,
        is_forked=True,
    )
    sub_lang.save()
    num_subs = props.get("num_subs", 0)

    if not translated_from:
        _add_subtitles(sub_lang, num_subs)

    if translated_from:
        sub_lang.is_original = False
        sub_lang.is_forked = False
        sub_lang.standard_language = translated_from
        sub_lang.save()
        _copy_subtitles(translated_from, sub_lang, num_subs)

    for translation_prop in props.get("translations", []):
        _add_lang_to_video(video, translation_prop, translated_from=sub_lang)

    sub_lang.update_percent_done()
    sub_lang.save()
    return sub_lang
Beispiel #7
0
def _add_lang_to_video(video, props, translated_from=None):

    if props.get("is_original", False):
        video.subtitle_language().delete()
    sub_lang = SubtitleLanguage(
        video=video,
        is_original=props.get("is_original", False),
        is_complete=props.get("is_complete", False),
        language=props.get("code"),
        has_version=True,
        had_version=True,
        is_forked=True,
    )
    sub_lang.save()
    num_subs = props.get("num_subs", 0)

    if not translated_from:
        _add_subtitles(sub_lang, num_subs)

    if translated_from:
        sub_lang.is_original = False
        sub_lang.is_forked = False
        sub_lang.standard_language = translated_from
        sub_lang.save()
        _copy_subtitles(translated_from, sub_lang, num_subs)

    for translation_prop in props.get("translations", []):
        _add_lang_to_video(video, translation_prop, translated_from=sub_lang)

    sub_lang.is_complete = props.get("is_complete", False)
    sub_lang.save()
    from videos.tasks import video_changed_tasks

    video_changed_tasks.delay(sub_lang.video.id)
    return sub_lang