forked from 0x2620/pandora
make update_external async
This commit is contained in:
parent
93c6d8495b
commit
4d9761a32c
2 changed files with 15 additions and 10 deletions
|
@ -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)
|
||||||
|
|
|
@ -1123,6 +1123,7 @@ pandora.ui.infoView = function(data) {
|
||||||
pandora.api.updateExternalData({
|
pandora.api.updateExternalData({
|
||||||
id: ui.item
|
id: ui.item
|
||||||
}, function(result) {
|
}, function(result) {
|
||||||
|
(result.data.taskId ? pandora.wait : Ox.noop)(result.data.taskId, function(result) {
|
||||||
pandora.updateItemContext();
|
pandora.updateItemContext();
|
||||||
Ox.Request.clearCache();
|
Ox.Request.clearCache();
|
||||||
if (ui.item == item && ui.itemView == 'info') {
|
if (ui.item == item && ui.itemView == 'info') {
|
||||||
|
@ -1132,6 +1133,7 @@ pandora.ui.infoView = function(data) {
|
||||||
}
|
}
|
||||||
$options.enableItem('update');
|
$options.enableItem('update');
|
||||||
});
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
that.reload = function() {
|
that.reload = function() {
|
||||||
|
|
Loading…
Reference in a new issue