cjber commited on
Commit
53c84ab
·
1 Parent(s): a56fc0e

fix: sort to ensure buttons do not swap places

Browse files
Files changed (1) hide show
  1. app.py +18 -25
app.py CHANGED
@@ -171,6 +171,7 @@ def display_download_buttons():
171
  .collect()["representations_document"]
172
  .to_list()
173
  )
 
174
 
175
  # remove some old intermediate files
176
  _ = [file.unlink() for file in (Paths.STAGING / "pdfs_azure").glob("*.pdf")]
@@ -190,46 +191,38 @@ def display_download_buttons():
190
 
191
  # Add some spacing and better organization
192
  st.markdown("---")
193
-
194
- for i, rep in enumerate(representations_documents):
195
- report_path = Paths.SUMMARY / f"Summary_Documents-{rep}.pdf"
196
- summaries_path = Paths.SUMMARY / f"Summary_of_Submitted_Responses-{rep}.pdf"
197
-
198
- # Create a container for each report set
199
- with st.container():
200
- st.subheader(f"Report Set {i+1}: {rep}")
201
-
202
- # Create columns with better spacing
203
- col1, col2 = st.columns(2, gap="large")
204
-
205
- with col1:
206
- st.markdown("**Executive Report**")
207
  with open(summaries_path, "rb") as pdf_file:
208
  st.download_button(
209
- label="Download",
210
  data=pdf_file,
211
  file_name=f"Summary_of_Submitted_Responses-{rep}.pdf",
212
  mime="application/pdf",
213
- type="primary",
214
  use_container_width=True,
215
- key=f"exec_{rep}",
216
  )
 
217
 
218
- with col2:
219
- st.markdown("**Representation Summary**")
 
 
 
 
220
  with open(report_path, "rb") as pdf_file:
221
  st.download_button(
222
- label="Download",
223
  data=pdf_file,
224
  file_name=f"Summary_Documents-{rep}.pdf",
225
  mime="application/pdf",
226
- type="primary",
227
  use_container_width=True,
228
- key=f"rep_{rep}",
229
  )
230
-
231
- # Add a separator between report sets
232
- if i < len(representations_documents) - 1:
233
  st.markdown("---")
234
 
235
 
 
171
  .collect()["representations_document"]
172
  .to_list()
173
  )
174
+ representations_documents.sort()
175
 
176
  # remove some old intermediate files
177
  _ = [file.unlink() for file in (Paths.STAGING / "pdfs_azure").glob("*.pdf")]
 
191
 
192
  # Add some spacing and better organization
193
  st.markdown("---")
194
+ # Create a container for the Executive Reports
195
+ with st.expander("**Executive Reports**"):
196
+ for i, rep in enumerate(representations_documents):
197
+ summaries_path = Paths.SUMMARY / f"Summary_of_Submitted_Responses-{rep}.pdf"
198
+ with st.container():
199
+ st.subheader(f"Executive Report for {rep}")
 
 
 
 
 
 
 
 
200
  with open(summaries_path, "rb") as pdf_file:
201
  st.download_button(
202
+ label="Download Executive Report",
203
  data=pdf_file,
204
  file_name=f"Summary_of_Submitted_Responses-{rep}.pdf",
205
  mime="application/pdf",
 
206
  use_container_width=True,
207
+ key=f"exec_{i}_{hash(rep)}", # Ensure key uniqueness with index + hash
208
  )
209
+ st.markdown("---")
210
 
211
+ # Create a container for the Representation Summaries
212
+ with st.expander("**Representation Summaries**"):
213
+ for i, rep in enumerate(representations_documents):
214
+ report_path = Paths.SUMMARY / f"Summary_Documents-{rep}.pdf"
215
+ with st.container():
216
+ st.subheader(f"Representation Summary for {rep}")
217
  with open(report_path, "rb") as pdf_file:
218
  st.download_button(
219
+ label="Download Representation Summary",
220
  data=pdf_file,
221
  file_name=f"Summary_Documents-{rep}.pdf",
222
  mime="application/pdf",
 
223
  use_container_width=True,
224
+ key=f"rep_{i}_{hash(rep)}", # Ensure key uniqueness with index + hash
225
  )
 
 
 
226
  st.markdown("---")
227
 
228