From 1db88b4c96cac8f6f1f36d68506139f55423c3b9 Mon Sep 17 00:00:00 2001 From: j Date: Sun, 14 Jul 2019 11:33:38 +0100 Subject: [PATCH] fix poster frames for new lists --- pandora/documentcollection/models.py | 10 +++++----- static/js/folders.js | 10 +++++++++- static/js/utils.js | 4 +++- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/pandora/documentcollection/models.py b/pandora/documentcollection/models.py index 74b55b58a..e0295c47f 100644 --- a/pandora/documentcollection/models.py +++ b/pandora/documentcollection/models.py @@ -272,16 +272,16 @@ class Collection(models.Model): for i in range(0, documents.count(), max(1, int(documents.count()/4))): poster_frames.append({ 'document': documents[int(i)].get_id(), - #'page': documents[int(i)] }) self.poster_frames = tuple(poster_frames) self.save() for i in self.poster_frames: from document.models import Document - qs = Document.objects.filter(id=ox.fromAZ(i['document'])) - if qs.count() > 0: - frame = qs[0].thumbnail(size=1024, page=i.get('page')) - frames.append(frame) + if 'document' in i: + qs = Document.objects.filter(id=ox.fromAZ(i['document'])) + if qs.count() > 0: + frame = qs[0].thumbnail(size=1024, page=i.get('page')) + frames.append(frame) self.icon.name = self.path('icon.jpg') icon = self.icon.path if frames: diff --git a/static/js/folders.js b/static/js/folders.js index 188f163e7..21903e2bf 100644 --- a/static/js/folders.js +++ b/static/js/folders.js @@ -46,7 +46,15 @@ pandora.ui.folders = function(section) { pandora.$ui.personalListsMenu = Ox.MenuButton({ items: [ { id: 'newlist', title: Ox._('New {0}', [Ox._(folderItem)]), keyboard: 'control n' }, - { id: 'newlistfromselection', title: Ox._('New {0} from Selection', [Ox._(folderItem)]), keyboard: 'shift control n', disabled: ui.listSelection.length == 0 }, + { + id: 'newlistfromselection', + title: Ox._('New {0} from Selection', + [Ox._(folderItem)]), + keyboard: 'shift control n', + disabled: ui.section == 'documents' + ? ui.collectionSelection == 0 + : ui.listSelection.length == 0 + }, { id: 'newsmartlist', title: Ox._('New Smart {0}', [Ox._(folderItem)]), keyboard: 'alt control n' }, { id: 'newsmartlistfromresults', title: Ox._('New Smart {0} from Results', [Ox._(folderItem)]), keyboard: 'shift alt control n' }, {}, diff --git a/static/js/utils.js b/static/js/utils.js index 1fedf4c5a..5825e724f 100644 --- a/static/js/utils.js +++ b/static/js/utils.js @@ -192,7 +192,9 @@ pandora.addFolderItem = function(section) { }, function(result) { var posterFrames = result ? result.data.items.map(function(item) { - return {item: item.id, position: item.posterFrame}; + return section == 'documents' + ? {document: item.id} + : {item: item.id, position: item.posterFrame}; }) : []; posterFrames = posterFrames.length == 1 ? Ox.repeat([posterFrames[0]], 4)