add ability to hide list/edits/collections from personal section but keep around in case they are shared or linked from elsewhere, but cluster the personal section
This commit is contained in:
parent
bd9d2ecd7e
commit
034b448846
7 changed files with 159 additions and 6 deletions
|
@ -133,7 +133,13 @@ def load_config(init=False):
|
|||
added = []
|
||||
for key in sorted(d):
|
||||
if key not in c:
|
||||
added.append("\"%s\": %s," % (key, json.dumps(d[key])))
|
||||
if key not in (
|
||||
'hidden',
|
||||
'find',
|
||||
'findDocuments',
|
||||
'videoPoints',
|
||||
):
|
||||
added.append("\"%s\": %s," % (key, json.dumps(d[key])))
|
||||
c[key] = d[key]
|
||||
if added:
|
||||
sys.stderr.write("adding default %s:\n\t" % section)
|
||||
|
|
|
@ -1159,6 +1159,11 @@ examples (config.SITENAME.jsonc) that are part of this pan.do/ra distribution.
|
|||
"findDocuments": {"conditions": [], "operator": "&"},
|
||||
"followPlayer": true,
|
||||
"help": "",
|
||||
"hidden": {
|
||||
"collections": [],
|
||||
"edits": [],
|
||||
"lists": []
|
||||
},
|
||||
"icons": "posters",
|
||||
"infoIconSize": 256,
|
||||
"item": "",
|
||||
|
|
|
@ -86,6 +86,11 @@ def findCollections(request, data):
|
|||
for x in data.get('query', {}).get('conditions', [])
|
||||
)
|
||||
|
||||
is_personal = request.user.is_authenticated and any(
|
||||
(x['key'] == 'user' and x['value'] == request.user.username and x['operator'] == '==')
|
||||
for x in data.get('query', {}).get('conditions', [])
|
||||
)
|
||||
|
||||
if is_section_request:
|
||||
qs = query['qs']
|
||||
if not is_featured and not request.user.is_anonymous:
|
||||
|
@ -94,6 +99,9 @@ def findCollections(request, data):
|
|||
else:
|
||||
qs = _order_query(query['qs'], query['sort'])
|
||||
|
||||
if is_personal and request.user.profile.ui['hidden']['collections']:
|
||||
qs = qs.exclude(name__in=request.user.profile.ui['hidden']['collections'])
|
||||
|
||||
response = json_response()
|
||||
if 'keys' in data:
|
||||
qs = qs[query['range'][0]:query['range'][1]]
|
||||
|
|
|
@ -412,6 +412,11 @@ def findEdits(request, data):
|
|||
|
||||
is_featured = any(filter(is_featured_condition, data.get('query', {}).get('conditions', [])))
|
||||
|
||||
is_personal = request.user.is_authenticated and any(
|
||||
(x['key'] == 'user' and x['value'] == request.user.username and x['operator'] == '==')
|
||||
for x in data.get('query', {}).get('conditions', [])
|
||||
)
|
||||
|
||||
if is_section_request:
|
||||
qs = query['qs']
|
||||
if not is_featured and not request.user.is_anonymous:
|
||||
|
@ -420,6 +425,9 @@ def findEdits(request, data):
|
|||
else:
|
||||
qs = _order_query(query['qs'], query['sort'])
|
||||
|
||||
if is_personal and request.user.profile.ui['hidden']['edits']:
|
||||
qs = qs.exclude(name__in=request.user.profile.ui['hidden']['edits'])
|
||||
|
||||
response = json_response()
|
||||
if 'keys' in data:
|
||||
qs = qs[query['range'][0]:query['range'][1]]
|
||||
|
|
|
@ -84,6 +84,11 @@ def findLists(request, data):
|
|||
for x in data.get('query', {}).get('conditions', [])
|
||||
)
|
||||
|
||||
is_personal = request.user.is_authenticated and any(
|
||||
(x['key'] == 'user' and x['value'] == request.user.username and x['operator'] == '==')
|
||||
for x in data.get('query', {}).get('conditions', [])
|
||||
)
|
||||
|
||||
if is_section_request:
|
||||
qs = query['qs']
|
||||
if not is_featured and not request.user.is_anonymous:
|
||||
|
@ -92,6 +97,9 @@ def findLists(request, data):
|
|||
else:
|
||||
qs = _order_query(query['qs'], query['sort'])
|
||||
|
||||
if is_personal and request.user.profile.ui['hidden']['lists']:
|
||||
qs = qs.exclude(name__in=request.user.profile.ui['hidden']['lists'])
|
||||
|
||||
response = json_response()
|
||||
if 'keys' in data:
|
||||
qs = qs[query['range'][0]:query['range'][1]]
|
||||
|
@ -412,7 +420,10 @@ def sortLists(request, data):
|
|||
models.Position.objects.filter(section=section, list=l).exclude(id=pos.id).delete()
|
||||
else:
|
||||
for i in ids:
|
||||
l = get_list_or_404_json(i)
|
||||
try:
|
||||
l = get_list_or_404_json(i)
|
||||
except:
|
||||
continue
|
||||
pos, created = models.Position.objects.get_or_create(list=l,
|
||||
user=request.user, section=section)
|
||||
if pos.position != position:
|
||||
|
|
|
@ -60,7 +60,7 @@ pandora.ui.folders = function(section) {
|
|||
{},
|
||||
{ id: 'duplicatelist', title: Ox._('Duplicate Selected {0}', [Ox._(folderItem)]), keyboard: 'control d', disabled: ui.section == 'documents' ? !ui._collection : !ui._list },
|
||||
{ id: 'editlist', title: Ox._('Edit Selected {0}...', [Ox._(folderItem)]), keyboard: 'control e', disabled: !editable },
|
||||
{ id: 'deletelist', title: Ox._('Delete Selected {0}...', [Ox._(folderItem)]), keyboard: 'delete', disabled: !editable }
|
||||
{ id: 'deletelist', title: Ox._('Delete Selected {0}...', [Ox._(folderItem)]), keyboard: 'delete', disabled: !editable },
|
||||
],
|
||||
title: 'edit',
|
||||
tooltip: Ox._('Manage Personal ' + folderItems),
|
||||
|
|
|
@ -284,6 +284,67 @@ pandora.ui.mainMenu = function() {
|
|||
}
|
||||
} else if (data.id == 'deletelist') {
|
||||
pandora.ui.deleteListDialog().open();
|
||||
} else if (data.id.startsWith('hidden:')) {
|
||||
var folderItems = {
|
||||
documents: 'Collections',
|
||||
edits: 'Edits',
|
||||
items: 'Lists'
|
||||
}[ui.section],
|
||||
folderKey = folderItems.toLowerCase(),
|
||||
listName = data.id.slice(7).replace(/\t/g, '_'),
|
||||
set = {}
|
||||
|
||||
if (ui.section == "items") {
|
||||
set.find = {
|
||||
conditions: [
|
||||
{key: 'list', value: pandora.user.username + ":" + listName, operator: '=='}
|
||||
],
|
||||
operator: '&'
|
||||
}
|
||||
} else if (ui.section == "edits") {
|
||||
set.edit = pandora.user.username + ":" + listName;
|
||||
} else if (ui.section == "documents") {
|
||||
set.findDocuments = {
|
||||
conditions: [
|
||||
{key: 'collection', value: pandora.user.username + ":" + listName, operator: '=='}
|
||||
],
|
||||
operator: '&'
|
||||
}
|
||||
}
|
||||
set['hidden.' + folderKey] = ui.hidden[folderKey].filter(name => { return name != listName })
|
||||
pandora.UI.set(set)
|
||||
Ox.Request.clearCache('find' + folderItems);
|
||||
pandora.$ui.folderList.personal.reloadList()
|
||||
} else if (data.id == 'hidelist') {
|
||||
var folderItems = {
|
||||
documents: 'Collections',
|
||||
edits: 'Edits',
|
||||
items: 'Lists'
|
||||
}[ui.section],
|
||||
folderKey = folderItems.toLowerCase(),
|
||||
listName = ({
|
||||
documents: ui._collection,
|
||||
edits: ui.edit,
|
||||
items: ui._list
|
||||
}[ui.section]).split(':', 2)[1],
|
||||
set = {};
|
||||
if (ui.section == "items") {
|
||||
set.find = {
|
||||
conditions: [],
|
||||
operator: '&'
|
||||
}
|
||||
} else if (ui.section == "edits") {
|
||||
set.edit = ""
|
||||
} else if (ui.section == "documents") {
|
||||
set.findDocuments = {
|
||||
conditions: [],
|
||||
operator: '&'
|
||||
};
|
||||
}
|
||||
set['hidden.' + folderKey] = Ox.unique([listName].concat(pandora.user.ui.hidden[folderKey]))
|
||||
pandora.UI.set(set)
|
||||
Ox.Request.clearCache('find' + folderItems);
|
||||
pandora.$ui.folderList.personal.reloadList()
|
||||
} else if (data.id == 'print') {
|
||||
window.open(document.location.href + '#print', '_blank');
|
||||
} else if (data.id == 'tv') {
|
||||
|
@ -627,7 +688,11 @@ pandora.ui.mainMenu = function() {
|
|||
that.uncheckItem(previousList == '' ? 'allitems' : 'viewlist' + previousList.replace(/_/g, Ox.char(9)));
|
||||
that.checkItem(list == '' ? 'allitems' : 'viewlist' + list.replace(/_/g, '\t'));
|
||||
}
|
||||
that[ui._list ? 'enableItem' : 'disableItem']('duplicatelist');
|
||||
that[list ? 'enableItem' : 'disableItem']('duplicatelist');
|
||||
that[
|
||||
list && pandora.$ui.folderList && pandora.$ui.folderList.personal.options('selected').length
|
||||
? 'enableItem' : 'disableItem'
|
||||
]('hidelist');
|
||||
that[action]('editlist');
|
||||
that[action]('deletelist');
|
||||
that[ui.listSelection.length ? 'enableItem' : 'disableItem']('newlistfromselection');
|
||||
|
@ -646,6 +711,10 @@ pandora.ui.mainMenu = function() {
|
|||
that.checkItem(edit == '' ? 'allitems' : 'viewlist' + edit.replace(/_/g, '\t'));
|
||||
}
|
||||
that[!isGuest && edit ? 'enableItem' : 'disableItem']('duplicatelist');
|
||||
that[
|
||||
!isGuest && edit && pandora.$ui.folderList && pandora.$ui.folderList.personal.options('selected').length
|
||||
? 'enableItem' : 'disableItem'
|
||||
]('hidelist');
|
||||
that[action]('editlist');
|
||||
that[action]('deletelist');
|
||||
that[!isGuest && edit ? 'enableItem' : 'disableItem']('newlistfromselection');
|
||||
|
@ -665,7 +734,11 @@ pandora.ui.mainMenu = function() {
|
|||
that.uncheckItem(previousList == '' ? 'allitems' : 'viewlist' + previousList.replace(/_/g, Ox.char(9)));
|
||||
that.checkItem(list == '' ? 'allitems' : 'viewlist' + list.replace(/_/g, '\t'));
|
||||
}
|
||||
that[ui._list ? 'enableItem' : 'disableItem']('duplicatelist');
|
||||
that[list ? 'enableItem' : 'disableItem']('duplicatelist');
|
||||
that[
|
||||
list && pandora.$ui.folderList && pandora.$ui.folderList.personal.options('selected').length
|
||||
? 'enableItem' : 'disableItem'
|
||||
]('hidelist');
|
||||
that[action]('editlist');
|
||||
that[action]('deletelist');
|
||||
that[ui.listSelection.length ? 'enableItem' : 'disableItem']('newlistfromselection');
|
||||
|
@ -1169,6 +1242,18 @@ pandora.ui.mainMenu = function() {
|
|||
})
|
||||
};
|
||||
}),
|
||||
ui.hidden[itemNamePlural.toLowerCase()].length ? [
|
||||
{
|
||||
id: 'hiddenlists',
|
||||
title: Ox._('Hidden ' + itemNamePlural),
|
||||
items: ui.hidden[itemNamePlural.toLowerCase()].map(id => {
|
||||
return {
|
||||
id: 'hidden:' + id.replace(/_/g, Ox.char(9)),
|
||||
title: id
|
||||
}
|
||||
})
|
||||
}
|
||||
] : [],
|
||||
[
|
||||
{},
|
||||
{ id: 'newlist', title: Ox._('New ' + itemNameSingular), disabled: isGuest, keyboard: 'control n' },
|
||||
|
@ -1180,6 +1265,8 @@ pandora.ui.mainMenu = function() {
|
|||
{ id: 'editlist', title: Ox._('Edit Selected ' + itemNameSingular + '...'), disabled: disableEdit, keyboard: 'control e' },
|
||||
{ id: 'deletelist', title: Ox._('Delete Selected ' + itemNameSingular + '...'), disabled: disableEdit, keyboard: 'delete' },
|
||||
{},
|
||||
{ id: 'hidelist', title: Ox._('Hide Selected ' + itemNameSingular + '...'), disabled: disableEdit || !pandora.$ui.folderList || !pandora.$ui.folderList.personal.options('selected').length},
|
||||
{},
|
||||
{ id: 'print', title: Ox._('Print'), keyboard: 'control p' }
|
||||
]
|
||||
)};
|
||||
|
@ -1216,6 +1303,18 @@ pandora.ui.mainMenu = function() {
|
|||
})
|
||||
};
|
||||
}),
|
||||
ui.hidden[itemNamePlural.toLowerCase()].length ? [
|
||||
{
|
||||
id: 'hiddenlists',
|
||||
title: Ox._('Hidden ' + itemNamePlural),
|
||||
items: ui.hidden[itemNamePlural.toLowerCase()].map(id => {
|
||||
return {
|
||||
id: 'hidden:' + id.replace(/_/g, Ox.char(9)),
|
||||
title: id
|
||||
}
|
||||
})
|
||||
}
|
||||
] : [],
|
||||
[
|
||||
{},
|
||||
{ id: 'newlist', title: Ox._('New ' + itemNameSingular), disabled: isGuest, keyboard: 'control n' },
|
||||
|
@ -1224,7 +1323,9 @@ pandora.ui.mainMenu = function() {
|
|||
{},
|
||||
{ id: 'duplicatelist', title: Ox._('Duplicate Selected ' + itemNameSingular), disabled: disableEdit, keyboard: 'control d' },
|
||||
{ id: 'editlist', title: Ox._('Edit Selected ' + itemNameSingular + '...'), disabled: disableEdit, keyboard: 'control e' },
|
||||
{ id: 'deletelist', title: Ox._('Delete Selected ' + itemNameSingular + '...'), disabled: disableEdit, keyboard: 'delete' }
|
||||
{ id: 'deletelist', title: Ox._('Delete Selected ' + itemNameSingular + '...'), disabled: disableEdit, keyboard: 'delete' },
|
||||
{},
|
||||
{ id: 'hidelist', title: Ox._('Hide Selected ' + itemNameSingular + '...'), disabled: disableEdit || !pandora.$ui.folderList || !pandora.$ui.folderList.personal.options('selected').length},
|
||||
]
|
||||
)};
|
||||
}
|
||||
|
@ -1284,6 +1385,18 @@ pandora.ui.mainMenu = function() {
|
|||
})
|
||||
};
|
||||
}),
|
||||
ui.hidden[itemNamePlural.toLowerCase()].length ? [
|
||||
{
|
||||
id: 'hiddenlists',
|
||||
title: Ox._('Hidden ' + itemNamePlural),
|
||||
items: ui.hidden[itemNamePlural.toLowerCase()].map(id => {
|
||||
return {
|
||||
id: 'hidden:' + id.replace(/_/g, Ox.char(9)),
|
||||
title: id
|
||||
}
|
||||
})
|
||||
}
|
||||
] : [],
|
||||
[
|
||||
{},
|
||||
{ id: 'newlist', title: Ox._('New ' + itemNameSingular), disabled: isGuest, keyboard: 'control n' },
|
||||
|
@ -1297,6 +1410,8 @@ pandora.ui.mainMenu = function() {
|
|||
{ id: 'editlist', title: Ox._('Edit Selected ' + itemNameSingular + '...'), disabled: disableEdit, keyboard: 'control e' },
|
||||
{ id: 'deletelist', title: Ox._('Delete Selected ' + itemNameSingular + '...'), disabled: disableEdit, keyboard: 'delete' },
|
||||
{},
|
||||
{ id: 'hidelist', title: Ox._('Hide Selected ' + itemNameSingular + '...'), disabled: disableEdit || !pandora.$ui.folderList || !pandora.$ui.folderList.personal.options('selected').length},
|
||||
{},
|
||||
{ id: 'print', title: Ox._('Print'), keyboard: 'control p' },
|
||||
{ id: 'tv', title: Ox._('TV'), keyboard: 'control space' }
|
||||
]
|
||||
|
|
Loading…
Reference in a new issue