Waitinglist: Improve waitinglist and logging

This commit is contained in:
Raphael Michel
2017-02-10 11:19:22 +01:00
parent c03ac624fc
commit 8310597944
6 changed files with 16 additions and 12 deletions

View File

@@ -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()

View File

@@ -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