diff --git a/doc/development/api/general.rst b/doc/development/api/general.rst index a43b8eb58b..587718a801 100644 --- a/doc/development/api/general.rst +++ b/doc/development/api/general.rst @@ -22,6 +22,13 @@ There are multiple signals that will be sent out in the ordering cycle: .. automodule:: pretix.base.signals :members: validate_cart, validate_cart_addons, validate_order, order_fee_calculation, order_paid, order_placed, order_canceled, order_expired, order_modified, order_changed, order_approved, order_denied, order_fee_type_name, allow_ticket_download, order_split, order_gracefully_delete, invoice_line_text +Check-ins +""""""""" + +.. automodule:: pretix.base.signals + :members: checkin_created + + Frontend -------- diff --git a/src/pretix/base/services/checkin.py b/src/pretix/base/services/checkin.py index 875a5ff5c0..af834746ad 100644 --- a/src/pretix/base/services/checkin.py +++ b/src/pretix/base/services/checkin.py @@ -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) diff --git a/src/pretix/base/signals.py b/src/pretix/base/signals.py index 4108b1b81e..a2fab17a1c 100644 --- a/src/pretix/base/signals.py +++ b/src/pretix/base/signals.py @@ -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"] ) diff --git a/src/pretix/control/views/checkin.py b/src/pretix/control/views/checkin.py index a89610ac9c..57e1a628bd 100644 --- a/src/pretix/control/views/checkin.py +++ b/src/pretix/control/views/checkin.py @@ -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.'))