use facets if possible for layer values

This commit is contained in:
j 2011-12-26 21:30:21 +01:00
parent ae556c62f0
commit e3b948f08f
4 changed files with 13 additions and 6 deletions

View file

@ -39,6 +39,10 @@ def parseCondition(condition, user):
else:
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')
if isinstance(key_type, list):
key_type = key_type[0]
@ -48,8 +52,8 @@ def parseCondition(condition, user):
'text': 'string',
'year': 'string',
'length': 'string',
'list': 'list',
'layer': 'string',
'list': 'list',
}.get(key_type, key_type)
if k == 'list':
key_type = ''
@ -95,7 +99,7 @@ def parseCondition(condition, user):
value_key = 'find__value'
else:
value_key = k
if k in models.Item.facet_keys + ['title']:
if k in facet_keys:
in_find = False
facet_value = 'facets__value%s' % {
'==': '__iexact',

View file

@ -541,7 +541,7 @@ class Item(models.Model):
'\n'.join([f.path for f in self.files.all()]))
elif key['type'] == 'layer':
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:
value = self.get(i)
if isinstance(value, list):

View file

@ -45,7 +45,7 @@
{"id": "collection", "title": "Collection", "type": "string"},
{"id": "source", "title": "Source", "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": "language", "title": "Language", "type": "string"},
{"id": "category", "title": "Category", "type": "string"},
@ -478,7 +478,7 @@
{"id": "source", "sort": [{"key": "name", "operator": "+"}]},
{"id": "category", "sort": [{"key": "items", "operator": "-"}]},
{"id": "keywords", "sort": [{"key": "items", "operator": "-"}]},
{"id": "location", "sort": [{"key": "items", "operator": "-"}]}
{"id": "locations", "sort": [{"key": "items", "operator": "-"}]}
],
"filtersSize": 176,
"find": {"conditions": [], "operator": "&"},

View file

@ -30,7 +30,10 @@ pandora.ui.placesDialog = function() {
pandora.api.findClips({
query: {
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 ? '&' : '|'
}