Skip to content
Closed
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
8 changes: 8 additions & 0 deletions arches_pdf_exporting/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,17 @@
from django.urls import include, path, re_path

from arches_pdf_exporting.views import search
from arches_pdf_exporting.views.print_report import PrintReportView

uuid_regex = settings.UUID_REGEX

urlpatterns = [
re_path(r"^search/export_results$", search.export_results, name="export_results"),
re_path(
r"^report/(?P<resourceid>%s)/print$" % uuid_regex,
PrintReportView.as_view(),
name="print_report",
),
]

# Ensure Arches core urls are superseded by project-level urls
Expand Down
20 changes: 20 additions & 0 deletions arches_pdf_exporting/views/print_report.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from django.shortcuts import render
from django.http import HttpResponse
from django.views.generic import View
from io import StringIO

from arches.app.utils.data_management.resources.formats.htmlfile import HtmlWriter
from arches.app.utils.data_management.resources.exporter import ResourceExporter

class PrintReportView(View):

def get(self, request, resourceid=None):

# Call HTML exporter - pass in our single resource id
html_exporter = ResourceExporter(format="html")
resource = html_exporter.export(resourceinstanceids=[resourceid])

# exporter returns file object, with file + content as stringIO, so we convert it back to html
html_content = resource[0]["outputfile"].getvalue()

return HttpResponse(html_content)
Loading