Spaces:
Running
Running
MarcosRodrigo
commited on
Commit
•
a9ee083
1
Parent(s):
7d66593
Update app.py
Browse files
app.py
CHANGED
@@ -156,14 +156,30 @@ elif menu == "Current":
|
|
156 |
download_temp_file_from_repo()
|
157 |
current_df = load_current_selections()
|
158 |
st.table(current_df)
|
|
|
159 |
if st.button("Submit Summary to History"):
|
|
|
160 |
timestamp = save_summary_to_history()
|
161 |
st.success(f"Summary saved to history at {timestamp}")
|
162 |
-
|
163 |
-
|
164 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
165 |
st.experimental_set_query_params(step="reset")
|
166 |
|
|
|
167 |
# History view to check past summaries
|
168 |
elif menu == "History":
|
169 |
st.title("Breakfast Poll History")
|
|
|
156 |
download_temp_file_from_repo()
|
157 |
current_df = load_current_selections()
|
158 |
st.table(current_df)
|
159 |
+
|
160 |
if st.button("Submit Summary to History"):
|
161 |
+
# Save the current selections to history
|
162 |
timestamp = save_summary_to_history()
|
163 |
st.success(f"Summary saved to history at {timestamp}")
|
164 |
+
|
165 |
+
# Reload history after saving to reflect the new entry
|
166 |
+
st.session_state.history = load_history()
|
167 |
+
|
168 |
+
# Delete the current selections file and clear session state
|
169 |
+
if os.path.exists(TEMP_FILE):
|
170 |
+
os.remove(TEMP_FILE) # Remove the local current_selections.csv file
|
171 |
+
# Reset the session state to reflect the empty state
|
172 |
+
st.session_state.current_selections = []
|
173 |
+
|
174 |
+
# Create an empty CSV to replace the deleted one
|
175 |
+
pd.DataFrame(columns=["Name", "Drinks", "Food"]).to_csv(TEMP_FILE, index=False)
|
176 |
+
# Upload the empty file to the repository to ensure shared state is reset
|
177 |
+
upload_temp_file_to_repo()
|
178 |
+
|
179 |
+
# Refresh the view to show the empty table
|
180 |
st.experimental_set_query_params(step="reset")
|
181 |
|
182 |
+
|
183 |
# History view to check past summaries
|
184 |
elif menu == "History":
|
185 |
st.title("Breakfast Poll History")
|