enable/disable files

This commit is contained in:
j 2011-10-23 13:57:52 +02:00
parent 48f078db5f
commit 5beba72d39
5 changed files with 34 additions and 12 deletions

View file

@ -65,9 +65,10 @@ def update_static():
pandora_json = os.path.join(settings.STATIC_ROOT, 'json/pandora.json') pandora_json = os.path.join(settings.STATIC_ROOT, 'json/pandora.json')
for root, folders, files in os.walk(os.path.join(settings.STATIC_ROOT, 'js/pandora')): for root, folders, files in os.walk(os.path.join(settings.STATIC_ROOT, 'js/pandora')):
for f in files: for f in files:
js.append(os.path.join(root, f)[len(settings.STATIC_ROOT)+1:]) if f.endswith('.js'):
with open(os.path.join(root, f)) as j: js.append(os.path.join(root, f)[len(settings.STATIC_ROOT)+1:])
data += j.read() + '\n' with open(os.path.join(root, f)) as j:
data += j.read() + '\n'
print 'write', pandora_js print 'write', pandora_js
with open(pandora_js, 'w') as f: with open(pandora_js, 'w') as f:

View file

@ -305,9 +305,12 @@ def editFile(request):
update = False update = False
#FIXME: should all instances be ignored? #FIXME: should all instances be ignored?
if 'ignore' in data: if 'ignore' in data:
f.instances.update(ignore=True) f.auto = True
f.instances.update(ignore=data['ignore'])
f.save()
#FIXME: is this to slow to run sync? #FIXME: is this to slow to run sync?
f.item.update_selected() f.item.update_selected()
f.item.update_wanted()
for key in ('part', 'language'): for key in ('part', 'language'):
if key in data: if key in data:
setattr(f, key, data[key]) setattr(f, key, data[key])

View file

@ -658,7 +658,7 @@ class Item(models.Model):
s.volume = None s.volume = None
s.parts = 0 s.parts = 0
if 'color' in self.data: if 'color' in self.data and len(self.data['color']) == 3:
s.hue, s.saturation, s.lightness = self.data['color'] s.hue, s.saturation, s.lightness = self.data['color']
else: else:
s.hue = None s.hue = None
@ -878,7 +878,7 @@ class Item(models.Model):
if settings.CONFIG['video']['download']: if settings.CONFIG['video']['download']:
self.make_torrent() self.make_torrent()
self.load_subtitles() self.load_subtitles()
self.rendered = streams != [] self.rendered = streams.count() > 0
self.save() self.save()
def delete_poster(self): def delete_poster(self):

View file

@ -46,6 +46,9 @@ pandora.ui.filesView = function(options, self) {
self.$filesList = Ox.TextList({ self.$filesList = Ox.TextList({
columns: [ columns: [
{ {
clickable: function(data) {
return true;
},
format: function(value, data) { format: function(value, data) {
Ox.print('File', value, data.wanted, data); Ox.print('File', value, data.wanted, data);
return $('<img>') return $('<img>')
@ -65,6 +68,11 @@ pandora.ui.filesView = function(options, self) {
title: $('<img>').attr({ title: $('<img>').attr({
src: Ox.UI.getImageURL('symbolCheck') src: Ox.UI.getImageURL('symbolCheck')
}), }),
tooltip: function (data) {
return data.instances.filter(function(i) {return i.ignore; }).length > 0
? 'Use this file'
: 'Dont use this file';
},
visible: true, visible: true,
width: 16 width: 16
}, },
@ -166,8 +174,21 @@ pandora.ui.filesView = function(options, self) {
sort: [{key: 'path', operator: '+'}] sort: [{key: 'path', operator: '+'}]
}) })
.bindEvent({ .bindEvent({
click: function(data) {
if (data.key == 'selected') {
var ignored = self.$filesList.value(data.id, 'instances')
.filter(function(i) {return i.ignore; }).length > 0;
pandora.api.editFile({
id: data.id,
ignore: !ignored
}, function(result) {
Ox.Request.clearCache();
self.$filesList.reloadList();
});
}
},
open: openFiles, open: openFiles,
select: selectFiles select: selectFiles,
}); });
self.$instancesList = Ox.TextList({ self.$instancesList = Ox.TextList({

View file

@ -218,15 +218,12 @@ pandora.ui.folderList = function(id) {
} }
]; ];
items = function(data, callback) { items = function(data, callback) {
var volumes = pandora.user.volumes || [ var volumes = pandora.user.volumes || [];
{"name": "Movies A-M", "path": "/Volumes/Movies A-M", "items": 1234},
{"name": "Movies N-Z", "path": "/Volumes/Movies N-Z", "items": 987}
];
if (!data.keys) { if (!data.keys) {
data = {items: volumes.length}; data = {items: volumes.length};
} else { } else {
data = {items: volumes.map(function(volume) { data = {items: volumes.map(function(volume) {
return Ox.extend({id: volume.name, user: pandora.user.username, mounted: volume.name == 'Movies A-M'}, volume); return Ox.extend({id: volume.name, user: pandora.user.username}, volume);
})}; })};
} }
// fixme: ridiculous (we're binding to init too late) // fixme: ridiculous (we're binding to init too late)