Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -116,7 +116,6 @@ def reset_selections():
|
|
116 |
if menu == "Poll":
|
117 |
st.title("Breakfast Poll Application")
|
118 |
|
119 |
-
# Step 1: Enter User's Name
|
120 |
if st.session_state.step == 1:
|
121 |
st.header("Step 1: Enter your name")
|
122 |
name = st.text_input("Name:")
|
@@ -124,8 +123,7 @@ if menu == "Poll":
|
|
124 |
st.session_state.users.append(name)
|
125 |
st.session_state.step = 2
|
126 |
|
127 |
-
|
128 |
-
elif st.session_state.step == 2:
|
129 |
st.header("Step 2: Select your drink(s)")
|
130 |
drinks_options = [
|
131 |
"Café con leche", "Colacao", "Descafeinado con leche", "Cortado",
|
@@ -137,8 +135,7 @@ if menu == "Poll":
|
|
137 |
st.session_state.current_selections.append({"Name": st.session_state.users[-1], "Drinks": selected_drinks})
|
138 |
st.session_state.step = 3
|
139 |
|
140 |
-
|
141 |
-
elif st.session_state.step == 3:
|
142 |
st.header("Step 3: Select your food(s)")
|
143 |
food_options = [
|
144 |
"Barrita con aceite", "Barrita con tomate", "Palmera de chocolate",
|
@@ -192,3 +189,43 @@ elif menu == "History":
|
|
192 |
st.table(record["Summary"])
|
193 |
else:
|
194 |
st.write("No history records found.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
116 |
if menu == "Poll":
|
117 |
st.title("Breakfast Poll Application")
|
118 |
|
|
|
119 |
if st.session_state.step == 1:
|
120 |
st.header("Step 1: Enter your name")
|
121 |
name = st.text_input("Name:")
|
|
|
123 |
st.session_state.users.append(name)
|
124 |
st.session_state.step = 2
|
125 |
|
126 |
+
if st.session_state.step == 2:
|
|
|
127 |
st.header("Step 2: Select your drink(s)")
|
128 |
drinks_options = [
|
129 |
"Café con leche", "Colacao", "Descafeinado con leche", "Cortado",
|
|
|
135 |
st.session_state.current_selections.append({"Name": st.session_state.users[-1], "Drinks": selected_drinks})
|
136 |
st.session_state.step = 3
|
137 |
|
138 |
+
if st.session_state.step == 3:
|
|
|
139 |
st.header("Step 3: Select your food(s)")
|
140 |
food_options = [
|
141 |
"Barrita con aceite", "Barrita con tomate", "Palmera de chocolate",
|
|
|
189 |
st.table(record["Summary"])
|
190 |
else:
|
191 |
st.write("No history records found.")
|
192 |
+
|
193 |
+
# "Current" view to display the current summary of all users' selections and submit to history
|
194 |
+
elif menu == "Current":
|
195 |
+
st.title("Current Selections of All Users")
|
196 |
+
if st.button("Reload Selections"):
|
197 |
+
download_temp_file_from_repo()
|
198 |
+
current_df = load_current_selections()
|
199 |
+
st.table(current_df)
|
200 |
+
|
201 |
+
if st.button("Submit Summary to History"):
|
202 |
+
timestamp = save_summary_to_history()
|
203 |
+
st.success(f"Summary saved to history at {timestamp}")
|
204 |
+
st.session_state.history = load_history()
|
205 |
+
|
206 |
+
# Clear local and remote current selections
|
207 |
+
if os.path.exists(TEMP_FILE):
|
208 |
+
os.remove(TEMP_FILE)
|
209 |
+
delete_file_from_repo(TEMP_FILE) # Delete the file from the remote repo
|
210 |
+
|
211 |
+
# Create an empty CSV to replace the deleted one
|
212 |
+
pd.DataFrame(columns=["Name", "Drinks", "Food"]).to_csv(TEMP_FILE, index=False)
|
213 |
+
upload_temp_file_to_repo()
|
214 |
+
|
215 |
+
# st.experimental_set_query_params(step="reset")
|
216 |
+
|
217 |
+
# History view to check past summaries
|
218 |
+
elif menu == "History":
|
219 |
+
st.title("Breakfast Poll History")
|
220 |
+
|
221 |
+
# Reload history if it's not already loaded
|
222 |
+
if not st.session_state.history:
|
223 |
+
st.session_state.history = load_history()
|
224 |
+
|
225 |
+
if st.session_state.history:
|
226 |
+
# Display history in reverse chronological order
|
227 |
+
for record in reversed(st.session_state.history):
|
228 |
+
st.subheader(f"Date: {record['Date']}")
|
229 |
+
st.table(record["Summary"])
|
230 |
+
else:
|
231 |
+
st.write("No history records found.")
|