Spaces:
Sleeping
Sleeping
Update src/streamlit_app.py
Browse files- src/streamlit_app.py +11 -7
src/streamlit_app.py
CHANGED
|
@@ -189,18 +189,22 @@ if movie_id:
|
|
| 189 |
|
| 190 |
rating_key = f"detail_rating_{movie_id}"
|
| 191 |
user_rating = next((r["rating"] for r in all_ratings_data if r["movie_id"] == movie_id), None)
|
| 192 |
-
|
| 193 |
-
|
| 194 |
-
else
|
| 195 |
-
|
| 196 |
-
|
| 197 |
-
|
|
|
|
|
|
|
| 198 |
save_rating_to_json({
|
| 199 |
"movie_id": movie_id,
|
| 200 |
-
"rating":
|
| 201 |
"timestamp": datetime.now().isoformat()
|
| 202 |
})
|
|
|
|
| 203 |
st.rerun()
|
|
|
|
| 204 |
except Exception as e:
|
| 205 |
st.error("Could not load movie details.")
|
| 206 |
|
|
|
|
| 189 |
|
| 190 |
rating_key = f"detail_rating_{movie_id}"
|
| 191 |
user_rating = next((r["rating"] for r in all_ratings_data if r["movie_id"] == movie_id), None)
|
| 192 |
+
st.markdown("### Your Rating")
|
| 193 |
+
existing_rating = next((r["rating"] for r in all_ratings_data if r["movie_id"] == movie_id), None)
|
| 194 |
+
initial_index = existing_rating - 1 if existing_rating else None
|
| 195 |
+
|
| 196 |
+
new_rating = st.radio("Rate this movie:", [1, 2, 3, 4, 5], horizontal=True, index=initial_index, key=rating_key)
|
| 197 |
+
|
| 198 |
+
if st.button("Submit Rating"):
|
| 199 |
+
if new_rating:
|
| 200 |
save_rating_to_json({
|
| 201 |
"movie_id": movie_id,
|
| 202 |
+
"rating": new_rating,
|
| 203 |
"timestamp": datetime.now().isoformat()
|
| 204 |
})
|
| 205 |
+
st.success("Rating saved.")
|
| 206 |
st.rerun()
|
| 207 |
+
|
| 208 |
except Exception as e:
|
| 209 |
st.error("Could not load movie details.")
|
| 210 |
|