fix _handle_checking_task error handling
This commit is contained in:
parent
6137a812b2
commit
de6c485a3f
1 changed files with 12 additions and 8 deletions
|
@ -1,6 +1,7 @@
|
||||||
from abc import ABC, abstractmethod
|
from abc import ABC, abstractmethod
|
||||||
|
|
||||||
from django.urls.base import reverse
|
from django.urls.base import reverse
|
||||||
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
from c3nav.editor.tasks import check_access_token, request_access_token
|
from c3nav.editor.tasks import check_access_token, request_access_token
|
||||||
from c3nav.mapdata.models import Package
|
from c3nav.mapdata.models import Package
|
||||||
|
@ -83,14 +84,17 @@ class Hoster(ABC):
|
||||||
Checks if the checking task is finished and if so handles its results.
|
Checks if the checking task is finished and if so handles its results.
|
||||||
"""
|
"""
|
||||||
if task.ready():
|
if task.ready():
|
||||||
task.maybe_reraise()
|
if task.failed():
|
||||||
state, content = task.result
|
session_data['state'] = 'logged_out'
|
||||||
if content:
|
session_data['error'] = _('Internal error.')
|
||||||
if state == 'logged_out':
|
else:
|
||||||
session_data['error'] = content
|
state, content = task.result
|
||||||
else:
|
if content:
|
||||||
session_data['access_token'] = content
|
if state == 'logged_out':
|
||||||
session_data['state'] = state
|
session_data['error'] = content
|
||||||
|
else:
|
||||||
|
session_data['access_token'] = content
|
||||||
|
session_data['state'] = state
|
||||||
session_data.pop('checking_progress_id')
|
session_data.pop('checking_progress_id')
|
||||||
|
|
||||||
def request_access_token(self, request, *args, **kwargs):
|
def request_access_token(self, request, *args, **kwargs):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue