forked from CGM_Public/pretix_original
Long-running async tasks: Expose running state
This commit is contained in:
@@ -77,7 +77,8 @@ class AsyncAction:
|
|||||||
data = self._ajax_response_data()
|
data = self._ajax_response_data()
|
||||||
data.update({
|
data.update({
|
||||||
'async_id': res.id,
|
'async_id': res.id,
|
||||||
'ready': ready
|
'ready': ready,
|
||||||
|
'started': False,
|
||||||
})
|
})
|
||||||
if ready:
|
if ready:
|
||||||
if res.successful() and not isinstance(res.info, Exception):
|
if res.successful() and not isinstance(res.info, Exception):
|
||||||
@@ -102,8 +103,13 @@ class AsyncAction:
|
|||||||
})
|
})
|
||||||
elif res.state == 'PROGRESS':
|
elif res.state == 'PROGRESS':
|
||||||
data.update({
|
data.update({
|
||||||
|
'started': True,
|
||||||
'percentage': res.result.get('value', 0)
|
'percentage': res.result.get('value', 0)
|
||||||
})
|
})
|
||||||
|
elif res.state == 'STARTED':
|
||||||
|
data.update({
|
||||||
|
'started': True,
|
||||||
|
})
|
||||||
return data
|
return data
|
||||||
|
|
||||||
def get_result(self, request):
|
def get_result(self, request):
|
||||||
|
|||||||
@@ -38,11 +38,17 @@ function async_task_check_callback(data, jqXHR, status) {
|
|||||||
async_task_timeout = window.setTimeout(async_task_check, 250);
|
async_task_timeout = window.setTimeout(async_task_check, 250);
|
||||||
|
|
||||||
if (async_task_is_long) {
|
if (async_task_is_long) {
|
||||||
$("#loadingmodal p.status").text(gettext(
|
if (data.started) {
|
||||||
'Your request has been queued on the server and will now be ' +
|
$("#loadingmodal p.status").text(gettext(
|
||||||
'processed. Depending on the size of your event, this might take up to a ' +
|
'Your request is currently being processed. Depending on the size of your event, this might take up to ' +
|
||||||
'few minutes.'
|
'a few minutes.'
|
||||||
));
|
));
|
||||||
|
} else {
|
||||||
|
$("#loadingmodal p.status").text(gettext(
|
||||||
|
'Your request has been queued on the server and will soon be ' +
|
||||||
|
'processed.'
|
||||||
|
));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
$("#loadingmodal p.status").text(gettext(
|
$("#loadingmodal p.status").text(gettext(
|
||||||
'Your request arrived on the server but we still wait for it to be ' +
|
'Your request arrived on the server but we still wait for it to be ' +
|
||||||
@@ -105,11 +111,17 @@ function async_task_callback(data, jqXHR, status) {
|
|||||||
async_task_timeout = window.setTimeout(async_task_check, 100);
|
async_task_timeout = window.setTimeout(async_task_check, 100);
|
||||||
|
|
||||||
if (async_task_is_long) {
|
if (async_task_is_long) {
|
||||||
$("#loadingmodal p.status").text(gettext(
|
if (data.started) {
|
||||||
'Your request has been queued on the server and will now be ' +
|
$("#loadingmodal p.status").text(gettext(
|
||||||
'processed. Depending on the size of your event, this might take up to a ' +
|
'Your request is currently being processed. Depending on the size of your event, this might take up to ' +
|
||||||
'few minutes.'
|
'a few minutes.'
|
||||||
));
|
));
|
||||||
|
} else {
|
||||||
|
$("#loadingmodal p.status").text(gettext(
|
||||||
|
'Your request has been queued on the server and will soon be ' +
|
||||||
|
'processed.'
|
||||||
|
));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
$("#loadingmodal p.status").text(gettext(
|
$("#loadingmodal p.status").text(gettext(
|
||||||
'Your request arrived on the server but we still wait for it to be ' +
|
'Your request arrived on the server but we still wait for it to be ' +
|
||||||
|
|||||||
Reference in New Issue
Block a user