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
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 |
-
|
| 251 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 252 |
st.download_button("β¬οΈ Download my redacted report", data=out,
|
| 253 |
-
file_name=f"REDACTED_{
|
| 254 |
mime="application/pdf")
|
| 255 |
-
st.caption("
|
|
|
|
| 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! π")
|