diff --git a/aleksis/core/util/core_helpers.py b/aleksis/core/util/core_helpers.py index b3df40881e4403c8dc3cdfd97384704205c94f60..fcbf1b65f7b20aea5c2bf1d7b5098c922c12dd1f 100644 --- a/aleksis/core/util/core_helpers.py +++ b/aleksis/core/util/core_helpers.py @@ -195,6 +195,12 @@ def celery_optional(orig: Callable) -> Callable: If Celery is configured and available, it wraps the function in a Task and calls its delay method when invoked; if not, it leaves it untouched and it is executed synchronously. + + The wrapped function returns a tuple with either + the return value of the task's delay method and False + if the method has been executed asynchronously + or the return value of the executed method and True + if the method has been executed synchronously. """ if is_celery_enabled(): from ..celery import app # noqa @@ -203,10 +209,9 @@ def celery_optional(orig: Callable) -> Callable: def wrapped(*args, **kwargs): if is_celery_enabled(): - task.delay(*args, **kwargs) + return task.delay(*args, **kwargs), False else: - orig(*args, **kwargs) - return True + return orig(*args, **kwargs), True return wrapped diff --git a/aleksis/core/views.py b/aleksis/core/views.py index 0e29253faf9c1b7b3cfb7cc6db614af1dde365d2..016b49052f9272bd3743c78eb86689a0395194bd 100644 --- a/aleksis/core/views.py +++ b/aleksis/core/views.py @@ -728,7 +728,7 @@ class RunDataChecks(PermissionRequiredMixin, View): permission_required = "core.run_data_checks" def get(self, request: HttpRequest, *args, **kwargs) -> HttpResponse: - if not check_data(): + if not check_data()[1]: messages.success( request, _(