[cvp-web] Bugfix: Results shared by email are not shown on non-reviewer's pages 43/46843/4
authorgrakiss <grakiss.wanglei@huawei.com>
Wed, 8 Nov 2017 07:58:34 +0000 (07:58 +0000)
committerLeo wang <grakiss.wanglei@huawei.com>
Thu, 9 Nov 2017 11:24:49 +0000 (11:24 +0000)
JIRA: DOVETAIL-551

The CVP web portal can support share with name and
share with email address.
But when sharing with email, the pages of non-reviewers
will not show the results shared by others.

Change-Id: I94451448cc60d1f7a3472d756c502200757a16a8
Signed-off-by: grakiss <grakiss.wanglei@huawei.com>
cvp/opnfv_testapi/resources/handlers.py

index 51092b9..9b156e1 100644 (file)
@@ -81,18 +81,22 @@ class GenericApiHandler(web.RequestHandler):
                 role = self.get_secure_cookie(auth_const.ROLE)
                 logging.info('role:%s', role)
                 if role:
+                    query['$or'] = [
+                        {
+                            "shared": {
+                                "$elemMatch": {"$eq": openid}
+                            }
+                        },
+                        {"owner": openid},
+                        {
+                            "shared": {
+                                "$elemMatch": {"$eq": user.get("email")}
+                            }
+                        }
+                    ]
+
                     if role.find("reviewer") != -1:
-                        query['$or'] = [{"shared":
-                                         {"$elemMatch": {"$eq": openid}}},
-                                        {"owner": openid},
-                                        {"shared": {"$elemMatch":
-                                                    {"$eq":
-                                                     user.get("email")}}},
-                                        {"status": {"$ne": "private"}}]
-                    else:
-                        query['$or'] = [{"shared":
-                                         {"$elemMatch": {"$eq": openid}}
-                                         }, {"owner": openid}]
+                        query['$or'].append({"status": {"$ne": "private"}})
             elif k not in ['last', 'page', 'descend', 'per_page']:
                 query[k] = v
             if date_range: