forked from 0x2620/pandora
use facets if possible for layer values
This commit is contained in:
parent
ae556c62f0
commit
e3b948f08f
4 changed files with 13 additions and 6 deletions
|
@ -39,6 +39,10 @@ def parseCondition(condition, user):
|
||||||
else:
|
else:
|
||||||
exclude = False
|
exclude = False
|
||||||
|
|
||||||
|
facet_keys = models.Item.facet_keys + ['title']
|
||||||
|
for f in settings.CONFIG['filters']:
|
||||||
|
if f['id'] not in facet_keys:
|
||||||
|
facet_keys.append(f['id'])
|
||||||
key_type = settings.CONFIG['keys'].get(k, {'type':'string'}).get('type')
|
key_type = settings.CONFIG['keys'].get(k, {'type':'string'}).get('type')
|
||||||
if isinstance(key_type, list):
|
if isinstance(key_type, list):
|
||||||
key_type = key_type[0]
|
key_type = key_type[0]
|
||||||
|
@ -48,8 +52,8 @@ def parseCondition(condition, user):
|
||||||
'text': 'string',
|
'text': 'string',
|
||||||
'year': 'string',
|
'year': 'string',
|
||||||
'length': 'string',
|
'length': 'string',
|
||||||
'list': 'list',
|
|
||||||
'layer': 'string',
|
'layer': 'string',
|
||||||
|
'list': 'list',
|
||||||
}.get(key_type, key_type)
|
}.get(key_type, key_type)
|
||||||
if k == 'list':
|
if k == 'list':
|
||||||
key_type = ''
|
key_type = ''
|
||||||
|
@ -95,7 +99,7 @@ def parseCondition(condition, user):
|
||||||
value_key = 'find__value'
|
value_key = 'find__value'
|
||||||
else:
|
else:
|
||||||
value_key = k
|
value_key = k
|
||||||
if k in models.Item.facet_keys + ['title']:
|
if k in facet_keys:
|
||||||
in_find = False
|
in_find = False
|
||||||
facet_value = 'facets__value%s' % {
|
facet_value = 'facets__value%s' % {
|
||||||
'==': '__iexact',
|
'==': '__iexact',
|
||||||
|
|
|
@ -541,7 +541,7 @@ class Item(models.Model):
|
||||||
'\n'.join([f.path for f in self.files.all()]))
|
'\n'.join([f.path for f in self.files.all()]))
|
||||||
elif key['type'] == 'layer':
|
elif key['type'] == 'layer':
|
||||||
qs = Annotation.objects.filter(layer=i, item=self).order_by('start')
|
qs = Annotation.objects.filter(layer=i, item=self).order_by('start')
|
||||||
save(i, '\n'.join([l.findvalue for l in qs]))
|
save(i, u'\n'.join([l.findvalue for l in qs]))
|
||||||
elif i != '*' and i not in self.facet_keys:
|
elif i != '*' and i not in self.facet_keys:
|
||||||
value = self.get(i)
|
value = self.get(i)
|
||||||
if isinstance(value, list):
|
if isinstance(value, list):
|
||||||
|
|
|
@ -45,7 +45,7 @@
|
||||||
{"id": "collection", "title": "Collection", "type": "string"},
|
{"id": "collection", "title": "Collection", "type": "string"},
|
||||||
{"id": "source", "title": "Source", "type": "string"},
|
{"id": "source", "title": "Source", "type": "string"},
|
||||||
{"id": "director", "title": "Director", "type": "string"},
|
{"id": "director", "title": "Director", "type": "string"},
|
||||||
{"id": "location", "title": "Location", "type": "string"},
|
{"id": "locations", "title": "Location", "type": "string"},
|
||||||
{"id": "year", "title": "Year", "type": "integer"},
|
{"id": "year", "title": "Year", "type": "integer"},
|
||||||
{"id": "language", "title": "Language", "type": "string"},
|
{"id": "language", "title": "Language", "type": "string"},
|
||||||
{"id": "category", "title": "Category", "type": "string"},
|
{"id": "category", "title": "Category", "type": "string"},
|
||||||
|
@ -478,7 +478,7 @@
|
||||||
{"id": "source", "sort": [{"key": "name", "operator": "+"}]},
|
{"id": "source", "sort": [{"key": "name", "operator": "+"}]},
|
||||||
{"id": "category", "sort": [{"key": "items", "operator": "-"}]},
|
{"id": "category", "sort": [{"key": "items", "operator": "-"}]},
|
||||||
{"id": "keywords", "sort": [{"key": "items", "operator": "-"}]},
|
{"id": "keywords", "sort": [{"key": "items", "operator": "-"}]},
|
||||||
{"id": "location", "sort": [{"key": "items", "operator": "-"}]}
|
{"id": "locations", "sort": [{"key": "items", "operator": "-"}]}
|
||||||
],
|
],
|
||||||
"filtersSize": 176,
|
"filtersSize": 176,
|
||||||
"find": {"conditions": [], "operator": "&"},
|
"find": {"conditions": [], "operator": "&"},
|
||||||
|
|
|
@ -30,7 +30,10 @@ pandora.ui.placesDialog = function() {
|
||||||
pandora.api.findClips({
|
pandora.api.findClips({
|
||||||
query: {
|
query: {
|
||||||
conditions: names.map(function(name) {
|
conditions: names.map(function(name) {
|
||||||
return {key: 'subtitles', value: name, operator: '='};
|
//FIXME: this should be more generic
|
||||||
|
return Ox.getObjectById(pandora.site.layers, 'subtitles')
|
||||||
|
? {key: 'subtitles', value: name, operator: '='}
|
||||||
|
: {key: 'locations', value: name, operator: '=='};
|
||||||
}),
|
}),
|
||||||
operator: names.length == 1 ? '&' : '|'
|
operator: names.length == 1 ? '&' : '|'
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue