mirror of
https://github.com/pretix/pretix.git
synced 2026-05-05 15:14:04 +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
|
||||
|
||||
@@ -54,7 +54,7 @@
|
||||
{% trans "Sales estimate" %}
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
{% blocktrans trimmed with amount=estimate|floatformat:2 currency=request.event.currency %}
|
||||
{% blocktrans trimmed with amount=estimate|default:0|floatformat:2 currency=request.event.currency %}
|
||||
If you can make enough room at your event to fit all the persons on the waiting list in, you
|
||||
could sell tickets worth an additional <strong>{{ amount }} {{ currency }}</strong>.
|
||||
{% endblocktrans %}
|
||||
|
||||
@@ -32,7 +32,7 @@ class AutoAssign(EventPermissionRequiredMixin, AsyncAction, View):
|
||||
})
|
||||
|
||||
def post(self, request, *args, **kwargs):
|
||||
return self.do(self.request.event.id)
|
||||
return self.do(self.request.event.id, self.request.user.id)
|
||||
|
||||
|
||||
class WaitingListView(EventPermissionRequiredMixin, ListView):
|
||||
@@ -55,7 +55,7 @@ class WaitingListView(EventPermissionRequiredMixin, ListView):
|
||||
pk=request.POST.get('assign'), event=self.request.event,
|
||||
)
|
||||
try:
|
||||
wle.send_voucher()
|
||||
wle.send_voucher(user=request.user)
|
||||
except WaitingListException as e:
|
||||
messages.error(request, str(e))
|
||||
else:
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
<div class="form-group">
|
||||
<div class="col-md-9 col-md-offset-3">
|
||||
<div class="help-block">
|
||||
{% blocktrans trimmed %}
|
||||
If tickets become available again, we will inform the first persons on the waiting list. If we notify you, you'll have 48 hours time to buy a ticket until we assign it to the next person on the list.
|
||||
{% blocktrans trimmed with hours=event.settings.waiting_list_hours %}
|
||||
If tickets become available again, we will inform the first persons on the waiting list. If we notify you, you'll have {{ hours }} hours time to buy a ticket until we assign it to the next person on the list.
|
||||
{% endblocktrans %}
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary">
|
||||
|
||||
@@ -63,7 +63,7 @@ class WaitingView(FormView):
|
||||
else self.item_and_variation[0].check_quotas(count_waitinglist=False)
|
||||
)
|
||||
if availability[0] == 100:
|
||||
messages.error(self.request, _("You cannot add yourself to the waiting list as this product ist currently "
|
||||
messages.error(self.request, _("You cannot add yourself to the waiting list as this product is currently "
|
||||
"available."))
|
||||
return redirect(eventreverse(self.request.event, 'presale:event.index'))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user