forked from 0x2620/pandora
move files
This commit is contained in:
parent
020a3e1808
commit
82336011d5
2 changed files with 28 additions and 17 deletions
|
@ -185,7 +185,7 @@ def firefogg_upload(request):
|
||||||
f.save()
|
f.save()
|
||||||
#FIXME: this fails badly if rabbitmq goes down
|
#FIXME: this fails badly if rabbitmq goes down
|
||||||
try:
|
try:
|
||||||
t = item.tasks.update_streams.delay((f.item.itemId))
|
t = item.tasks.update_streams.delay(f.item.itemId)
|
||||||
response['resultUrl'] = t.task_id
|
response['resultUrl'] = t.task_id
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
@ -237,20 +237,28 @@ def moveFiles(request):
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
'''
|
'''
|
||||||
#FIXME: permissions, need to be checked
|
|
||||||
data = json.loads(request.POST['data'])
|
data = json.loads(request.POST['data'])
|
||||||
|
if models.Item.objects.filter(itemId=data['itemId']).count() == 1:
|
||||||
|
item = models.Item.objects.get(itemId=data['itemId'])
|
||||||
|
else:
|
||||||
|
if len(data['itemId']) != 7:
|
||||||
|
del data['itemId']
|
||||||
|
item = get_item(data)
|
||||||
|
else:
|
||||||
|
item = get_item({'imdbId': data['itemId']})
|
||||||
|
changed = []
|
||||||
for f in models.File.objects.filter(oshash__in=data['ids']):
|
for f in models.File.objects.filter(oshash__in=data['ids']):
|
||||||
if f.item.id != data['itemId']:
|
if f.item.id != data['itemId'] and f.editable(request.user):
|
||||||
if len(data['itemId']) != 7:
|
if f.item.itemId not in changed:
|
||||||
folder = f.instances.all()[0].folder
|
changed.append(f.item.itemId)
|
||||||
item_info = utils.parse_path(folder)
|
if item.itemId not in changed:
|
||||||
item = get_item(item_info)
|
changed.append(item.itemId)
|
||||||
else:
|
|
||||||
item = get_item({'imdbId': data['itemId']})
|
|
||||||
f.item = item
|
f.item = item
|
||||||
f.save()
|
f.save()
|
||||||
#FIXME: other things might need updating here
|
for itemId in changed:
|
||||||
|
item.tasks.update_streams.delay(itemId)
|
||||||
response = json_response(text='updated')
|
response = json_response(text='updated')
|
||||||
|
response['data']['itemId'] = item.itemId
|
||||||
return render_to_json_response(response)
|
return render_to_json_response(response)
|
||||||
actions.register(moveFiles, cache=False)
|
actions.register(moveFiles, cache=False)
|
||||||
|
|
||||||
|
|
|
@ -287,16 +287,19 @@ Ox.FilesView = function(options, self) {
|
||||||
.css({margin: '0 4px 4px 4px'})
|
.css({margin: '0 4px 4px 4px'})
|
||||||
.bindEvent({
|
.bindEvent({
|
||||||
click: function() {
|
click: function() {
|
||||||
var itemId = self.$idInput.value();
|
var data = {
|
||||||
Ox.Request.clearCache(); // fixme: remove
|
|
||||||
pandora.api.moveFiles({
|
|
||||||
ids: self.selected,
|
ids: self.selected,
|
||||||
itemId: itemId
|
itemId: self.$idInput.value()
|
||||||
}, function() {
|
};
|
||||||
|
['title', 'director', 'year'].forEach(function(key) {
|
||||||
|
data[key] = self['$' + key + 'Input'].value();
|
||||||
|
});
|
||||||
|
Ox.Request.clearCache(); // fixme: remove
|
||||||
|
pandora.api.moveFiles(data, function(result) {
|
||||||
if(self.$checkbox.value()) {
|
if(self.$checkbox.value()) {
|
||||||
pandora.URL.set(itemId);
|
pandora.URL.set(result.data.itemId);
|
||||||
} else {
|
} else {
|
||||||
Ox.print('moved', self.selected, itemId);
|
Ox.print('moved', self.selected, result.data.itemId);
|
||||||
self.$filesList.reloadList();
|
self.$filesList.reloadList();
|
||||||
self.$instancesList.reloadList();
|
self.$instancesList.reloadList();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue