예제 #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
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
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
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
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
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 ''