rsm-roguchi commited on
Commit
3beb864
·
1 Parent(s): 0901876
Files changed (1) hide show
  1. server/document_creation.py +13 -16
server/document_creation.py CHANGED
@@ -177,29 +177,26 @@ def server(input, output, session):
177
  legal_notes=job.get("legal_notes", "Subject to U.S. labor law.")
178
  )
179
 
180
- ctx.setdefault("onboarding_docs", {})["contract"] = contract
181
- save_candidate_context(candidate_id, ctx)
182
- return ui.HTML(f"<pre style='font-family: Georgia; font-size: 1rem'>{contract}</pre>")
183
-
184
- @output
185
- @render.download(filename="Offer_Letter.pdf")
186
- def download_offer():
187
- candidate_id = input.candidate_dropdown_doc()
188
- ctx = get_candidate_context(candidate_id)
189
- offer = ctx.get("onboarding_docs", {}).get("offer_letter", "No offer letter found.")
190
-
191
  pdf = FPDF()
192
  pdf.add_page()
193
  pdf.set_auto_page_break(auto=True, margin=15)
194
  pdf.set_font("Arial", size=12)
195
 
196
- for line in offer.split("\n"):
197
  pdf.multi_cell(0, 10, line)
198
 
199
- pdf_bytes = io.BytesIO()
200
- pdf_bytes.write(pdf.output(dest="S").encode("latin1"))
201
- pdf_bytes.seek(0)
202
- return pdf_bytes
 
 
 
 
 
 
 
 
203
 
204
 
205
  @output
 
177
  legal_notes=job.get("legal_notes", "Subject to U.S. labor law.")
178
  )
179
 
 
 
 
 
 
 
 
 
 
 
 
180
  pdf = FPDF()
181
  pdf.add_page()
182
  pdf.set_auto_page_break(auto=True, margin=15)
183
  pdf.set_font("Arial", size=12)
184
 
185
+ for line in contract.split("\n"):
186
  pdf.multi_cell(0, 10, line)
187
 
188
+ pdf_path = f'/tmp/Offer_Letter_{candidate_id}.pdf'
189
+ pdf.output(pdf_path)
190
+
191
+ return ui.HTML(f"<pre style='font-family: Georgia; font-size: 1rem'>{contract}</pre>")
192
+
193
+ @output
194
+ @render.download(filename="Offer_Letter.pdf")
195
+ def download_offer():
196
+ candidate_id = input.candidate_dropdown_doc()
197
+ pdf = f'/tmp/Offer_letter_{candidate_id}.pdf'
198
+
199
+ return pdf
200
 
201
 
202
  @output