[odrs-web] Fix showing all the reviews for a specific user



commit bc38aee59e4062696669e7f5f142f61acfa2b009
Author: Richard Hughes <richard hughsie com>
Date:   Wed Jul 3 21:01:12 2019 +0100

    Fix showing all the reviews for a specific user

 app_data/odrs/views_admin.py | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
---
diff --git a/app_data/odrs/views_admin.py b/app_data/odrs/views_admin.py
index 56b98d3..551d105 100644
--- a/app_data/odrs/views_admin.py
+++ b/app_data/odrs/views_admin.py
@@ -490,7 +490,11 @@ def admin_show_user(user_hash):
     """
     Return all the reviews from a user on the server as HTML.
     """
-    reviews = db.session.query(Review).filter(Review.user_hash == user_hash).all()
+    user = db.session.query(User).filter(User.user_hash == user_hash).first()
+    if not user:
+        flash('No user with that user_hash')
+        return redirect(url_for('.admin_show_all'))
+    reviews = db.session.query(Review).filter(Review.user_id == user.user_id).all()
     return render_template('show-all.html', reviews=reviews)
 
 @app.route('/admin/show/app/<app_id>')


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]