mirror of
https://github.com/pretix/pretix.git
synced 2026-05-06 15:24:02 +00:00
Fix waiting list processing with infinite-size quotas
This commit is contained in:
@@ -87,7 +87,7 @@ class WaitingListEntry(LoggedModel):
|
||||
if self.variation
|
||||
else self.item.check_quotas(count_waitinglist=False, subevent=self.subevent, _cache=quota_cache)
|
||||
)
|
||||
if availability[1] < 1:
|
||||
if availability[1] is None or availability[1] < 1:
|
||||
raise WaitingListException(_('This product is currently not available.'))
|
||||
if self.voucher:
|
||||
raise WaitingListException(_('A voucher has already been sent to this person.'))
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import sys
|
||||
|
||||
from django.dispatch import receiver
|
||||
|
||||
from pretix.base.models import Event, User, WaitingListEntry
|
||||
@@ -41,7 +43,7 @@ def assign_automatically(event_id: int, user_id: int=None, subevent_id: int=None
|
||||
if wle.variation
|
||||
else wle.item.check_quotas(count_waitinglist=False, _cache=quota_cache, subevent=wle.subevent)
|
||||
)
|
||||
if availability[1] > 0:
|
||||
if availability[1] is None or availability[1] > 0:
|
||||
try:
|
||||
wle.send_voucher(quota_cache, user=user)
|
||||
sent += 1
|
||||
@@ -52,7 +54,7 @@ def assign_automatically(event_id: int, user_id: int=None, subevent_id: int=None
|
||||
for q in quotas:
|
||||
quota_cache[q.pk] = (
|
||||
quota_cache[q.pk][0] if quota_cache[q.pk][0] > 1 else 0,
|
||||
quota_cache[q.pk][1] - 1
|
||||
quota_cache[q.pk][1] - 1 if quota_cache[q.pk][1] is not None else sys.maxsize
|
||||
)
|
||||
else:
|
||||
gone.add((wle.item, wle.variation))
|
||||
|
||||
@@ -99,6 +99,22 @@ class WaitingListTestCase(TestCase):
|
||||
'foo7@bar.com', 'foo8@bar.com', 'foo9@bar.com'
|
||||
]
|
||||
|
||||
def test_send_auto_quota_infinite(self):
|
||||
self.quota.variations.add(self.var1)
|
||||
self.quota.size = None
|
||||
self.quota.save()
|
||||
for i in range(10):
|
||||
WaitingListEntry.objects.create(
|
||||
event=self.event, item=self.item2, variation=self.var1, email='foo{}@bar.com'.format(i)
|
||||
)
|
||||
WaitingListEntry.objects.create(
|
||||
event=self.event, item=self.item1, email='bar{}@bar.com'.format(i)
|
||||
)
|
||||
|
||||
assign_automatically.apply(args=(self.event.pk,))
|
||||
assert WaitingListEntry.objects.filter(voucher__isnull=True).count() == 10
|
||||
assert Voucher.objects.count() == 10
|
||||
|
||||
def test_send_periodic(self):
|
||||
self.event.settings.set('waiting_list_enabled', True)
|
||||
self.event.settings.set('waiting_list_auto', True)
|
||||
|
||||
Reference in New Issue
Block a user