Ejemplo n.º 1
0
 def post(self):
     response = Search().post()
     record = json.loads(response)["record"]
     request_data = request.get_json()
     aliases = request_data["aliases"]
     header = MarkdownSerializer.default_header(aliases)
     source = MarkdownSerializer.to_markdown(record, header)
     pdf = MarkdownToPDF.to_pdf("Expungement analysis", source)
     response = make_response(pdf)
     response.headers["Content-Type"] = "application/pdf"
     filename = Pdf.build_filename(aliases)
     response.headers["Content-Disposition"] = f"inline; filename={filename}"
     return response
Ejemplo n.º 2
0
 def post(self):
     request_data = request.get_json()
     user_information = request_data.get("userInformation")
     record_summary = Search().build_response()
     temp_dir = mkdtemp()
     zip_dir = mkdtemp()
     zip_name = "expungement_packet.zip"
     zip_path = path.join(zip_dir, zip_name)
     zipfile = ZipFile(zip_path, "w")
     for case in record_summary.record.cases:
         pdf = FormFilling._build_pdf_for_case(case, user_information)
         if pdf:
             file_name = f"{case.summary.name}_{case.summary.case_number}.pdf"
             file_path = path.join(temp_dir, file_name)
             PdfWriter().write(file_path, pdf)
             zipfile.write(file_path, file_name)
     zipfile.close()
     return send_file(zip_path,
                      as_attachment=True,
                      attachment_filename=zip_name)