Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions ietf/doc/tests_unprepped.py → ietf/doc/tests_notprepped.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from ietf.utils.test_utils import TestCase


class UnpreppedRfcXmlTests(TestCase):
class NotpreppedRfcXmlTests(TestCase):
def test_editor_source_button_visibility(self):
pre_v3 = WgRfcFactory(rfc_number=settings.FIRST_V3_RFC - 1)
first_v3 = WgRfcFactory(rfc_number=settings.FIRST_V3_RFC)
Expand Down Expand Up @@ -72,13 +72,17 @@ def test_rfcxml_notprepped(self):
r = self.client.get(url)
self.assertEqual(r.status_code, 404)

# 200 with correct content-type and body when object is fully stored
# 200 with correct content-type, attachment disposition, and body when object is fully stored
xml_content = b"<rfc>test</rfc>"
store_bytes("rfc", stored_name, xml_content, allow_overwrite=True)
r = self.client.get(url)
self.assertEqual(r.status_code, 200)
self.assertEqual(r["Content-Type"], "application/xml")
self.assertEqual(r.content, xml_content)
self.assertEqual(
r["Content-Disposition"],
f'attachment; filename="rfc{number}.notprepped.xml"',
)
self.assertEqual(b"".join(r.streaming_content), xml_content)

def test_rfcxml_notprepped_wrapper(self):
number = settings.FIRST_V3_RFC
Expand Down
5 changes: 3 additions & 2 deletions ietf/doc/views_doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,10 @@

from celery.result import AsyncResult
from django.core.cache import caches
from django.core.files.base import ContentFile
from django.core.exceptions import PermissionDenied
from django.db.models import Max
from django.http import HttpResponse, Http404, HttpResponseBadRequest, JsonResponse
from django.http import FileResponse, HttpResponse, Http404, HttpResponseBadRequest, JsonResponse
from django.shortcuts import render, get_object_or_404, redirect
from django.template.loader import render_to_string
from django.urls import reverse as urlreverse
Expand Down Expand Up @@ -2372,7 +2373,7 @@ def rfcxml_notprepped(request, number):
bytes = retrieve_bytes("rfc", name)
except FileNotFoundError:
raise Http404
return HttpResponse(bytes, content_type="application/xml")
return FileResponse(ContentFile(bytes, name=f"rfc{number}.notprepped.xml"), as_attachment=True)


def rfcxml_notprepped_wrapper(request, number):
Expand Down
Loading