Beispiel #1
0
def diffing(request, first_version, second_pk):
    language = first_version.subtitle_language
    second_version = get_object_or_404(SubtitleVersion.objects.extant(),
                                       pk=second_pk,
                                       subtitle_language=language)

    if first_version.video != second_version.video:
        # this is either a bad bug, or someone evil
        raise "Revisions for diff videos"

    if first_version.pk < second_version.pk:
        # this is just stupid Instead of first, second meaning
        # chronological order (first cames before second)
        # it means  the opposite, so make sure the first version
        # has a larger version no than the second
        first_version, second_version = second_version, first_version

    video = first_version.subtitle_language.video
    diff_data = diff_subs(first_version.get_subtitles(),
                          second_version.get_subtitles(),
                          mappings=HTMLGenerator.MAPPINGS)
    team_video = video.get_team_video()
    first_version_previous = first_version.previous_version()
    first_version_next = first_version.next_version()
    second_version_previous = second_version.previous_version()
    second_version_next = second_version.next_version()
    context = {
        'video':
        video,
        'diff_data':
        diff_data,
        'language':
        language,
        'first_version':
        first_version,
        'second_version':
        second_version,
        'latest_version':
        language.get_tip(),
        'first_version_previous':
        first_version_previous if
        (first_version_previous != second_version) else None,
        'first_version_next':
        first_version_next,
        'second_version_previous':
        second_version_previous,
        'second_version_next':
        second_version_next if
        (second_version_next != first_version) else None,
        'rollback_allowed':
        user_can_edit_subtitles(request.user, video, language.language_code),
        'width':
        video_size["small"]["width"],
        'height':
        video_size["small"]["height"],
        'video_url':
        video.get_video_url(),
    }

    return render(request, 'videos/diffing.html', context)
Beispiel #2
0
def diffing(request, first_version, second_pk):
    language = first_version.subtitle_language
    second_version = get_object_or_404(
        sub_models.SubtitleVersion.objects.extant(),
        pk=second_pk,
        subtitle_language=language)

    if first_version.video != second_version.video:
        # this is either a bad bug, or someone evil
        raise "Revisions for diff videos"

    if first_version.pk < second_version.pk:
        # this is just stupid Instead of first, second meaning
        # chronological order (first cames before second)
        # it means  the opposite, so make sure the first version
        # has a larger version no than the second
        first_version, second_version = second_version, first_version

    video = first_version.subtitle_language.video
    diff_data = diff_subs(first_version.get_subtitles(),
                          second_version.get_subtitles())
    team_video = video.get_team_video()

    context = widget.add_onsite_js_files({})
    context['video'] = video
    context['diff_data'] = diff_data
    context['language'] = language
    context['first_version'] = first_version
    context['second_version'] = second_version
    context['latest_version'] = language.get_tip()
    if team_video and not can_rollback_language(request.user, language):
        context['rollback_allowed'] = False
    else:
        context['rollback_allowed'] = True
    context['widget0_params'] = \
        _widget_params(request, video,
                       first_version.version_number)
    context['widget1_params'] = \
        _widget_params(request, video,
                       second_version.version_number)
    return render_to_response('videos/diffing.html',
                              context,
                              context_instance=RequestContext(request))