Add warning to backend if cronjob is not running (#4550)

This commit is contained in:
Raphael Michel
2024-10-24 22:50:34 +02:00
committed by GitHub
parent 2b6f82502e
commit 22e9a6eb92
3 changed files with 14 additions and 0 deletions

View File

@@ -36,6 +36,7 @@ import time
import traceback
from django.conf import settings
from django.core.cache import cache
from django.core.management.base import BaseCommand
from django.dispatch.dispatcher import NO_RECEIVERS
@@ -57,6 +58,8 @@ class Command(BaseCommand):
def handle(self, *args, **options):
verbosity = int(options['verbosity'])
cache.set("pretix_runperiodic_executed", True, 3600 * 12)
if not periodic_task.receivers or periodic_task.sender_receivers_cache.get(self) is NO_RECEIVERS:
return

View File

@@ -36,6 +36,7 @@ import sys
from importlib import import_module
from django.conf import settings
from django.core.cache import cache
from django.db.models import Q
from django.urls import Resolver404, get_script_prefix, resolve
from django.utils.translation import get_language
@@ -152,6 +153,8 @@ def _default_context(request):
ctx['warning_update_available'] = True
if not gs.settings.update_check_ack and 'runserver' not in sys.argv:
ctx['warning_update_check_active'] = True
if not cache.get('pretix_runperiodic_executed') and not settings.DEBUG:
ctx['warning_cronjob'] = True
ctx['ie_deprecation_warning'] = 'MSIE' in request.headers.get('User-Agent', '') or 'Trident/' in request.headers.get('User-Agent', '')

View File

@@ -421,6 +421,14 @@
</a>
</div>
{% endif %}
{% if warning_cronjob %}
<div class="alert alert-warning">
{% blocktrans trimmed %}
The cronjob component of pretix was not executed in the last hours. Please check that
you have completed all installation steps and your cronjob is executed correctly.
{% endblocktrans %}
</div>
{% endif %}
{% if debug_warning %}
<div class="alert alert-danger">