canEditFeaturedLists

This commit is contained in:
j 2011-11-10 23:14:31 +00:00
parent dac0738047
commit ee9135bf04

View file

@ -319,9 +319,7 @@ def editList(request):
pos.section = 'personal' pos.section = 'personal'
pos.save() pos.save()
elif value == 'featured': elif value == 'featured':
if not request.user.is_staff: if request.user.get_profile().capability('canEditFeaturedLists'):
value = list.status
else:
pos, created = models.Position.objects.get_or_create(list=list, user=request.user, pos, created = models.Position.objects.get_or_create(list=list, user=request.user,
section='featured') section='featured')
if created: if created:
@ -329,6 +327,8 @@ def editList(request):
pos.position = qs.aggregate(Max('position'))['position__max'] + 1 pos.position = qs.aggregate(Max('position'))['position__max'] + 1
pos.save() pos.save()
models.Position.objects.filter(list=list).exclude(id=pos.id).delete() models.Position.objects.filter(list=list).exclude(id=pos.id).delete()
else:
value = list.status
elif list.status == 'featured' and value == 'public': elif list.status == 'featured' and value == 'public':
models.Position.objects.filter(list=list).delete() models.Position.objects.filter(list=list).delete()
pos, created = models.Position.objects.get_or_create(list=list, pos, created = models.Position.objects.get_or_create(list=list,
@ -472,7 +472,7 @@ def sortLists(request):
section = data['section'] section = data['section']
#ids = list(set(data['ids'])) #ids = list(set(data['ids']))
ids = data['ids'] ids = data['ids']
if section == 'featured' and not request.user.is_staff: if section == 'featured' and not request.user.get_profile().capability('canEditFeaturedLists'):
response = json_response(status=403, text='not allowed') response = json_response(status=403, text='not allowed')
else: else:
user = request.user user = request.user