forked from 0x2620/pandora
fix select all
This commit is contained in:
parent
92239d2bc2
commit
80f90420db
3 changed files with 30 additions and 10 deletions
|
@ -75,8 +75,11 @@ class List(models.Model):
|
|||
l.item = item
|
||||
l.save()
|
||||
|
||||
def remove(self, item):
|
||||
ListItem.objects.all().filter(item=item, list=self).delete()
|
||||
def remove(self, item=None, items=None):
|
||||
if item:
|
||||
ListItem.objects.all().filter(item=item, list=self).delete()
|
||||
if items:
|
||||
ListItem.objects.all().filter(item__itemId__in=items, list=self).delete()
|
||||
|
||||
def __unicode__(self):
|
||||
return self.get_id()
|
||||
|
|
|
@ -4,6 +4,7 @@ from __future__ import division
|
|||
import os
|
||||
|
||||
from django.db.models import Max, Sum
|
||||
from django.db import transaction
|
||||
from django.http import HttpResponseForbidden, Http404
|
||||
from django.conf import settings
|
||||
from ox.utils import json
|
||||
|
@ -139,8 +140,9 @@ def addListItems(request):
|
|||
list = get_list_or_404_json(data['list'])
|
||||
if 'items' in data:
|
||||
if list.editable(request.user):
|
||||
for item in Item.objects.filter(itemId__in=data['items']):
|
||||
list.add(item)
|
||||
with transaction.commit_on_success():
|
||||
for item in Item.objects.filter(itemId__in=data['items']):
|
||||
list.add(item)
|
||||
response = json_response(status=200, text='items added')
|
||||
else:
|
||||
response = json_response(status=403, text='not allowed')
|
||||
|
@ -170,8 +172,7 @@ def removeListItems(request):
|
|||
list = get_list_or_404_json(data['list'])
|
||||
if 'items' in data:
|
||||
if list.editable(request.user):
|
||||
for item in list.items.filter(itemId__in=data['items']):
|
||||
list.remove(item)
|
||||
list.remove(items=data['items'])
|
||||
response = json_response(status=200, text='items removed')
|
||||
else:
|
||||
response = json_response(status=403, text='not allowed')
|
||||
|
|
|
@ -497,7 +497,7 @@ pandora.ui.list = function() {
|
|||
}, pandora.reloadList);
|
||||
},
|
||||
select: function(data) {
|
||||
var $still, $timeline;
|
||||
var query;
|
||||
pandora.UI.set('listSelection', data.ids);
|
||||
if (data.ids.length) {
|
||||
pandora.$ui.mainMenu.enableItem('copy');
|
||||
|
@ -507,8 +507,8 @@ pandora.ui.list = function() {
|
|||
pandora.$ui.mainMenu.disableItem('openmovie');
|
||||
}
|
||||
pandora.$ui.leftPanel.replaceElement(2, pandora.$ui.info = pandora.ui.info());
|
||||
pandora.api.find({
|
||||
query: {
|
||||
if (Ox.isUndefined(data.rest)) {
|
||||
query = {
|
||||
conditions: data.ids.map(function(id) {
|
||||
return {
|
||||
key: 'id',
|
||||
|
@ -517,7 +517,23 @@ pandora.ui.list = function() {
|
|||
}
|
||||
}),
|
||||
operator: '|'
|
||||
}
|
||||
};
|
||||
} else {
|
||||
query = {
|
||||
conditions: Ox.merge([
|
||||
pandora.user.ui.find
|
||||
], data.rest.map(function(id) {
|
||||
return {
|
||||
key: 'id',
|
||||
value: id,
|
||||
operator: '!='
|
||||
};
|
||||
})),
|
||||
operator: '&'
|
||||
};
|
||||
}
|
||||
pandora.api.find({
|
||||
query: query
|
||||
}, function(result) {
|
||||
pandora.$ui.selected.html(pandora.ui.status('selected', result.data));
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue