start cleanup
Signed-off-by: Marc 'risson' Schmitt <marc.schmitt@risson.space>
This commit is contained in:
@ -57,18 +57,6 @@ class AuthentikEventsConfig(ManagedAppConfig):
|
||||
message=msg,
|
||||
).save()
|
||||
|
||||
@ManagedAppConfig.reconcile_tenant
|
||||
def prefill_tasks(self):
|
||||
"""Prefill tasks"""
|
||||
from authentik.events.models import SystemTask
|
||||
from authentik.events.system_tasks import _prefill_tasks
|
||||
|
||||
for task in _prefill_tasks:
|
||||
if SystemTask.objects.filter(name=task.name).exists():
|
||||
continue
|
||||
task.save()
|
||||
self.logger.debug("prefilled task", task_name=task.name)
|
||||
|
||||
@ManagedAppConfig.reconcile_tenant
|
||||
def run_scheduled_tasks(self):
|
||||
"""Run schedule tasks which are behind schedule (only applies
|
||||
|
@ -132,25 +132,3 @@ class SystemTask(TenantTask):
|
||||
|
||||
def run(self, *args, **kwargs):
|
||||
raise NotImplementedError
|
||||
|
||||
|
||||
def prefill_task(func):
|
||||
"""Ensure a task's details are always in cache, so it can always be triggered via API"""
|
||||
_prefill_tasks.append(
|
||||
DBSystemTask(
|
||||
name=func.__name__,
|
||||
description=func.__doc__,
|
||||
start_timestamp=now(),
|
||||
finish_timestamp=now(),
|
||||
status=TaskStatus.UNKNOWN,
|
||||
messages=sanitize_item([_("Task has not been run yet.")]),
|
||||
task_call_module=func.__module__,
|
||||
task_call_func=func.__name__,
|
||||
expiring=False,
|
||||
duration=0,
|
||||
)
|
||||
)
|
||||
return func
|
||||
|
||||
|
||||
_prefill_tasks = []
|
||||
|
@ -76,6 +76,7 @@ TENANT_APPS = [
|
||||
"authentik.admin",
|
||||
"authentik.api",
|
||||
"authentik.crypto",
|
||||
"authentik.events",
|
||||
"authentik.flows",
|
||||
"authentik.outposts",
|
||||
"authentik.policies.dummy",
|
||||
@ -123,7 +124,6 @@ TENANT_APPS = [
|
||||
"authentik.stages.user_login",
|
||||
"authentik.stages.user_logout",
|
||||
"authentik.stages.user_write",
|
||||
"authentik.tasks.schedules",
|
||||
"authentik.brands",
|
||||
"authentik.blueprints",
|
||||
"guardian",
|
||||
@ -500,9 +500,9 @@ try:
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
# Import events after other apps since it relies on tasks and other things from all apps
|
||||
# being imported for @prefill_task
|
||||
TENANT_APPS.append("authentik.events")
|
||||
# Import schedules after other apps since it relies on tasks and ScheduledModel being
|
||||
# registered for its startup.
|
||||
TENANT_APPS.append("authentik.tasks.schedules")
|
||||
|
||||
|
||||
# Load subapps's settings
|
||||
|
Reference in New Issue
Block a user