From 6b42efcc8b1b6e1d374708410b7381deeb1ea70d Mon Sep 17 00:00:00 2001 From: rolux Date: Fri, 14 Jan 2011 10:35:53 +0000 Subject: [PATCH] more minor fixes --- pandora/itemlist/views.py | 15 +++++++++++++++ static/js/pandora.js | 25 +++++++++++++++++++++---- 2 files changed, 36 insertions(+), 4 deletions(-) diff --git a/pandora/itemlist/views.py b/pandora/itemlist/views.py index 8f54c1757..873a655b2 100644 --- a/pandora/itemlist/views.py +++ b/pandora/itemlist/views.py @@ -288,6 +288,21 @@ def editList(request): qs = models.Position.objects.filter(user=request.user, section='featured') pos.position = qs.aggregate(Max('position'))['position__max'] + 1 pos.save() + models.Position.objects.filter(list=list).exclude(id=pos.id).delete() + else: + models.Position.objects.filter(list=list).delete() + pos, created = models.Position.objects.get_or_create(list=list, user=list.user, + section='my') + qs = models.Position.objects.filter(user=list.user, section='my') + pos.position = qs.aggregate(Max('position'))['position__max'] + 1 + pos.save() + for u in list.subscribed_users.all(): + pos, created = models.Position.objects.get_or_create(list=list, user=u, + section='public') + qs = models.Position.objects.filter(user=u, section='public') + pos.position = qs.aggregate(Max('position'))['position__max'] + 1 + pos.save() + list.status = value elif key == 'name': name = data['name'].strip() diff --git a/static/js/pandora.js b/static/js/pandora.js index 151d79e1a..ac00fa784 100755 --- a/static/js/pandora.js +++ b/static/js/pandora.js @@ -35,6 +35,17 @@ var pandora = new Ox.App({ $.browser.safari && Ox.theme('modern'); } + // fixme: remove + app.uiDefaults = { + "list": { + "columns": ["id", "title", "director", "country", "year", "language", "runtime", "genre"], + "listView": "icons", + "selected": [], + "sort": [ + {"key": "director", "operator": ""} + ] + } + } // fixme: remove app.user.ui.showSection = { "my": true, @@ -1653,7 +1664,7 @@ var pandora = new Ox.App({ {key: 'status', value: 'public', operator: '='} ], operator: '&'} : {conditions: [ {key: 'status', value: 'public', operator: '='}, - {key: 'status', value: 'public', operator: '='} + {key: 'status', value: 'featured', operator: '='} ], operator: '|'}; return pandora.api.findLists($.extend(data, { query: query @@ -2418,9 +2429,12 @@ var pandora = new Ox.App({ query = {conditions: [ {key: 'user', value: app.user.username, operator: '='}, {key: 'status', value: 'featured', operator: '!'} - ], operator: ''}; + ], operator: '&'}; } else if (id == 'public') { - query = {conditions: [{key: 'subscribed', value: true, operator: '='}], operator: ''}; + query = {conditions: [ + {key: 'subscribed', value: true, operator: '='}, + {key: 'status', value: 'featured', operator: '!'}, + ], operator: '&'}; } else if (id == 'featured') { query = {conditions: [{key: 'status', value: 'featured', operator: '='}], operator: '&'}; } @@ -2485,6 +2499,7 @@ var pandora = new Ox.App({ pandora.api.removeList({ id: data.ids[0] }, function(result) { + delete app.user.ui.lists[data.ids[0]]; // fixme: how to delete a ui preference? Ox.Request.emptyCache(); // fixme: remove $list.reloadList(); }); @@ -2586,7 +2601,8 @@ var pandora = new Ox.App({ }) .bindEvent({ click: function(event, data) { - var id; + var $list = app.$ui.sectionList[i], + id; if (data.id == 'new' || data.id == 'newsmart') { pandora.api.addList({ name: 'Untitled', @@ -2594,6 +2610,7 @@ var pandora = new Ox.App({ type: data.id == 'new' ? 'static' : 'smart' }, function(result) { id = result.data.id; + app.user.ui.lists[id] = app.uiDefaults.list; URL.set('?find=list:' + id) Ox.Request.emptyCache(); // fixme: remove $list.reloadList().bindEvent({load: load});