diff --git a/pandora/config.0xdb.jsonc b/pandora/config.0xdb.jsonc index 14cf5e6e..fb774402 100644 --- a/pandora/config.0xdb.jsonc +++ b/pandora/config.0xdb.jsonc @@ -75,23 +75,6 @@ included in find annotations. */ "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, "help": [ {"id": "help", "title": "Help"}, @@ -304,6 +287,7 @@ "type": ["string"], "autocomplete": true, "columnWidth": 180, + "filter": true, "find": true, "sort": true }, diff --git a/pandora/config.indiancinema.jsonc b/pandora/config.indiancinema.jsonc index 11dc817c..b0f99b21 100644 --- a/pandora/config.indiancinema.jsonc +++ b/pandora/config.indiancinema.jsonc @@ -77,25 +77,6 @@ included in find annotations. */ "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, "help": [ {"id": "help", "title": "Help"}, @@ -177,7 +158,6 @@ "type": ["string"], "autocomplete": true, "columnWidth": 120, - "filter": true, "find": true, "sort": true }, diff --git a/pandora/config.padma.jsonc b/pandora/config.padma.jsonc index b735c451..f91b16c1 100644 --- a/pandora/config.padma.jsonc +++ b/pandora/config.padma.jsonc @@ -183,6 +183,7 @@ "title": "People", "type": ["string"], "autocomplete": true, + "filter": true, "find": true }, { @@ -272,18 +273,21 @@ "id": "places", "title": "Places", "type": "layer", + "filter": true, "find": true }, { "id": "events", "title": "Events", "type": "layer", + "filter": true, "find": true }, { "id": "keywords", "title": "Keywords", "type": "layer", + "filter": true, "find": true }, { diff --git a/pandora/config.pandora.jsonc b/pandora/config.pandora.jsonc index dfe4657a..8a527ff2 100644 --- a/pandora/config.pandora.jsonc +++ b/pandora/config.pandora.jsonc @@ -73,15 +73,6 @@ included in find annotations. // FIXME: the last bit is not implemented. */ "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, "help": [ {"id": "help", "title": "Help"}, @@ -157,6 +148,7 @@ "autocomplete": true, "columnRequired": true, "columnWidth": 180, + "filter": true, "sort": true, "sortType": "person" }, @@ -225,6 +217,7 @@ "id": "keywords", "title": "Keywords", "type": "layer", + "filter": true, "find": true }, { diff --git a/pandora/item/managers.py b/pandora/item/managers.py index 728b2de2..4ce60c53 100644 --- a/pandora/item/managers.py +++ b/pandora/item/managers.py @@ -42,9 +42,6 @@ def parseCondition(condition, user, owner=None): 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] diff --git a/pandora/item/models.py b/pandora/item/models.py index c6472357..24ad896f 100644 --- a/pandora/item/models.py +++ b/pandora/item/models.py @@ -895,10 +895,9 @@ class Item(models.Model): Facet.objects.get_or_create(item=self, key=key, value=value, sortvalue=sortvalue) def update_layer_facets(self): - filters = [f['id'] for f in settings.CONFIG['filters']] - for layer in settings.CONFIG['layers']: - if layer['id'] in filters: - self.update_layer_facet(layer['id']) + for k in settings.CONFIG['itemKeys']: + if k.get('filter') and k['type'] == 'layer': + self.update_layer_facet(k['id']) def update_facets(self): for key in self.facet_keys + ['title']: diff --git a/static/js/pandora.js b/static/js/pandora.js index abea4110..14e83ce1 100644 --- a/static/js/pandora.js +++ b/static/js/pandora.js @@ -287,6 +287,15 @@ appPanel 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) { return key.find; }),