fix sorting favorite lists, fixes #1679
This commit is contained in:
parent
19f345b865
commit
fd496dfee0
4 changed files with 11 additions and 4 deletions
|
@ -453,6 +453,9 @@ def sortEdits(request):
|
||||||
data = json.loads(request.POST['data'])
|
data = json.loads(request.POST['data'])
|
||||||
position = 0
|
position = 0
|
||||||
section = data['section']
|
section = data['section']
|
||||||
|
section = {
|
||||||
|
'favorite': 'public'
|
||||||
|
}.get(section,section)
|
||||||
#ids = list(set(data['ids']))
|
#ids = list(set(data['ids']))
|
||||||
ids = data['ids']
|
ids = data['ids']
|
||||||
if section == 'featured' and not request.user.get_profile().capability('canEditFeaturedEdits'):
|
if section == 'featured' and not request.user.get_profile().capability('canEditFeaturedEdits'):
|
||||||
|
|
|
@ -127,8 +127,7 @@ class List(models.Model):
|
||||||
if value == 'private':
|
if value == 'private':
|
||||||
for user in self.subscribed_users.all():
|
for user in self.subscribed_users.all():
|
||||||
self.subscribed_users.remove(user)
|
self.subscribed_users.remove(user)
|
||||||
qs = Position.objects.filter(user=user,
|
qs = Position.objects.filter(user=user, list=self)
|
||||||
section='section', list=self)
|
|
||||||
if qs.count() > 1:
|
if qs.count() > 1:
|
||||||
pos = qs[0]
|
pos = qs[0]
|
||||||
pos.section = 'personal'
|
pos.section = 'personal'
|
||||||
|
@ -148,8 +147,7 @@ class List(models.Model):
|
||||||
Position.objects.filter(list=self).delete()
|
Position.objects.filter(list=self).delete()
|
||||||
pos, created = Position.objects.get_or_create(list=self,
|
pos, created = Position.objects.get_or_create(list=self,
|
||||||
user=self.user, section='personal')
|
user=self.user, section='personal')
|
||||||
qs = Position.objects.filter(user=self.user,
|
qs = Position.objects.filter(user=self.user, section='personal')
|
||||||
section='personal')
|
|
||||||
pos.position = qs.aggregate(Max('position'))['position__max'] + 1
|
pos.position = qs.aggregate(Max('position'))['position__max'] + 1
|
||||||
pos.save()
|
pos.save()
|
||||||
for u in self.subscribed_users.all():
|
for u in self.subscribed_users.all():
|
||||||
|
|
|
@ -369,6 +369,9 @@ def sortLists(request):
|
||||||
data = json.loads(request.POST['data'])
|
data = json.loads(request.POST['data'])
|
||||||
position = 0
|
position = 0
|
||||||
section = data['section']
|
section = data['section']
|
||||||
|
section = {
|
||||||
|
'favorite': 'public'
|
||||||
|
}.get(section,section)
|
||||||
#ids = list(set(data['ids']))
|
#ids = list(set(data['ids']))
|
||||||
ids = data['ids']
|
ids = data['ids']
|
||||||
if section == 'featured' and not request.user.get_profile().capability('canEditFeaturedLists'):
|
if section == 'featured' and not request.user.get_profile().capability('canEditFeaturedLists'):
|
||||||
|
|
|
@ -319,6 +319,9 @@ def sortTexts(request):
|
||||||
data = json.loads(request.POST['data'])
|
data = json.loads(request.POST['data'])
|
||||||
position = 0
|
position = 0
|
||||||
section = data['section']
|
section = data['section']
|
||||||
|
section = {
|
||||||
|
'favorite': 'public'
|
||||||
|
}.get(section,section)
|
||||||
#ids = list(set(data['ids']))
|
#ids = list(set(data['ids']))
|
||||||
ids = data['ids']
|
ids = data['ids']
|
||||||
if section == 'featured' and not request.user.get_profile().capability('canEditFeaturedTexts'):
|
if section == 'featured' and not request.user.get_profile().capability('canEditFeaturedTexts'):
|
||||||
|
|
Loading…
Reference in a new issue