コード例 #1
0
def mbox(request, patch_id):
    patch = get_object_or_404(Patch, id=patch_id)
    response = HttpResponse(content_type="text/plain")
    # NOTE(stephenfin) http://stackoverflow.com/a/28584090/613428
    if six.PY3:
        response.write(patch_to_mbox(patch).as_bytes(True).decode())
    else:
        response.write(patch_to_mbox(patch).as_string(True))
    response['Content-Disposition'] = 'attachment; filename=' + \
        patch.filename().replace(';', '').replace('\n', '')
    return response
コード例 #2
0
ファイル: patch.py プロジェクト: getpatchwork/patchwork
def mbox(request, patch_id):
    patch = get_object_or_404(Patch, id=patch_id)
    response = HttpResponse(content_type="text/plain")
    # NOTE(stephenfin) http://stackoverflow.com/a/28584090/613428
    if six.PY3:
        response.write(patch_to_mbox(patch).as_bytes(True).decode())
    else:
        response.write(patch_to_mbox(patch).as_string(True))
    response['Content-Disposition'] = 'attachment; filename=' + \
        patch.filename.replace(';', '').replace('\n', '')
    return response
コード例 #3
0
ファイル: patch.py プロジェクト: tklengyel/patchwork
def mbox(request, patch_id):
    patch = get_object_or_404(Patch, id=patch_id)
    response = HttpResponse(mimetype="text/plain")
    response.write(patch_to_mbox(patch).as_string(True))
    response['Content-Disposition'] = 'attachment; filename=' + \
        patch.filename().replace(';', '').replace('\n', '')
    return response
コード例 #4
0
ファイル: xmlrpc.py プロジェクト: tklengyel/patchwork
def patch_get_mbox(patch_id):
    """Return mbox string for the given patch ID."""
    try:
        patch = Patch.objects.filter(id = patch_id)[0]
        return patch_to_mbox(patch).as_string()
    except:
        return ""
コード例 #5
0
ファイル: patch.py プロジェクト: nwnk/patchwork
def mbox(request, patch_id):
    patch = get_object_or_404(Patch, id=patch_id)
    response = HttpResponse(content_type="text/plain")
    response.write(patch_to_mbox(patch).as_string(True))
    response['Content-Disposition'] = 'attachment; filename=' + \
        patch.filename().replace(';', '').replace('\n', '')
    return response
コード例 #6
0
ファイル: api.py プロジェクト: michaelgwood/patchwork
def series_mbox(request, revision):
    options = {"patch-link": request.GET.get("link", None), "request": request}
    patches = revision.ordered_patches()
    data = "\n".join([patch_to_mbox(x, options).as_string(True) for x in patches])
    response = HttpResponse(content_type="text/plain")
    response.write(data)
    response["Content-Disposition"] = "attachment; filename=" + revision.series.filename()
    return response
コード例 #7
0
def series_mbox(revision):
    patches = revision.ordered_patches()
    data = '\n'.join([patch_to_mbox(x).as_string(True) for x in patches])
    response = HttpResponse(content_type="text/plain")
    response.write(data)
    response['Content-Disposition'] = 'attachment; filename=' + \
        revision.series.filename()
    return response
コード例 #8
0
ファイル: api.py プロジェクト: nwnk/patchwork
def series_mbox(revision):
    patches = revision.ordered_patches()
    data = '\n'.join([patch_to_mbox(x).as_string(True) for x in patches])
    response = HttpResponse(content_type="text/plain")
    response.write(data)
    response['Content-Disposition'] = 'attachment; filename=' + \
        revision.series.filename()
    return response
コード例 #9
0
def series_mbox(request, revision):
    options = {
        'patch-link': request.GET.get('link', None),
        'request': request,
    }
    patches = revision.ordered_patches()
    data = '\n'.join([patch_to_mbox(x, options).as_string(True)
                      for x in patches])
    response = HttpResponse(content_type="text/plain")
    response.write(data)
    response['Content-Disposition'] = 'attachment; filename=' + \
        revision.series.filename()
    return response
コード例 #10
0
ファイル: api.py プロジェクト: joselamego/patchwork
def series_mbox(request, revision):
    options = {
        'patch-link': request.GET.get('link', None),
        'request': request,
    }
    patches = revision.ordered_patches()
    data = '\n'.join([patch_to_mbox(x, options).as_string(True)
                      for x in patches])
    response = HttpResponse(content_type="text/plain")
    response.write(data)
    response['Content-Disposition'] = 'attachment; filename=' + \
        revision.series.filename()
    return response
コード例 #11
0
ファイル: bundle.py プロジェクト: getpatchwork/patchwork
def mbox(request, username, bundlename):
    bundle = get_object_or_404(Bundle, owner__username=username,
                               name=bundlename)

    if not (request.user == bundle.owner or bundle.public):
        return HttpResponseNotFound()

    mbox = '\n'.join([patch_to_mbox(p).as_string(True)
                      for p in bundle.ordered_patches()])

    response = HttpResponse(content_type='text/plain')
    response['Content-Disposition'] = \
        'attachment; filename=bundle-%d-%s.mbox' % (bundle.id, bundle.name)

    response.write(mbox)
    return response
コード例 #12
0
ファイル: bundle.py プロジェクト: nwnk/patchwork
def mbox(request, username, bundlename):
    bundle = get_object_or_404(Bundle, owner__username = username,
                                name = bundlename)

    if not (request.user == bundle.owner or bundle.public):
        return HttpResponseNotFound()

    mbox = '\n'.join([patch_to_mbox(p).as_string(True)
                        for p in bundle.ordered_patches()])

    response = HttpResponse(content_type='text/plain')
    response['Content-Disposition'] = \
	'attachment; filename=bundle-%d-%s.mbox' % (bundle.id, bundle.name)

    response.write(mbox)
    return response
コード例 #13
0
ファイル: xmlrpc.py プロジェクト: asdil12/patchwork
def patch_get_mbox(patch_id):
    """Get a patch by its ID in mbox format.

    Retrieve a patch matching a given patch ID, if any exists, and
    return in mbox format.

    Args:
        patch_id (int): The ID of the patch to retrieve.

    Returns:
        The serialized patch matching the ID, if any, in mbox format,
        else an empty string.
    """
    try:
        patch = Patch.objects.filter(id=patch_id)[0]
        return patch_to_mbox(patch).as_string(True)
    except Patch.DoesNotExist:
        return ''