make update_external async

This commit is contained in:
j 2016-09-07 20:16:25 +02:00
parent 93c6d8495b
commit 4d9761a32c
2 changed files with 15 additions and 10 deletions

View file

@ -693,7 +693,9 @@ def updateExternalData(request, data):
takes { takes {
id: string // item id id: string // item id
} }
returns {} returns {
taskId: string, // taskId
}
notes: This can be used to populate metadata from a remote source, like notes: This can be used to populate metadata from a remote source, like
IMDb. IMDb.
see: getIds, getMetadata see: getIds, getMetadata
@ -701,7 +703,8 @@ def updateExternalData(request, data):
item = get_object_or_404_json(models.Item, public_id=data['id']) item = get_object_or_404_json(models.Item, public_id=data['id'])
response = json_response() response = json_response()
if item.editable(request.user): if item.editable(request.user):
item.update_external() t = tasks.update_external.delay(item.public_id)
response['taskId'] = t.task_id
else: else:
response = json_response(status=403, text='permission denied') response = json_response(status=403, text='permission denied')
return render_to_json_response(response) return render_to_json_response(response)

View file

@ -1123,14 +1123,16 @@ pandora.ui.infoView = function(data) {
pandora.api.updateExternalData({ pandora.api.updateExternalData({
id: ui.item id: ui.item
}, function(result) { }, function(result) {
pandora.updateItemContext(); (result.data.taskId ? pandora.wait : Ox.noop)(result.data.taskId, function(result) {
Ox.Request.clearCache(); pandora.updateItemContext();
if (ui.item == item && ui.itemView == 'info') { Ox.Request.clearCache();
pandora.$ui.contentPanel.replaceElement( if (ui.item == item && ui.itemView == 'info') {
1, pandora.$ui.item = pandora.ui.item() pandora.$ui.contentPanel.replaceElement(
); 1, pandora.$ui.item = pandora.ui.item()
} );
$options.enableItem('update'); }
$options.enableItem('update');
});
}); });
} }