Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Previews don't work because the snapshot XML is broken #2029

Closed
jnm opened this issue Oct 12, 2018 · 0 comments
Closed

Previews don't work because the snapshot XML is broken #2029

jnm opened this issue Oct 12, 2018 · 0 comments
Assignees
Labels
bug Things broken and not working as expected high priority To be done soon

Comments

@jnm
Copy link
Member

jnm commented Oct 12, 2018

NOTE: use this branch, which now has a failing test, when working on this issue: https://github.com/kobotoolbox/kpi/tree/2029-snapshot-xml-renderer

Can’t preview any Enketo form; Enketo responds with an error: Extra content at the end of the document.

Adding rest_framework_xml.renderers.XMLRenderer to settings.REST_FRAMEWORK['DEFAULT_RENDERER_CLASSES'] has caused our custom XML renderers not to be used:

kpi/kpi/renderers.py

Lines 22 to 39 in 78e5ab0

class XFormRenderer(renderers.BaseRenderer):
media_type = 'application/xml'
format = 'xml'
charset = 'utf-8'
def render(self, data, media_type=None, renderer_context=None):
asset = renderer_context['view'].get_object()
return asset.snapshot.xml
class AssetSnapshotXFormRenderer(renderers.BaseRenderer):
media_type = 'application/xml'
format = 'xml'
charset = 'utf-8'
def render(self, data, media_type=None, renderer_context=None):
asset_snapshot = renderer_context['view'].get_object()
return asset_snapshot.xml

See

kpi/kpi/views.py

Lines 598 to 600 in 78e5ab0

renderer_classes = NoUpdateModelViewSet.renderer_classes + [
AssetSnapshotXFormRenderer,
]

@jnm jnm added bug Things broken and not working as expected high priority To be done soon labels Oct 12, 2018
@jnm jnm closed this as completed in #2035 Oct 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Things broken and not working as expected high priority To be done soon
Projects
None yet
Development

No branches or pull requests

2 participants