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

View file

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