StrangeIB commited on
Commit
16890dc
Β·
1 Parent(s): 67c1693

Download filename uses the report UID (not the student's name); same UID shared with the DB submission

Browse files
Files changed (1) hide show
  1. app.py +12 -5
app.py CHANGED
@@ -247,18 +247,25 @@ if uploaded is not None and consent:
247
  st.info("Part of your name might still show up inside a course title β€” "
248
  "we'll double-check that on our end.")
249
 
250
- stem = os.path.splitext(uploaded.name)[0]
251
- stem = stem.replace("DONOTSHARE_", "").replace("REDACTED_", "")
 
 
 
 
 
 
 
252
  st.download_button("⬇️ Download my redacted report", data=out,
253
- file_name=f"REDACTED_{stem}.pdf",
254
  mime="application/pdf")
255
- st.caption("Open it to make sure it looks right β€” then submit it below.")
 
256
 
257
  st.divider()
258
  if _submissions_enabled():
259
  st.markdown("**Share it with BBH**")
260
  if st.button("πŸ“€ Submit my redacted report"):
261
- uid = uuid.uuid4().hex[:8].upper()
262
  try:
263
  _upload_submission(out, uid)
264
  st.success("Submitted β€” thank you so much! πŸŽ‰")
 
247
  st.info("Part of your name might still show up inside a course title β€” "
248
  "we'll double-check that on our end.")
249
 
250
+ # One stable ID per uploaded file, shared by the download filename AND
251
+ # the database submission β€” so the filename never contains the student's
252
+ # name, and the file they keep matches what we store.
253
+ file_key = getattr(uploaded, "file_id", None) or f"{uploaded.name}:{uploaded.size}"
254
+ if st.session_state.get("uid_key") != file_key:
255
+ st.session_state["uid_key"] = file_key
256
+ st.session_state["uid"] = uuid.uuid4().hex[:8].upper()
257
+ uid = st.session_state["uid"]
258
+
259
  st.download_button("⬇️ Download my redacted report", data=out,
260
+ file_name=f"REDACTED_{uid}.pdf",
261
  mime="application/pdf")
262
+ st.caption(f"Saved as `REDACTED_{uid}.pdf` β€” that code is your report ID. "
263
+ "Open it to check it looks right, then submit below.")
264
 
265
  st.divider()
266
  if _submissions_enabled():
267
  st.markdown("**Share it with BBH**")
268
  if st.button("πŸ“€ Submit my redacted report"):
 
269
  try:
270
  _upload_submission(out, uid)
271
  st.success("Submitted β€” thank you so much! πŸŽ‰")