better results for batch edit

This commit is contained in:
j 2016-01-05 15:57:35 +05:30
parent 4ed4926bd8
commit ef9b13b310

View file

@ -128,6 +128,7 @@ def edit(data):
ids = data['id']
if isinstance(ids, str):
ids = [ids]
edited = []
for id in ids:
item = models.Item.get(id)
if item and item.json()['mediastate'] == 'available':
@ -143,8 +144,12 @@ def edit(data):
else:
item.edit_metadata(data)
response = item.json()
edited.append(id)
else:
logger.info('can only edit available items %s', id)
if len(ids) > 1:
response = data
response['id'] = edited
return response
actions.register(edit, cache=False)