From dac07380473b24d6b56b6e609a323bdae1fc56ed Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Thu, 10 Nov 2011 23:12:20 +0000 Subject: [PATCH] dont reset list position while setting private lists public --- pandora/0xdb.jsonc | 1 + pandora/itemlist/views.py | 28 ++++++++++++++-------------- static/js/pandora/folderList.js | 1 + 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/pandora/0xdb.jsonc b/pandora/0xdb.jsonc index 61ef43dd7..bb3fa53a4 100644 --- a/pandora/0xdb.jsonc +++ b/pandora/0xdb.jsonc @@ -16,6 +16,7 @@ // "canClickMap": {"friend": true, "staff": true, "admin": true}, "canDeleteItems": {"admin": true}, "canDownloadVideo": {"guest": 0, "member": 0, "friend": 4, "staff": 4, "admin": 4}, + "canEditFeaturedLists": {"staff": true, "admin": true}, "canEditMetadata": {"staff": true, "admin": true}, "canEditSitePages": {"staff": true, "admin": true}, "canEditUsers": {"admin": true}, diff --git a/pandora/itemlist/views.py b/pandora/itemlist/views.py index 61a8aaee5..e7f563fce 100644 --- a/pandora/itemlist/views.py +++ b/pandora/itemlist/views.py @@ -233,8 +233,8 @@ def addList(request): value = data['status'] if value not in list._status: value = list._status[0] - if not request.user.is_staff and value == 'featured': - value = 'private' + if value == 'featured' and request.user.get_profile().capability('canEditFeaturedLists'): + value = list.status list.status = value if 'description' in data: list.description = data['description'] @@ -329,20 +329,20 @@ def editList(request): 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='personal') - qs = models.Position.objects.filter(user=list.user, - section='personal') + elif list.status == 'featured' and value == 'public': + models.Position.objects.filter(list=list).delete() + pos, created = models.Position.objects.get_or_create(list=list, + user=list.user,section='personal') + qs = models.Position.objects.filter(user=list.user, + section='personal') + 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() - 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': diff --git a/static/js/pandora/folderList.js b/static/js/pandora/folderList.js index 9d0100948..a1d6eaf1c 100644 --- a/static/js/pandora/folderList.js +++ b/static/js/pandora/folderList.js @@ -1,6 +1,7 @@ // vim: et:ts=4:sw=4:sts=4:ft=javascript 'use strict'; pandora.ui.folderList = function(id) { + // FIXME: use canEditFeaturedLists capability, not 'admin' var i = Ox.getPositionById(pandora.site.sectionFolders[pandora.user.ui.section], id), that; if (pandora.user.ui.section == 'items') {