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:
j 2023-07-07 11:46:09 +05:30
commit 034b448846
7 changed files with 159 additions and 6 deletions

View file

@ -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: