aboutsummaryrefslogtreecommitdiffstats
path: root/opnfv_testapi
diff options
context:
space:
mode:
authorPanagiotis Karalis <pkaralis@intracom-telecom.com>2019-05-03 08:04:06 +0000
committerGerrit Code Review <gerrit@opnfv.org>2019-05-03 08:04:06 +0000
commit92becdc69c08beb4fd72bf8fa832fb7953412472 (patch)
tree927a4af64348aa989f1904a067358559868235eb /opnfv_testapi
parent95c53f27c194dbab6b609fc0d3b903811e392068 (diff)
parentda620c17769c0357e4a9137eedbb7cf044cc38d4 (diff)
Merge "Bug fix for ONAP/OVP portals"
Diffstat (limited to 'opnfv_testapi')
-rw-r--r--opnfv_testapi/resources/application_handlers.py8
-rw-r--r--opnfv_testapi/resources/handlers.py27
2 files changed, 28 insertions, 7 deletions
diff --git a/opnfv_testapi/resources/application_handlers.py b/opnfv_testapi/resources/application_handlers.py
index 7d823b8..653e6b5 100644
--- a/opnfv_testapi/resources/application_handlers.py
+++ b/opnfv_testapi/resources/application_handlers.py
@@ -236,19 +236,19 @@ class ApplicationsGURHandler(GenericApplicationHandler):
data = json.loads(self.request.body)
item = data.get('item')
value = data.get(item)
+ owner = data.get('owner')
logging.debug('%s:%s', item, value)
try:
- self.update(application_id, item, value)
+ self.update(application_id, item, value, owner)
except Exception as e:
logging.error('except:%s', e)
return
@gen.coroutine
- def update(self, application_id, item, value):
+ def update(self, application_id, item, value, owner):
self.json_args = {}
self.json_args[item] = value
- query = {'_id': objectid.ObjectId(application_id), 'owner':
- self.get_secure_cookie(auth_const.OPENID)}
+ query = {'_id': objectid.ObjectId(application_id), 'owner': owner}
db_keys = ['_id', 'owner']
if item == 'approved':
if value == 'true':
diff --git a/opnfv_testapi/resources/handlers.py b/opnfv_testapi/resources/handlers.py
index 559e689..df0cae5 100644
--- a/opnfv_testapi/resources/handlers.py
+++ b/opnfv_testapi/resources/handlers.py
@@ -79,6 +79,30 @@ class GenericApiHandler(web.RequestHandler):
date_range.update({'$gte': str(v)})
elif k == 'to':
date_range.update({'$lt': str(v)})
+ elif k == 'applications':
+ role = self.get_secure_cookie(auth_const.ROLE)
+ logging.info('role:%s', role)
+ if role:
+ if role.find("administrator") != -1:
+ query['$or'] = [
+ {
+ "status": {
+ "$ne": "private"
+ }
+ }
+ ]
+ elif k == 'review':
+ role = self.get_secure_cookie(auth_const.ROLE)
+ logging.info('role:%s', role)
+ if role:
+ if role.find("reviewer") != -1:
+ query['$or'] = [
+ {
+ "status": {
+ "$ne": "private"
+ }
+ }
+ ]
elif k == 'signed':
openid = self.get_secure_cookie(auth_const.OPENID)
user = yield dbapi.db_find_one("users", {'openid': openid})
@@ -98,9 +122,6 @@ class GenericApiHandler(web.RequestHandler):
}
}
]
-
- if role.find("reviewer") != -1:
- query['$or'].append({"status": {"$ne": "private"}})
elif k == 'status':
if v.startswith('{'):
query[k] = json.loads(v)