From 384c643326b78735710bee9b50f39a3152ee8528 Mon Sep 17 00:00:00 2001 From: j Date: Tue, 9 Aug 2016 13:16:30 +0100 Subject: [PATCH 1/3] no tags == [] --- pandora/archive/external.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pandora/archive/external.py b/pandora/archive/external.py index 834b6b77..b9bce934 100644 --- a/pandora/archive/external.py +++ b/pandora/archive/external.py @@ -55,6 +55,8 @@ def get_info(url): for k in info_keys if k in i and i[k] }) + if not 'tags' in info[-1]: + info[-1]['tags'] = [] if 'upload_date' in i: info[-1]['date'] = '-'.join([i['upload_date'][:4], i['upload_date'][4:6], i['upload_date'][6:]]) return info From c08ce51db2493ad15eb9eff4fde8fff9e74f2ba8 Mon Sep 17 00:00:00 2001 From: j Date: Tue, 9 Aug 2016 14:22:15 +0200 Subject: [PATCH 2/3] add padma importMetadata --- pandora/config.padma.jsonc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pandora/config.padma.jsonc b/pandora/config.padma.jsonc index 80727170..0b55196f 100644 --- a/pandora/config.padma.jsonc +++ b/pandora/config.padma.jsonc @@ -135,6 +135,12 @@ {"id": "texts", "title": "Texts"}, {"id": "embeds", "title": "Embeds"} ], + "importMetadata": { + "date": "{date}", + "topic": "{tags}", + "summary": "{description}", + "title": "{title}" + }, /* "itemKeys" defines the metadata associated with each item. Required keys are "*", "id" and "title". Annotation layers can be referenced too, which From 2157b719ec932074385aab640311d618b37b3d8d Mon Sep 17 00:00:00 2001 From: j Date: Tue, 9 Aug 2016 15:06:44 +0200 Subject: [PATCH 3/3] use more info from sort table, fixes #2953 --- pandora/item/views.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/pandora/item/views.py b/pandora/item/views.py index a0b83f20..970c0452 100644 --- a/pandora/item/views.py +++ b/pandora/item/views.py @@ -225,15 +225,18 @@ def find(request, data): clips = qs return [c.json(query['clip_keys'], query['clip_filter']) for c in clips] + sort_keys = { + 'accessed', 'modified', 'timesaccessed', + 'numberofannotations', 'numberoffiles', 'numberofdocuments' + } + def only_p_sums(m): r = {} for p in _p: if p == 'accessed': r[p] = m.sort.accessed or '' - elif p == 'modified': - r[p] = m.sort.modified - elif p == 'timesaccessed': - r[p] = m.sort.timesaccessed + elif p in sort_keys: + r[p] = getattr(m.sort, p) else: r[p] = m.json.get(p) if 'clip_qs' in query: @@ -252,9 +255,7 @@ def find(request, data): return r qs = qs[query['range'][0]:query['range'][1]] # response['data']['items'] = [m.get_json(_p) for m in qs] - if filter(lambda p: p in ( - 'accessed', 'modified', 'timesaccessed', 'viewed' - ), _p): + if any(p for p in _p if p in sort_keys): qs = qs.select_related() response['data']['items'] = [only_p_sums(m) for m in qs] else: