get rid of filters in config, only use itemKeys filter: true

This commit is contained in:
j 2013-09-30 18:34:44 +00:00
parent a04711e94c
commit 7a529bfd12
7 changed files with 19 additions and 53 deletions

View file

@ -75,23 +75,6 @@
included in find annotations. included in find annotations.
*/ */
"clipLayers": ["subtitles"], "clipLayers": ["subtitles"],
// fixme: either this, or filter: true in itemKeys, but not both
"filters": [
{"id": "director", "title": "Director", "type": "string"},
{"id": "country", "title": "Country", "type": "string"},
{"id": "year", "title": "Year", "type": "integer"},
{"id": "language", "title": "Language", "type": "string"},
{"id": "color", "title": "Color", "type": "string"},
{"id": "sound", "title": "Sound", "type": "string"},
{"id": "writer", "title": "Writer", "type": "string"},
{"id": "producer", "title": "Producer", "type": "string"},
{"id": "cinematographer", "title": "Cinematographer", "type": "string"},
{"id": "editor", "title": "Editor", "type": "string"},
{"id": "actor", "title": "Actor", "type": "string"},
{"id": "productionCompany", "title": "Studio", "type": "string"},
{"id": "genre", "title": "Genre", "type": "string"},
{"id": "keyword", "title": "Keyword", "type": "string"}
],
"flags": true, "flags": true,
"help": [ "help": [
{"id": "help", "title": "Help"}, {"id": "help", "title": "Help"},
@ -304,6 +287,7 @@
"type": ["string"], "type": ["string"],
"autocomplete": true, "autocomplete": true,
"columnWidth": 180, "columnWidth": 180,
"filter": true,
"find": true, "find": true,
"sort": true "sort": true
}, },

View file

@ -77,25 +77,6 @@
included in find annotations. included in find annotations.
*/ */
"clipLayers": ["subtitles", "keywords", "notes"], "clipLayers": ["subtitles", "keywords", "notes"],
// fixme: either this, or filter: true in itemKeys, but not both
"filters": [
{"id": "director", "title": "Director", "type": "string"},
{"id": "year", "title": "Year", "type": "integer"},
{"id": "language", "title": "Language", "type": "string"},
{"id": "color", "title": "Color", "type": "string"},
{"id": "sound", "title": "Sound", "type": "string"},
{"id": "productionCompany", "title": "Studio", "type": "string"},
{"id": "producer", "title": "Producer", "type": "string"},
{"id": "codirector", "title": "Co-Director", "type": "string"},
{"id": "writer", "title": "Writer", "type": "string"},
{"id": "cinematographer", "title": "Cinematographer", "type": "string"},
{"id": "editor", "title": "Editor", "type": "string"},
{"id": "composer", "title": "Composer", "type": "string"},
{"id": "lyricist", "title": "Lyricist", "type": "string"},
{"id": "actor", "title": "Actor", "type": "string"},
{"id": "genre", "title": "Genre", "type": "string"},
{"id": "keyword", "title": "Keyword", "type": "string"}
],
"flags": false, "flags": false,
"help": [ "help": [
{"id": "help", "title": "Help"}, {"id": "help", "title": "Help"},
@ -177,7 +158,6 @@
"type": ["string"], "type": ["string"],
"autocomplete": true, "autocomplete": true,
"columnWidth": 120, "columnWidth": 120,
"filter": true,
"find": true, "find": true,
"sort": true "sort": true
}, },

View file

@ -183,6 +183,7 @@
"title": "People", "title": "People",
"type": ["string"], "type": ["string"],
"autocomplete": true, "autocomplete": true,
"filter": true,
"find": true "find": true
}, },
{ {
@ -272,18 +273,21 @@
"id": "places", "id": "places",
"title": "Places", "title": "Places",
"type": "layer", "type": "layer",
"filter": true,
"find": true "find": true
}, },
{ {
"id": "events", "id": "events",
"title": "Events", "title": "Events",
"type": "layer", "type": "layer",
"filter": true,
"find": true "find": true
}, },
{ {
"id": "keywords", "id": "keywords",
"title": "Keywords", "title": "Keywords",
"type": "layer", "type": "layer",
"filter": true,
"find": true "find": true
}, },
{ {

View file

@ -73,15 +73,6 @@
included in find annotations. // FIXME: the last bit is not implemented. included in find annotations. // FIXME: the last bit is not implemented.
*/ */
"clipLayers": ["publicnotes", "keywords", "subtitles"], "clipLayers": ["publicnotes", "keywords", "subtitles"],
// fixme: either this, or filter: true in itemKeys, but not both
"filters": [
{"id": "director", "title": "Director", "type": "string"},
{"id": "country", "title": "Country", "type": "string"},
{"id": "year", "title": "Year", "type": "integer"},
{"id": "language", "title": "Languages", "type": "string"},
{"id": "featuring", "title": "Featuring", "type": "string"},
{"id": "keywords", "title": "Keywords", "type": "string"}
],
"flags": false, "flags": false,
"help": [ "help": [
{"id": "help", "title": "Help"}, {"id": "help", "title": "Help"},
@ -157,6 +148,7 @@
"autocomplete": true, "autocomplete": true,
"columnRequired": true, "columnRequired": true,
"columnWidth": 180, "columnWidth": 180,
"filter": true,
"sort": true, "sort": true,
"sortType": "person" "sortType": "person"
}, },
@ -225,6 +217,7 @@
"id": "keywords", "id": "keywords",
"title": "Keywords", "title": "Keywords",
"type": "layer", "type": "layer",
"filter": true,
"find": true "find": true
}, },
{ {

View file

@ -42,9 +42,6 @@ def parseCondition(condition, user, owner=None):
exclude = False exclude = False
facet_keys = models.Item.facet_keys + ['title'] 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]

View file

@ -895,10 +895,9 @@ class Item(models.Model):
Facet.objects.get_or_create(item=self, key=key, value=value, sortvalue=sortvalue) Facet.objects.get_or_create(item=self, key=key, value=value, sortvalue=sortvalue)
def update_layer_facets(self): def update_layer_facets(self):
filters = [f['id'] for f in settings.CONFIG['filters']] for k in settings.CONFIG['itemKeys']:
for layer in settings.CONFIG['layers']: if k.get('filter') and k['type'] == 'layer':
if layer['id'] in filters: self.update_layer_facet(k['id'])
self.update_layer_facet(layer['id'])
def update_facets(self): def update_facets(self):
for key in self.facet_keys + ['title']: for key in self.facet_keys + ['title']:

View file

@ -287,6 +287,15 @@ appPanel
operator: pandora.getSortOperator(key.id) operator: pandora.getSortOperator(key.id)
}); });
}), }),
filters: data.site.itemKeys.filter(function(key) {
return key.filter;
}).map(function(key) {
return {
id: key.id,
title: key.title,
type: Ox.isArray(key.type) ? key.type[0] : key.type
};
}),
findKeys: data.site.itemKeys.filter(function(key) { findKeys: data.site.itemKeys.filter(function(key) {
return key.find; return key.find;
}), }),