From c94df5dc491cff80bfa14cf1e66b62db48e05b01 Mon Sep 17 00:00:00 2001
From: grakiss <grakiss.wanglei@huawei.com>
Date: Wed, 13 Dec 2017 01:15:39 +0000
Subject: Bugfix: pass/not pass filter not work in result-report page

The reason is there are some conflict with jquery.js and ng-model.
So ng-model not work.

Change-Id: I01ccd0e297d1a89aff8f78d7fb0a63a0e2114f63
Signed-off-by: grakiss <grakiss.wanglei@huawei.com>
---
 cvp/3rd_party/static/testapi-ui/assets/css/combine.css           | 2 +-
 .../components/results-report/partials/reportDetails.html        | 6 +++---
 .../components/results-report/resultsReportController.js         | 5 +++++
 cvp/opnfv_testapi/resources/test_handlers.py                     | 9 ++++++++-
 4 files changed, 17 insertions(+), 5 deletions(-)

(limited to 'cvp')

diff --git a/cvp/3rd_party/static/testapi-ui/assets/css/combine.css b/cvp/3rd_party/static/testapi-ui/assets/css/combine.css
index b2f16c9a..a6395e78 100644
--- a/cvp/3rd_party/static/testapi-ui/assets/css/combine.css
+++ b/cvp/3rd_party/static/testapi-ui/assets/css/combine.css
@@ -816,7 +816,7 @@ h5 {
   margin-bottom: 0; }
 
 a, a:visited {
-  color: #30739C; }
+  color: #27CCC0; }
 
 .lead {
   font-size: 18px;
diff --git a/cvp/3rd_party/static/testapi-ui/components/results-report/partials/reportDetails.html b/cvp/3rd_party/static/testapi-ui/components/results-report/partials/reportDetails.html
index 7dc43964..b552ea47 100644
--- a/cvp/3rd_party/static/testapi-ui/components/results-report/partials/reportDetails.html
+++ b/cvp/3rd_party/static/testapi-ui/components/results-report/partials/reportDetails.html
@@ -6,15 +6,15 @@ report page.
 Test Filters:<br />
 <div class="btn-toolbar" role="toolbar">
     <div class="btn-group button-margin" data-toggle="buttons">
-        <label class="btn btn-default" ng-class="{'active': ctrl.testStatus === 'total'}">
+        <label class="btn btn-default" ng-click="ctrl.changeStatus('total')" ng-class="{'active': ctrl.testStatus === 'total'}">
             <input type="radio" ng-model="ctrl.testStatus" value="total">
             <span class="text-primary">All</span>
         </label>
-        <label class="btn btn-default" ng-class="{'active': ctrl.testStatus === 'passed'}">
+        <label class="btn btn-default" ng-click="ctrl.changeStatus('passed')" ng-class="{'active': ctrl.testStatus === 'passed'}">
             <input type="radio" ng-model="ctrl.testStatus" value="passed">
             <span class="text-success">Passed</span>
         </label>
-        <label class="btn btn-default" ng-class="{'active': ctrl.testStatus === 'not passed'}">
+        <label class="btn btn-default" ng-click="ctrl.changeStatus('not passed')" ng-class="{'active': ctrl.testStatus === 'not passed'}">
             <input type="radio" ng-model="ctrl.testStatus" value="not passed">
             <span class="text-danger">Not Passed</span>
         </label>
diff --git a/cvp/3rd_party/static/testapi-ui/components/results-report/resultsReportController.js b/cvp/3rd_party/static/testapi-ui/components/results-report/resultsReportController.js
index 0260938a..b0061f61 100644
--- a/cvp/3rd_party/static/testapi-ui/components/results-report/resultsReportController.js
+++ b/cvp/3rd_party/static/testapi-ui/components/results-report/resultsReportController.js
@@ -47,6 +47,7 @@
         ctrl.openAll = openAll;
         ctrl.folderAll = folderAll;
         ctrl.gotoResultLog = gotoResultLog;
+        ctrl.changeStatus = changeStatus;
 
         /** The testID extracted from the URL route. */
         ctrl.testId = $stateParams.testID;
@@ -58,6 +59,10 @@
 
         $scope.load_finish = false;
 
+        function changeStatus(value){
+            ctrl.testStatus = value;
+        }
+
         function extend(case_list) {
             angular.forEach(case_list, function(ele){
                 ctrl.case_list.push(ele);
diff --git a/cvp/opnfv_testapi/resources/test_handlers.py b/cvp/opnfv_testapi/resources/test_handlers.py
index 161585ef..2b5f28c2 100644
--- a/cvp/opnfv_testapi/resources/test_handlers.py
+++ b/cvp/opnfv_testapi/resources/test_handlers.py
@@ -221,7 +221,14 @@ class TestsGURHandler(GenericTestHandler):
                 query['owner'] = curr_user
                 db_keys.append('owner')
 
-                test_query = {'id': test['id'], 'status': 'review'}
+                test_query = {
+                    'id': test['id'],
+                    '$or': [
+                        {'status': 'review'},
+                        {'status': 'approved'},
+                        {'status': 'not approved'}
+                    ]
+                }
                 record = yield dbapi.db_find_one("tests", test_query)
                 if record:
                     msg = ('{} has already submitted one record with the same '
-- 
cgit