forked from 0x2620/pandora
move files
This commit is contained in:
parent
8bf2a89749
commit
4fd1cbdc0f
1 changed files with 31 additions and 0 deletions
|
@ -221,6 +221,37 @@ def taskStatus(request):
|
|||
return render_to_json_response(response)
|
||||
actions.register(taskStatus, cache=False)
|
||||
|
||||
@login_required_json
|
||||
def moveFiles(request):
|
||||
'''
|
||||
change file / item link
|
||||
param data {
|
||||
ids: hashes of files
|
||||
itemId: new itemId
|
||||
}
|
||||
|
||||
return {
|
||||
status: {'code': int, 'text': string},
|
||||
data: {
|
||||
}
|
||||
}
|
||||
'''
|
||||
#FIXME: permissions, need to be checked
|
||||
data = json.loads(request.POST['data'])
|
||||
for f in models.File.objects.filter(oshash__in=data['ids']):
|
||||
if f.item.id != data['itemId']:
|
||||
if len(data['itemId']) != 7:
|
||||
folder = f.instances.all()[0].folder
|
||||
item_info = utils.parse_path(folder)
|
||||
item = get_item(item_info)
|
||||
else:
|
||||
item = get_item({'imdbId': data['itemId']})
|
||||
f.item = item
|
||||
f.save()
|
||||
#FIXME: other things might need updating here
|
||||
response = json_response(text='updated')
|
||||
return render_to_json_response(response)
|
||||
actions.register(moveFiles, cache=False)
|
||||
|
||||
@login_required_json
|
||||
def editFile(request):
|
||||
|
|
Loading…
Reference in a new issue