mirror of
https://github.com/pretix/pretix.git
synced 2026-05-07 15:34:02 +00:00
Refactor quota calculation (#1668)
This commit is contained in:
@@ -44,6 +44,7 @@ from pretix.base.services.invoices import (
|
||||
from pretix.base.services.locking import LockTimeoutException, NoLockManager
|
||||
from pretix.base.services.mail import SendMailException
|
||||
from pretix.base.services.pricing import get_price
|
||||
from pretix.base.services.quotas import QuotaAvailability
|
||||
from pretix.base.services.tasks import ProfiledEventTask, ProfiledTask
|
||||
from pretix.base.signals import (
|
||||
allow_ticket_download, order_approved, order_canceled, order_changed,
|
||||
@@ -1391,10 +1392,13 @@ class OrderChangeManager:
|
||||
raise OrderError(self.error_messages['seat_subevent_mismatch'].format(seat=v['seat'].name))
|
||||
|
||||
def _check_quotas(self):
|
||||
qa = QuotaAvailability()
|
||||
qa.queue(*[k for k, v in self._quotadiff.items() if v > 0])
|
||||
qa.compute()
|
||||
for quota, diff in self._quotadiff.items():
|
||||
if diff <= 0:
|
||||
continue
|
||||
avail = quota.availability()
|
||||
avail = qa.results[quota]
|
||||
if avail[0] != Quota.AVAILABILITY_OK or (avail[1] is not None and avail[1] < diff):
|
||||
raise OrderError(self.error_messages['quota'].format(name=quota.name))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user