cjber commited on
Commit
9270ac5
·
1 Parent(s): fa07861

fix: fix doc paths

Browse files
Files changed (1) hide show
  1. app.py +51 -56
app.py CHANGED
@@ -231,7 +231,6 @@ def specify_chapters():
231
  st.button(
232
  "Save Chapters", on_click=lambda: st.session_state.update({"chapters": True})
233
  )
234
- return title
235
 
236
 
237
  def upload_and_extract_files():
@@ -370,64 +369,59 @@ def display_download_buttons(rep):
370
  summaries_docx_path = (
371
  Paths.SUMMARY / f"Overview_of_Public_Submissions-{rep}.docx"
372
  )
373
- if summaries_pdf_path.exists() and summaries_docx_path.exists():
374
- with st.container():
375
- st.subheader(f"Executive Report for {rep}")
376
- col1, col2 = st.columns(2)
377
- with col1:
378
- with open(summaries_pdf_path, "rb") as pdf_file:
379
- st.download_button(
380
- label="Download PDF Version",
381
- data=pdf_file,
382
- file_name=f"Overview_of_Public_Submissions-{rep}.pdf",
383
- mime="application/pdf",
384
- use_container_width=True,
385
- key=f"exec_pdf_{hash(rep)}",
386
- )
387
- with col2:
388
- if summaries_docx_path.exists():
389
- with open(summaries_docx_path, "rb") as docx_file:
390
- st.download_button(
391
- label="Download DOCX Version",
392
- data=docx_file,
393
- file_name=f"Overview_of_Public_Submissions-{rep}.docx",
394
- mime="application/vnd.openxmlformats-officedocument.wordprocessingml.document",
395
- use_container_width=True,
396
- key=f"exec_docx_{hash(rep)}",
397
- )
398
- else:
399
- st.warning("DOCX version not available")
400
- st.markdown("---")
401
 
402
  # Create a container for the Representation Summaries
403
  with st.expander("**Representation Summaries**"):
404
  report_pdf_path = Paths.SUMMARY / f"Summaries_of_Public_Submissions-{rep}.pdf"
405
  report_docx_path = Paths.SUMMARY / f"Summaries_of_Public_Submissions-{rep}.docx"
406
- if report_pdf_path.exists() and report_docx_path.exists():
407
- with st.container():
408
- st.subheader(f"Representation Summary for {rep}")
409
- col1, col2 = st.columns(2)
410
- with col1:
411
- with open(report_pdf_path, "rb") as pdf_file:
412
- st.download_button(
413
- label="Download PDF Version",
414
- data=pdf_file,
415
- file_name=f"Summaries_of_Public_Submissions-{rep}.pdf",
416
- mime="application/pdf",
417
- use_container_width=True,
418
- key=f"rep_pdf_{hash(rep)}",
419
- )
420
- with col2:
421
- with open(report_docx_path, "rb") as docx_file:
422
- st.download_button(
423
- label="Download DOCX Version",
424
- data=docx_file,
425
- file_name=f"Summaries_of_Public_Submissions-{rep}.docx",
426
- mime="application/vnd.openxmlformats-officedocument.wordprocessingml.document",
427
- use_container_width=True,
428
- key=f"rep_docx_{hash(rep)}",
429
- )
430
- st.markdown("---")
431
 
432
 
433
  def reset_session():
@@ -466,9 +460,8 @@ def main():
466
  authenticator.logout() # show logout button
467
 
468
  # Step 1: Specify chapters
469
- rep = ""
470
  if not st.session_state["chapters"]:
471
- rep = specify_chapters()
472
 
473
  # Step 2: Upload and extract files
474
  if not st.session_state["files_extracted"] and st.session_state["chapters"]:
@@ -479,6 +472,8 @@ def main():
479
  build_report()
480
 
481
  # Step 4: Show download buttons when complete
 
 
482
  if st.session_state["completed"]:
483
  display_download_buttons(rep)
484
 
 
231
  st.button(
232
  "Save Chapters", on_click=lambda: st.session_state.update({"chapters": True})
233
  )
 
234
 
235
 
236
  def upload_and_extract_files():
 
369
  summaries_docx_path = (
370
  Paths.SUMMARY / f"Overview_of_Public_Submissions-{rep}.docx"
371
  )
372
+ with st.container():
373
+ st.subheader(f"Executive Report for {rep}")
374
+ col1, col2 = st.columns(2)
375
+ with col1:
376
+ with open(summaries_pdf_path, "rb") as pdf_file:
377
+ st.download_button(
378
+ label="Download PDF Version",
379
+ data=pdf_file,
380
+ file_name=f"Overview_of_Public_Submissions-{rep}.pdf",
381
+ mime="application/pdf",
382
+ use_container_width=True,
383
+ key=f"exec_pdf_{hash(rep)}",
384
+ )
385
+ with col2:
386
+ with open(summaries_docx_path, "rb") as docx_file:
387
+ st.download_button(
388
+ label="Download DOCX Version",
389
+ data=docx_file,
390
+ file_name=f"Overview_of_Public_Submissions-{rep}.docx",
391
+ mime="application/vnd.openxmlformats-officedocument.wordprocessingml.document",
392
+ use_container_width=True,
393
+ key=f"exec_docx_{hash(rep)}",
394
+ )
395
+ st.markdown("---")
 
 
 
 
396
 
397
  # Create a container for the Representation Summaries
398
  with st.expander("**Representation Summaries**"):
399
  report_pdf_path = Paths.SUMMARY / f"Summaries_of_Public_Submissions-{rep}.pdf"
400
  report_docx_path = Paths.SUMMARY / f"Summaries_of_Public_Submissions-{rep}.docx"
401
+ with st.container():
402
+ st.subheader(f"Representation Summary for {rep}")
403
+ col1, col2 = st.columns(2)
404
+ with col1:
405
+ with open(report_pdf_path, "rb") as pdf_file:
406
+ st.download_button(
407
+ label="Download PDF Version",
408
+ data=pdf_file,
409
+ file_name=f"Summaries_of_Public_Submissions-{rep}.pdf",
410
+ mime="application/pdf",
411
+ use_container_width=True,
412
+ key=f"rep_pdf_{hash(rep)}",
413
+ )
414
+ with col2:
415
+ with open(report_docx_path, "rb") as docx_file:
416
+ st.download_button(
417
+ label="Download DOCX Version",
418
+ data=docx_file,
419
+ file_name=f"Summaries_of_Public_Submissions-{rep}.docx",
420
+ mime="application/vnd.openxmlformats-officedocument.wordprocessingml.document",
421
+ use_container_width=True,
422
+ key=f"rep_docx_{hash(rep)}",
423
+ )
424
+ st.markdown("---")
 
425
 
426
 
427
  def reset_session():
 
460
  authenticator.logout() # show logout button
461
 
462
  # Step 1: Specify chapters
 
463
  if not st.session_state["chapters"]:
464
+ specify_chapters()
465
 
466
  # Step 2: Upload and extract files
467
  if not st.session_state["files_extracted"] and st.session_state["chapters"]:
 
472
  build_report()
473
 
474
  # Step 4: Show download buttons when complete
475
+ with open(Paths.RAW / "title.txt", "r") as f:
476
+ rep = f.read().strip()
477
  if st.session_state["completed"]:
478
  display_download_buttons(rep)
479