support batch edit

This commit is contained in:
j 2016-01-05 14:01:38 +05:30
parent 9aff4766e5
commit cd6d09c86c

View file

@ -121,9 +121,15 @@ def edit(data):
... ...
} }
setting identifier or base metadata is possible not both at the same time setting identifier or base metadata is possible not both at the same time
id can be one id or list of ids
''' '''
response = {} response = {}
item = models.Item.get(data['id']) ids = data['id']
if isinstance(ids, str):
ids = [ids]
for id in ids:
item = models.Item.get(id)
if item and item.json()['mediastate'] == 'available': if item and item.json()['mediastate'] == 'available':
if 'primaryid' in data: if 'primaryid' in data:
if data['primaryid']: if data['primaryid']:
@ -138,7 +144,7 @@ def edit(data):
item.edit_metadata(data) item.edit_metadata(data)
response = item.json() response = item.json()
else: else:
logger.info('can only edit available items') logger.info('can only edit available items %s', id)
return response return response
actions.register(edit, cache=False) actions.register(edit, cache=False)