mirror of
https://github.com/pretix/pretix.git
synced 2026-05-04 15:04:03 +00:00
Waitinglist: Improve waitinglist and logging
This commit is contained in:
@@ -75,7 +75,7 @@ class WaitingListEntry(LoggedModel):
|
||||
if not self.variation and self.item.has_variations:
|
||||
raise ValidationError(_('Please select a specific variation of this product.'))
|
||||
|
||||
def send_voucher(self, quota_cache=None):
|
||||
def send_voucher(self, quota_cache=None, user=None):
|
||||
availability = (
|
||||
self.variation.check_quotas(count_waitinglist=False, _cache=quota_cache)
|
||||
if self.variation
|
||||
@@ -108,8 +108,8 @@ class WaitingListEntry(LoggedModel):
|
||||
'max_usages': 1,
|
||||
'email': self.email,
|
||||
'waitinglistentry': self.pk
|
||||
})
|
||||
self.log_action('pretix.waitinglist.voucher')
|
||||
}, user=user)
|
||||
self.log_action('pretix.waitinglist.voucher', user=user)
|
||||
self.voucher = v
|
||||
self.save()
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
from django.dispatch import receiver
|
||||
|
||||
from pretix.base.models import Event, WaitingListEntry
|
||||
from pretix.base.models import Event, User, WaitingListEntry
|
||||
from pretix.base.models.waitinglist import WaitingListException
|
||||
from pretix.base.services.async import ProfiledTask
|
||||
from pretix.base.signals import periodic_task
|
||||
@@ -8,8 +8,12 @@ from pretix.celery_app import app
|
||||
|
||||
|
||||
@app.task(base=ProfiledTask)
|
||||
def assign_automatically(event_id: int):
|
||||
def assign_automatically(event_id: int, user_id: int = None):
|
||||
event = Event.objects.get(id=event_id)
|
||||
if user_id:
|
||||
user = User.objects.get(id=user_id)
|
||||
else:
|
||||
user = None
|
||||
|
||||
quota_cache = {}
|
||||
gone = set()
|
||||
@@ -31,7 +35,7 @@ def assign_automatically(event_id: int):
|
||||
)
|
||||
if availability[1] > 0:
|
||||
try:
|
||||
wle.send_voucher(quota_cache)
|
||||
wle.send_voucher(quota_cache, user=user)
|
||||
sent += 1
|
||||
except WaitingListException: # noqa
|
||||
continue
|
||||
|
||||
Reference in New Issue
Block a user