From 9768eb4e788da99607c01efde03748b881f3d6d9 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Mon, 1 Aug 2011 17:51:34 +0200 Subject: [PATCH] poster precedence --- pandora/item/models.py | 4 +++- static/js/pandora/ui/postersDialog.js | 6 +++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/pandora/item/models.py b/pandora/item/models.py index 0ab7367d..7df6e512 100644 --- a/pandora/item/models.py +++ b/pandora/item/models.py @@ -313,7 +313,8 @@ class Item(models.Model): for service in services: if service not in precedence: precedence.append(service) - precedence.append(settings.URL) + if settings.URL not in precedence: + precedence.append(settings.URL) posters = [ { @@ -337,6 +338,7 @@ class Item(models.Model): 'selected': p.url == url, 'precedence': precedence.index(p.service) }) + posters.sort(key=lambda a: a['precedence']) return posters def get_stream(self): diff --git a/static/js/pandora/ui/postersDialog.js b/static/js/pandora/ui/postersDialog.js index eb62d9a8..9ab53ce0 100644 --- a/static/js/pandora/ui/postersDialog.js +++ b/static/js/pandora/ui/postersDialog.js @@ -59,13 +59,13 @@ pandora.ui.postersDialog = function(id) { } }, items: posters, - keys: ['source', 'width', 'height', 'url'], + keys: ['precedence', 'source', 'width', 'height', 'url'], max: 1, min: 1, orientation: 'vertical', selected: selected, size: 128, - sort: [{key: 'source', operator: '+'}], + sort: [{key: 'precedence', operator: '+'}], unique: 'source' }) .css({background: 'rgb(16, 16, 16)'}) @@ -103,4 +103,4 @@ pandora.ui.postersDialog = function(id) { return that; -} \ No newline at end of file +}