Example #1
0
 def get(self, request, *args, **kwargs):
     self.object = self.get_object()
     pdf_page_settings = PDFPageSettings.for_request(request)
     content = draw_submission_content(self.object.output_text_answers())
     pdf = make_pdf(
         title=self.object.title,
         sections=[
             {
                 'content':
                 content,
                 'title':
                 'Submission',
                 'meta': [
                     self.object.stage,
                     self.object.page,
                     self.object.round,
                     f"Lead: { self.object.lead }",
                 ],
             },
         ],
         pagesize=pdf_page_settings.download_page_size,
     )
     return FileResponse(
         pdf,
         as_attachment=True,
         filename=self.object.title + '.pdf',
     )
Example #2
0
 def get(self, request, *args, **kwargs):
     self.object = self.get_object()
     pdf_page_settings = PDFPageSettings.for_request(request)
     response = ProjectDetailSimplifiedView.as_view()(
         request=self.request,
         pk=self.object.pk,
     )
     project = draw_project_content(response.render().content)
     submission = draw_submission_content(
         self.object.submission.output_text_answers())
     pdf = make_pdf(
         title=self.object.title,
         sections=[
             {
                 'content':
                 project,
                 'title':
                 'Project Approval Form',
                 'meta': [
                     self.object.submission.page,
                     self.object.submission.round,
                     f"Lead: { self.object.lead }",
                 ],
             },
             {
                 'content':
                 submission,
                 'title':
                 'Submission',
                 'meta': [
                     self.object.submission.stage,
                     self.object.submission.page,
                     self.object.submission.round,
                     f"Lead: { self.object.submission.lead }",
                 ],
             },
         ],
         pagesize=pdf_page_settings.download_page_size,
     )
     return FileResponse(
         pdf,
         as_attachment=True,
         filename=self.object.title + '.pdf',
     )