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:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue