Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 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 ""
Ejemplo n.º 5
0
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
Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 8
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
Ejemplo n.º 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
Ejemplo n.º 10
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
Ejemplo n.º 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
Ejemplo n.º 12
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
Ejemplo n.º 13
0
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 ''