rsm-roguchi commited on
Commit
8b45fde
Β·
1 Parent(s): a0c8d1c
code/context.py CHANGED
@@ -1,11 +1,16 @@
1
  import json
2
  import os
 
3
 
4
- CONTEXT_PATH = "data/context.json"
 
 
 
 
5
 
6
  def init_context():
7
- if not os.path.exists("data"):
8
- os.makedirs("data")
9
  if not os.path.exists(CONTEXT_PATH):
10
  with open(CONTEXT_PATH, "w") as f:
11
  json.dump({"jobs": {}, "candidates": {}, 'employees': {}}, f)
 
1
  import json
2
  import os
3
+ import shutil
4
 
5
+ if not os.path.exists('/tmp/data'):
6
+ os.mkdir('/tmp/data')
7
+
8
+ shutil.copyfile('data/context.json', '/tmp/data/context.json')
9
+ CONTEXT_PATH = "/tmp/data/context.json"
10
 
11
  def init_context():
12
+ if not os.path.exists("/tmp/data"):
13
+ os.makedirs("/tmp/data")
14
  if not os.path.exists(CONTEXT_PATH):
15
  with open(CONTEXT_PATH, "w") as f:
16
  json.dump({"jobs": {}, "candidates": {}, 'employees': {}}, f)
server/document_creation.py CHANGED
@@ -151,7 +151,8 @@ def server(input, output, session):
151
  for line in offer.split("\n"):
152
  pdf.multi_cell(0, 10, line)
153
 
154
- pdf_path = f'/tmp/Offer_Letter_{candidate_id}.pdf'
 
155
  pdf.output(pdf_path)
156
 
157
  return ui.HTML(f"<pre style='font-family: Georgia; font-size: 1rem'>{offer}</pre>")
@@ -194,7 +195,8 @@ def server(input, output, session):
194
  for line in contract.split("\n"):
195
  pdf.multi_cell(0, 10, line)
196
 
197
- pdf_path = f'/tmp/Contract_{candidate_id}.pdf'
 
198
  pdf.output(pdf_path)
199
 
200
  return ui.HTML(f"<pre style='font-family: Georgia; font-size: 1rem'>{contract}</pre>")
@@ -203,7 +205,8 @@ def server(input, output, session):
203
  @render.download(filename="Offer_Letter.pdf")
204
  def download_offer():
205
  candidate_id = input.candidate_dropdown_doc()
206
- pdf = f'/tmp/Offer_letter_{candidate_id}.pdf'
 
207
 
208
  return pdf
209
 
@@ -212,7 +215,8 @@ def server(input, output, session):
212
  @render.download(filename="Contract.pdf")
213
  def download_contract():
214
  candidate_id = input.candidate_dropdown_doc()
215
- pdf = f"/tmp/Contract_{candidate_id}.pdf"
 
216
  return pdf
217
 
218
 
 
151
  for line in offer.split("\n"):
152
  pdf.multi_cell(0, 10, line)
153
 
154
+ os.mkdir(f'/tmp/data/{job_id}/offers', exist_ok=True)
155
+ pdf_path = f'/tmp/data/{job_id}/offers/Offer_Letter_{candidate_id}.pdf'
156
  pdf.output(pdf_path)
157
 
158
  return ui.HTML(f"<pre style='font-family: Georgia; font-size: 1rem'>{offer}</pre>")
 
195
  for line in contract.split("\n"):
196
  pdf.multi_cell(0, 10, line)
197
 
198
+ os.mkdir(f'/tmp/data/{job_id}/contracts', exist_ok=True)
199
+ pdf_path = f'/tmp/data/{job_id}/contracts/Contract_{candidate_id}.pdf'
200
  pdf.output(pdf_path)
201
 
202
  return ui.HTML(f"<pre style='font-family: Georgia; font-size: 1rem'>{contract}</pre>")
 
205
  @render.download(filename="Offer_Letter.pdf")
206
  def download_offer():
207
  candidate_id = input.candidate_dropdown_doc()
208
+ job_id = input.job_dropdown_doc()
209
+ pdf = f'/tmp/data/{job_id}/offers/Offer_Letter_{candidate_id}.pdf'
210
 
211
  return pdf
212
 
 
215
  @render.download(filename="Contract.pdf")
216
  def download_contract():
217
  candidate_id = input.candidate_dropdown_doc()
218
+ job_id = input.job_dropdown_doc()
219
+ pdf = f"/tmp/data/{job_id}/contracts/Contract_{candidate_id}.pdf"
220
  return pdf
221
 
222
 
server/home.py CHANGED
@@ -2,6 +2,7 @@ import uuid
2
  from pathlib import Path
3
  import tempfile
4
  from shiny import reactive, ui, render
 
5
 
6
  import os
7
  import sys
@@ -16,7 +17,13 @@ from context import (
16
 
17
  init_context()
18
 
19
- UPLOAD_DIR = Path(tempfile.gettempdir()) / "resumes"
 
 
 
 
 
 
20
  UPLOAD_DIR.mkdir(parents=True, exist_ok=True)
21
  print(f"Uploading resume to: {UPLOAD_DIR.resolve()} (tempdir)")
22
 
@@ -25,6 +32,7 @@ def server(input, output, session):
25
  @output
26
  @render.text
27
  @reactive.event(input.upload_resume_btn)
 
28
  def upload_result():
29
  print("🚨 upload_result triggered")
30
 
@@ -41,7 +49,7 @@ def server(input, output, session):
41
 
42
  candidate_id = str(uuid.uuid4())
43
  filename = f"{candidate_id}.pdf"
44
- target_path = UPLOAD_DIR / filename
45
  target_path.write_bytes(resume_bytes)
46
 
47
  candidate_data = {
 
2
  from pathlib import Path
3
  import tempfile
4
  from shiny import reactive, ui, render
5
+ import shutil
6
 
7
  import os
8
  import sys
 
17
 
18
  init_context()
19
 
20
+ src = 'data/resumes'
21
+ dst = '/tmp/data/resumes'
22
+ os.mkdir(dst, exist_ok=True)
23
+
24
+ shutil.copy(src, dst, dirs_exist_ok=True)
25
+
26
+ UPLOAD_DIR = f"/tmp/data/"
27
  UPLOAD_DIR.mkdir(parents=True, exist_ok=True)
28
  print(f"Uploading resume to: {UPLOAD_DIR.resolve()} (tempdir)")
29
 
 
32
  @output
33
  @render.text
34
  @reactive.event(input.upload_resume_btn)
35
+
36
  def upload_result():
37
  print("🚨 upload_result triggered")
38
 
 
49
 
50
  candidate_id = str(uuid.uuid4())
51
  filename = f"{candidate_id}.pdf"
52
+ target_path = os.path.join(UPLOAD_DIR, 'data', job_id, 'resumes')
53
  target_path.write_bytes(resume_bytes)
54
 
55
  candidate_data = {
server/interview_scheduler.py CHANGED
@@ -193,7 +193,7 @@ def server(input, output, session):
193
  filename = f"{safe_name}.pdf"
194
 
195
  # Correct folder: data/emails/{job_id}/
196
- output_dir = "/tmp/"
197
 
198
  os.makedirs(output_dir, exist_ok=True)
199
 
@@ -257,7 +257,7 @@ def server(input, output, session):
257
  if not job_id:
258
  return ui.p("⚠️ No active job selected.")
259
 
260
- file_path = f"/tmp/{selected}"
261
 
262
  if not os.path.exists(file_path):
263
  print("❌ File not found on disk.")
@@ -289,7 +289,7 @@ def server(input, output, session):
289
  return None # nothing to download
290
 
291
  job_id = session._memo.get("active_job_id", "").strip()
292
- zip_path = f"/tmp/Interview_Emails.zip"
293
 
294
  if os.path.exists(zip_path):
295
  os.remove(zip_path)
@@ -312,7 +312,7 @@ def server(input, output, session):
312
  return "⚠️ Select a PDF to edit."
313
 
314
  # Load original text
315
- pdf_path = f"/tmp/{selected}"
316
 
317
  if not os.path.exists(pdf_path):
318
  return "❌ Could not find the original PDF."
@@ -345,7 +345,7 @@ def server(input, output, session):
345
  for line in revised.strip().split("\n"):
346
  pdf.multi_cell(0, 10, line)
347
  pdf.output(pdf_path)
348
- pdf_files = [f for f in os.listdir("/tmp/") if f.endswith(".pdf")]
349
 
350
  ui.update_select("pdf_selector", choices=pdf_files)
351
  ui.update_text_area("edit_text", value=revised.strip())
@@ -362,7 +362,7 @@ def server(input, output, session):
362
  if not selected or not job_id:
363
  return
364
 
365
- file_path = f"/tmp/{selected}"
366
 
367
  if not os.path.exists(file_path):
368
  return
@@ -383,7 +383,7 @@ def server(input, output, session):
383
  if not selected or not job_id or not new_text:
384
  return
385
 
386
- file_path = f"/tmp/{selected}"
387
 
388
  pdf = FPDF()
389
  pdf.add_page()
@@ -394,7 +394,7 @@ def server(input, output, session):
394
  pdf.output(file_path)
395
 
396
  print(f"βœ… Overwrote PDF: {file_path}")
397
- pdf_files = [f for f in os.listdir("/tmp/") if f.endswith(".pdf")]
398
  ui.update_select("pdf_selector", choices=pdf_files)
399
 
400
  session.send_input_message("selected_pdf", {"value": selected})
 
193
  filename = f"{safe_name}.pdf"
194
 
195
  # Correct folder: data/emails/{job_id}/
196
+ output_dir = "/tmp/data/emails"
197
 
198
  os.makedirs(output_dir, exist_ok=True)
199
 
 
257
  if not job_id:
258
  return ui.p("⚠️ No active job selected.")
259
 
260
+ file_path = f"/tmp/data/emails/{selected}"
261
 
262
  if not os.path.exists(file_path):
263
  print("❌ File not found on disk.")
 
289
  return None # nothing to download
290
 
291
  job_id = session._memo.get("active_job_id", "").strip()
292
+ zip_path = f"/tmp/data/{job_id}/emails/Interview_Emails.zip"
293
 
294
  if os.path.exists(zip_path):
295
  os.remove(zip_path)
 
312
  return "⚠️ Select a PDF to edit."
313
 
314
  # Load original text
315
+ pdf_path = f"/tmp/data/{job_id}/emails/{selected}"
316
 
317
  if not os.path.exists(pdf_path):
318
  return "❌ Could not find the original PDF."
 
345
  for line in revised.strip().split("\n"):
346
  pdf.multi_cell(0, 10, line)
347
  pdf.output(pdf_path)
348
+ pdf_files = [f for f in os.listdir(f"/tmp/data/{job_id}/emails/") if f.endswith(".pdf")]
349
 
350
  ui.update_select("pdf_selector", choices=pdf_files)
351
  ui.update_text_area("edit_text", value=revised.strip())
 
362
  if not selected or not job_id:
363
  return
364
 
365
+ file_path = f"/tmp/data/{job_id}/emails/{selected}"
366
 
367
  if not os.path.exists(file_path):
368
  return
 
383
  if not selected or not job_id or not new_text:
384
  return
385
 
386
+ file_path = f"/tmp/data/{job_id}/emails/{selected}"
387
 
388
  pdf = FPDF()
389
  pdf.add_page()
 
394
  pdf.output(file_path)
395
 
396
  print(f"βœ… Overwrote PDF: {file_path}")
397
+ pdf_files = [f for f in os.listdir(f"/tmp/data/{job_id}/emails") if f.endswith(".pdf")]
398
  ui.update_select("pdf_selector", choices=pdf_files)
399
 
400
  session.send_input_message("selected_pdf", {"value": selected})