new file/path logic

This commit is contained in:
j 2012-09-11 14:42:33 +02:00
commit 6916792f95
2 changed files with 68 additions and 67 deletions

View file

@ -435,22 +435,23 @@ def getPath(request):
'''
change file / item link
param data {
ids: [hash of file]
id: [hash of file]
}
return {
status: {'code': int, 'text': string},
data: {
path: {
id: path
}
id: path
}
}
'''
data = json.loads(request.POST['data'])
response = json_response({'path': {}})
for f in models.File.objects.filter(oshash__in=data['ids']):
response['data']['path'][f.oshash] = f.path
ids = data['id']
if isinstance(ids, basestring):
ids = [ids]
for f in models.File.objects.filter(oshash__in=ids).values('path', 'oshash'):
response['data'][f['oshash']] = f['path']
return render_to_json_response(response)
actions.register(getPath, cache=True)