summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgrakiss <grakiss.wanglei@huawei.com>2017-11-20 06:19:29 +0000
committerLeo wang <grakiss.wanglei@huawei.com>2017-11-20 06:49:38 +0000
commit85c2c85ab5ae91141bacb23d0d881dcbfa5e9bd6 (patch)
treea15c3144dce82b820a414465917ebbfac7c8d5ee
parent29547a92197f88a732420761ee72d92dcc4b9972 (diff)
[cvp-web] Can't submit the same results to review from different users
JIRA: DOVETAIL-560 Can't submit the same results to review from different users. Change-Id: I4a3dcc2dc8a817653ac9da6f93722659e04c89a1 Signed-off-by: grakiss <grakiss.wanglei@huawei.com>
-rw-r--r--cvp/opnfv_testapi/resources/test_handlers.py28
1 files changed, 12 insertions, 16 deletions
diff --git a/cvp/opnfv_testapi/resources/test_handlers.py b/cvp/opnfv_testapi/resources/test_handlers.py
index 3c33b7d..2baa294 100644
--- a/cvp/opnfv_testapi/resources/test_handlers.py
+++ b/cvp/opnfv_testapi/resources/test_handlers.py
@@ -189,25 +189,21 @@ class TestsGURHandler(GenericTestHandler):
query = {'_id': objectid.ObjectId(_id)}
db_keys = ['_id', ]
curr_user = self.get_secure_cookie(auth_const.OPENID)
- if item in {"shared", "label"}:
+ if item in {"shared", "label", "status"}:
query['owner'] = curr_user
db_keys.append('owner')
- if item == 'status':
- user = yield dbapi.db_find_one("users", {'openid': curr_user})
- query["$or"] = [
- {"owner": curr_user},
- {
- "shared": {
- "$elemMatch": {"$eq": curr_user}
- }
- },
- {
- "shared": {
- "$elemMatch": {"$eq": user['email']}
- }
- }
- ]
+ if item == "status" and value == "review":
+ test = yield dbapi.db_find_one("tests", query)
+ if test:
+ test_query = {'id': test['id'], 'status': 'review'}
+ record = yield dbapi.db_find_one("tests", test_query)
+ if record:
+ msg = ('{} has already submitted one record with the same'
+ 'Test ID: {}'.format(record['owner'], test['id']))
+ self.finish_request({'code': 403, 'msg': msg})
+ return
+
logging.debug("before _update 2")
self._update(query=query, db_keys=db_keys)