Send signal on checkin (#1546)

* Send signal when orderposition is checked in

* Add position_checked_in signal to documentation

* Rename signal to checkin_created

* Update general.rst

* Update signals.py

Co-authored-by: Raphael Michel <mail@raphaelmichel.de>
This commit is contained in:
pajowu
2020-02-04 18:26:35 +01:00
committed by GitHub
parent 22dfa0e61d
commit 6e88054af7
4 changed files with 24 additions and 2 deletions

View File

@@ -7,7 +7,7 @@ from django.utils.translation import ugettext as _
from pretix.base.models import (
Checkin, CheckinList, Order, OrderPosition, Question, QuestionOption,
)
from pretix.base.signals import order_placed
from pretix.base.signals import checkin_created, order_placed
class CheckInError(Exception):
@@ -143,6 +143,7 @@ def perform_checkin(op: OrderPosition, clist: CheckinList, given_answers: dict,
'datetime': dt,
'list': clist.pk
}, user=user, auth=auth)
checkin_created.send(op.order.event, checkin=ci)
else:
if not force:
raise CheckInError(
@@ -171,4 +172,5 @@ def order_placed(sender, **kwargs):
for op in order.positions.all():
for cl in cls:
if cl.all_products or op.item_id in {i.pk for i in cl.limit_products.all()}:
Checkin.objects.create(position=op, list=cl, auto_checked_in=True)
ci = Checkin.objects.create(position=op, list=cl, auto_checked_in=True)
checkin_created.send(event, checkin=ci)

View File

@@ -405,6 +405,17 @@ the deletion of the order.
As with all event-plugin signals, the ``sender`` keyword argument will contain the event.
"""
checkin_created = EventPluginSignal(
providing_args=["checkin"],
)
"""
This signal is sent out every time a check-in is created (i.e. an order position is marked as
checked in). It is not send if the position was already checked in and is force-checked-in a second time.
The check-in object is given as the first argument
As with all event-plugin signals, the ``sender`` keyword argument will contain the event.
"""
logentry_display = EventPluginSignal(
providing_args=["logentry"]
)

View File

@@ -14,6 +14,7 @@ from pytz import UTC
from pretix.base.channels import get_all_sales_channels
from pretix.base.models import Checkin, Order, OrderPosition
from pretix.base.models.checkin import CheckinList
from pretix.base.signals import checkin_created
from pretix.control.forms.checkin import CheckinListForm
from pretix.control.forms.filter import CheckInFilterForm
from pretix.control.permissions import EventPermissionRequiredMixin
@@ -124,6 +125,7 @@ class CheckInListShow(EventPermissionRequiredMixin, PaginationMixin, ListView):
'list': self.list.pk,
'web': True
}, user=request.user)
checkin_created.send(op.order.event, checkin=ci)
messages.success(request, _('The selected tickets have been marked as checked in.'))