Skip to content
Snippets Groups Projects
Unverified Commit 41ea7dc3 authored by Harsha Kethineni's avatar Harsha Kethineni Committed by GitHub
Browse files

Merge pull request #1064 from scitran/filter-alias

'plus' and 'minus' download filters 
parents adf6a5b1 6d5545cd
No related branches found
No related tags found
No related merge requests found
......@@ -17,8 +17,8 @@ log = config.log
BYTES_IN_MEGABYTE = float(1<<20)
def _filter_check(property_filter, property_values):
minus = set(property_filter.get('-', []))
plus = set(property_filter.get('+', []))
minus = set(property_filter.get('-', []) + property_filter.get('minus', []))
plus = set(property_filter.get('+', []) + property_filter.get('plus', []))
if "null" in plus and not property_values:
return True
if "null" in minus and property_values:
......
......@@ -3,6 +3,6 @@
"nodes": [{"level":"project", "_id":"57abe1589e512c513d42cb83"}],
"filters":[{
"tags":{"+":["incomplete"]},
"types":{"+":["dicom"]}
"types":{"plus":["dicom"]}
}]
}
......@@ -5,7 +5,9 @@
"type": "object",
"properties": {
"+": {"$ref": "#/definitions/filterItems"},
"-": {"$ref": "#/definitions/filterItems"}
"plus": {"$ref": "#definitions/filterItems"},
"-": {"$ref": "#/definitions/filterItems"},
"minus": {"$ref": "#definitions/filterItems"}
},
"additionalProperties": false
},
......
......@@ -463,6 +463,20 @@ def test_filters(data_builder, file_form, as_admin):
assert r.ok
assert r.json()['file_cnt'] == 2
# Use filter aliases
r = as_admin.post('/download', json={
'optional': False,
'filters': [
{'tags': {'plus':['red']}}
],
'nodes': [
{'level': 'session', '_id': session},
]
})
assert r.ok
# 'plus' is same as using '+'
assert r.json()['file_cnt'] == 2
# Filter by type
as_admin.post('/acquisitions/' + acquisition + '/files', files=file_form(
"test", meta={'name': "test", 'tags': ['red', 'blue']}))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment