Beispiel #1
0
def diff_fragment(request, review_request_id, revision, filediff_id,
                  interdiff_revision=None, chunkindex=None,
                  template_name='diffviewer/diff_file_fragment.html'):
    """
    Wrapper around diffviewer.views.view_diff_fragment that takes a review
    request.

    Displays just a fragment of a diff or interdiff owned by the given
    review request. The fragment is identified by the chunk index in the
    diff.
    """
    review_request = get_object_or_404(ReviewRequest, pk=review_request_id)
    draft = review_request.get_draft(request.user)

    if interdiff_revision is not None:
        interdiffset = _query_for_diff(review_request, request.user,
                                       interdiff_revision)
        interdiffset_id = interdiffset.id
        # Only the interdiff should have an extra query for the draft.
        # It's going to be the most recent diff (generally). We should be
        # smarter and check.
        query_extra = None
    else:
        interdiffset_id = None

    diffset = _query_for_diff(review_request, request.user, revision)

    return view_diff_fragment(request, diffset.id, filediff_id,
                              interdiffset_id, chunkindex, template_name)
Beispiel #2
0
def diff_fragment(
    request,
    review_request_id,
    revision,
    filediff_id,
    interdiff_revision=None,
    chunkindex=None,
    template_name="diffviewer/diff_file_fragment.html",
):
    """
    Wrapper around diffviewer.views.view_diff_fragment that takes a review
    request.

    Displays just a fragment of a diff or interdiff owned by the given
    review request. The fragment is identified by the chunk index in the
    diff.
    """
    review_request = get_object_or_404(ReviewRequest, pk=review_request_id)
    review_request.get_draft(request.user)

    if interdiff_revision is not None:
        interdiffset = _query_for_diff(review_request, request.user, interdiff_revision)
        interdiffset_id = interdiffset.id
    else:
        interdiffset_id = None

    diffset = _query_for_diff(review_request, request.user, revision)

    return view_diff_fragment(request, diffset.id, filediff_id, interdiffset_id, chunkindex, template_name)
Beispiel #3
0
def diff_fragment(request,
                  review_request_id,
                  revision,
                  filediff_id,
                  interdiff_revision=None,
                  chunkindex=None,
                  template_name='diffviewer/diff_file_fragment.html',
                  local_site_name=None):
    """
    Wrapper around diffviewer.views.view_diff_fragment that takes a review
    request.

    Displays just a fragment of a diff or interdiff owned by the given
    review request. The fragment is identified by the chunk index in the
    diff.
    """
    review_request, response = \
        _find_review_request(request, review_request_id, local_site_name)

    if not review_request:
        return response

    review_request.get_draft(request.user)

    if interdiff_revision is not None:
        interdiffset = _query_for_diff(review_request, request.user,
                                       interdiff_revision)
    else:
        interdiffset = None

    diffset = _query_for_diff(review_request, request.user, revision)

    return view_diff_fragment(request, diffset.id, filediff_id,
                              review_request.get_absolute_url(),
                              interdiffset, chunkindex, template_name)
Beispiel #4
0
def diff_fragment(request,
                  review_request_id,
                  revision,
                  filediff_id,
                  interdiff_revision=None,
                  chunkindex=None,
                  template_name='diffviewer/diff_file_fragment.html',
                  local_site_name=None):
    """
    Wrapper around diffviewer.views.view_diff_fragment that takes a review
    request.

    Displays just a fragment of a diff or interdiff owned by the given
    review request. The fragment is identified by the chunk index in the
    diff.
    """
    review_request, response = \
        _find_review_request(request, review_request_id, local_site_name)

    if not review_request:
        return response

    review_request.get_draft(request.user)

    if interdiff_revision is not None:
        interdiffset = _query_for_diff(review_request, request.user,
                                       interdiff_revision)
        interdiffset_id = interdiffset.id
    else:
        interdiffset_id = None

    diffset = _query_for_diff(review_request, request.user, revision)

    return view_diff_fragment(request, diffset.id, filediff_id,
                              review_request.get_absolute_url(),
                              interdiffset_id, chunkindex, template_name)