Waiting list: Cronjob should skip events with no waiting entries (#2066)

* Waiting list: Cronjob should skip events with no waiting entries

* isort
This commit is contained in:
Raphael Michel
2021-05-12 21:05:30 +02:00
committed by GitHub
parent 5b0d3c9ff1
commit bd7a38ea3f

View File

@@ -22,7 +22,7 @@
import sys
from datetime import timedelta
from django.db.models import Q
from django.db.models import Exists, OuterRef, Q
from django.dispatch import receiver
from django.utils.timezone import now
from django_scopes import scopes_disabled
@@ -101,6 +101,12 @@ def assign_automatically(event: Event, user_id: int=None, subevent_id: int=None)
@scopes_disabled()
def process_waitinglist(sender, **kwargs):
qs = Event.objects.filter(
Exists(
WaitingListEntry.objects.filter(
event_id=OuterRef('pk'),
voucher__isnull=True,
)
),
live=True
).exclude(
Q(date_to__isnull=True) | Q(date_to__lt=now() - timedelta(days=14)),