forked from 0x2620/pandora
add filter of layer values(i.e. keywords)
This commit is contained in:
parent
d070cb616b
commit
3cd321a116
2 changed files with 22 additions and 34 deletions
|
@ -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.value for l in qs]))
|
||||
save(i, '\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):
|
||||
|
@ -733,6 +733,22 @@ class Item(models.Model):
|
|||
#update cached values in clips
|
||||
self.clips.all().update(director=s.director, title=s.title)
|
||||
|
||||
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:
|
||||
key = layer['id']
|
||||
current_values = [a['value']
|
||||
for a in self.annotations.filter(layer=key).distinct().values('value')]
|
||||
saved_values = [i.value for i in Facet.objects.filter(item=self, key=key)]
|
||||
removed_values = filter(lambda i: i not in current_values, saved_values)
|
||||
if removed_values:
|
||||
Facet.objects.filter(item=self, key=key, value__in=removed_values).delete()
|
||||
for value in current_values:
|
||||
if value not in saved_values:
|
||||
sortvalue = value
|
||||
Facet.objects.get_or_create(item=self, key=key, value=value, sortvalue=sortvalue)
|
||||
|
||||
def update_facets(self):
|
||||
for key in self.facet_keys + ['title']:
|
||||
current_values = self.get(key, [])
|
||||
|
@ -769,6 +785,7 @@ class Item(models.Model):
|
|||
if key in self.person_keys + ['name']:
|
||||
sortvalue = get_name_sort(value)
|
||||
Facet.objects.get_or_create(item=self, key=key, value=value, sortvalue=sortvalue)
|
||||
self.update_layer_facets()
|
||||
|
||||
def path(self, name=''):
|
||||
h = self.itemId
|
||||
|
|
|
@ -49,12 +49,7 @@
|
|||
{"id": "year", "title": "Year", "type": "integer"},
|
||||
{"id": "language", "title": "Language", "type": "string"},
|
||||
{"id": "category", "title": "Category", "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": "keyword", "title": "Keyword", "type": "string"}
|
||||
{"id": "keywords", "title": "Keyword", "type": "string"}
|
||||
],
|
||||
/*
|
||||
An itemKey must have the following properties:
|
||||
|
@ -174,30 +169,6 @@
|
|||
"filter": true,
|
||||
"find": true
|
||||
},
|
||||
{
|
||||
"id": "genre",
|
||||
"title": "Genre",
|
||||
"type": ["string"],
|
||||
"autocomplete": true,
|
||||
"columnWidth": 120,
|
||||
"filter": true,
|
||||
"find": true
|
||||
},
|
||||
{
|
||||
"id": "keyword",
|
||||
"title": "Keyword",
|
||||
"type": ["string"],
|
||||
"autocomplete": true,
|
||||
"filter": true,
|
||||
"find": true
|
||||
},
|
||||
{
|
||||
"id": "numberofkeywords",
|
||||
"title": "Number of Keywords",
|
||||
"type": "integer",
|
||||
"columnWidth": 60,
|
||||
"value": {"key": "keyword", "type": "length"}
|
||||
},
|
||||
{
|
||||
"id": "description",
|
||||
"title": "Description",
|
||||
|
@ -503,10 +474,10 @@
|
|||
}
|
||||
},
|
||||
"filters": [
|
||||
{"id": "collection", "sort": [{"key": "name", "operator": "-"}]},
|
||||
{"id": "source", "sort": [{"key": "items", "operator": "-"}]},
|
||||
{"id": "collection", "sort": [{"key": "name", "operator": "+"}]},
|
||||
{"id": "source", "sort": [{"key": "name", "operator": "+"}]},
|
||||
{"id": "category", "sort": [{"key": "items", "operator": "-"}]},
|
||||
{"id": "keyword", "sort": [{"key": "items", "operator": "-"}]},
|
||||
{"id": "keywords", "sort": [{"key": "items", "operator": "-"}]},
|
||||
{"id": "location", "sort": [{"key": "items", "operator": "-"}]}
|
||||
],
|
||||
"filtersSize": 176,
|
||||
|
|
Loading…
Reference in a new issue