Skip to content

Commit

Permalink
refactor code
Browse files Browse the repository at this point in the history
  • Loading branch information
kelvin-muchiri committed Jul 18, 2024
1 parent bc32997 commit 8a899ff
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 3 additions & 1 deletion onadata/apps/api/tests/viewsets/test_xform_list_viewset.py
Original file line number Diff line number Diff line change
Expand Up @@ -824,7 +824,9 @@ def test_retrieve_xform_manifest_cache(self):
response = self.view(request, pk=self.xform.pk)

self.assertEqual(response.status_code, 200)
self.assertEqual(response.content.decode("utf-8"), "<manifest>Test</manifest>")
self.assertEqual(
response.render().content.decode("utf-8"), "<manifest>Test</manifest>"
)
self.assertTrue(response.has_header("X-OpenRosa-Version"))
self.assertTrue(response.has_header("X-OpenRosa-Accept-Content-Length"))
self.assertTrue(response.has_header("Date"))
Expand Down
8 changes: 5 additions & 3 deletions onadata/apps/api/viewsets/xform_list_viewset.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"""
from django.conf import settings
from django.core.cache import cache
from django.http import Http404, StreamingHttpResponse, HttpResponse
from django.http import Http404, StreamingHttpResponse
from django.shortcuts import get_object_or_404

from django_filters import rest_framework as django_filter_filters
Expand Down Expand Up @@ -171,7 +171,9 @@ def retrieve(self, request, *args, **kwargs):
self.object.xml, headers=get_openrosa_headers(request, location=False)
)

@action(methods=["GET", "HEAD"], detail=True)
@action(
methods=["GET", "HEAD"], detail=True, renderer_classes=[XFormManifestRenderer]
)
def manifest(self, request, *args, **kwargs):
"""A manifest defining additional supporting objects."""
# pylint: disable=attribute-defined-outside-init
Expand All @@ -181,7 +183,7 @@ def manifest(self, request, *args, **kwargs):
# Ensure a previous stream has completed updating the cache by
# confirm the last tag </manifest> exists
if cached_manifest is not None and cached_manifest.endswith("</manifest>"):
return HttpResponse(
return Response(
cached_manifest,
content_type="text/xml; charset=utf-8",
headers=get_openrosa_headers(request, location=False),
Expand Down

0 comments on commit 8a899ff

Please sign in to comment.