[odrs-web] Do not add reviews with taboo words



commit 20febf0929b3be7ce0580086f21229a0c2d43a52
Author: Richard Hughes <richard hughsie com>
Date:   Thu Mar 17 14:07:06 2022 +0000

    Do not add reviews with taboo words

 app_data/odrs/tests/odrs_test.py | 6 ++----
 app_data/odrs/views_api.py       | 2 +-
 2 files changed, 3 insertions(+), 5 deletions(-)
---
diff --git a/app_data/odrs/tests/odrs_test.py b/app_data/odrs/tests/odrs_test.py
index 3b96b5b..d5b47fb 100644
--- a/app_data/odrs/tests/odrs_test.py
+++ b/app_data/odrs/tests/odrs_test.py
@@ -336,10 +336,8 @@ class OdrsTest(unittest.TestCase):
         assert b"Added taboo" in rv.data, rv.data
 
         # submit something, and ensure it's flagged
-        self.review_submit()
-        rv = self.app.get("/admin/review/1")
-        assert b"Somebody Important" in rv.data, rv.data
-        assert b"Contains taboo" in rv.data, rv.data
+        rv = self._review_submit()
+        assert b"review contains taboo word" in rv.data, rv.data
 
         # delete
         rv = self.app.get("/admin/taboo/1/delete", follow_redirects=True)
diff --git a/app_data/odrs/views_api.py b/app_data/odrs/views_api.py
index 54e26ce..2b92c06 100644
--- a/app_data/odrs/views_api.py
+++ b/app_data/odrs/views_api.py
@@ -201,7 +201,7 @@ def api_submit():
 
     # contains taboos
     if review.matches_taboos(_get_taboos_for_locale(review.locale)):
-        review.reported = 5
+        return json_error("review contains taboo word")
 
     # log and add
     _eventlog_add(_get_client_address(), review.user_id, component.app_id, "reviewed")


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