forked from CGM_Public/pretix_original
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:
@@ -22,6 +22,13 @@ There are multiple signals that will be sent out in the ordering cycle:
|
|||||||
.. automodule:: pretix.base.signals
|
.. 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
|
: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
|
Frontend
|
||||||
--------
|
--------
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ from django.utils.translation import ugettext as _
|
|||||||
from pretix.base.models import (
|
from pretix.base.models import (
|
||||||
Checkin, CheckinList, Order, OrderPosition, Question, QuestionOption,
|
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):
|
class CheckInError(Exception):
|
||||||
@@ -143,6 +143,7 @@ def perform_checkin(op: OrderPosition, clist: CheckinList, given_answers: dict,
|
|||||||
'datetime': dt,
|
'datetime': dt,
|
||||||
'list': clist.pk
|
'list': clist.pk
|
||||||
}, user=user, auth=auth)
|
}, user=user, auth=auth)
|
||||||
|
checkin_created.send(op.order.event, checkin=ci)
|
||||||
else:
|
else:
|
||||||
if not force:
|
if not force:
|
||||||
raise CheckInError(
|
raise CheckInError(
|
||||||
@@ -171,4 +172,5 @@ def order_placed(sender, **kwargs):
|
|||||||
for op in order.positions.all():
|
for op in order.positions.all():
|
||||||
for cl in cls:
|
for cl in cls:
|
||||||
if cl.all_products or op.item_id in {i.pk for i in cl.limit_products.all()}:
|
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)
|
||||||
|
|||||||
@@ -405,6 +405,17 @@ the deletion of the order.
|
|||||||
As with all event-plugin signals, the ``sender`` keyword argument will contain the event.
|
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(
|
logentry_display = EventPluginSignal(
|
||||||
providing_args=["logentry"]
|
providing_args=["logentry"]
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ from pytz import UTC
|
|||||||
from pretix.base.channels import get_all_sales_channels
|
from pretix.base.channels import get_all_sales_channels
|
||||||
from pretix.base.models import Checkin, Order, OrderPosition
|
from pretix.base.models import Checkin, Order, OrderPosition
|
||||||
from pretix.base.models.checkin import CheckinList
|
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.checkin import CheckinListForm
|
||||||
from pretix.control.forms.filter import CheckInFilterForm
|
from pretix.control.forms.filter import CheckInFilterForm
|
||||||
from pretix.control.permissions import EventPermissionRequiredMixin
|
from pretix.control.permissions import EventPermissionRequiredMixin
|
||||||
@@ -124,6 +125,7 @@ class CheckInListShow(EventPermissionRequiredMixin, PaginationMixin, ListView):
|
|||||||
'list': self.list.pk,
|
'list': self.list.pk,
|
||||||
'web': True
|
'web': True
|
||||||
}, user=request.user)
|
}, user=request.user)
|
||||||
|
checkin_created.send(op.order.event, checkin=ci)
|
||||||
|
|
||||||
messages.success(request, _('The selected tickets have been marked as checked in.'))
|
messages.success(request, _('The selected tickets have been marked as checked in.'))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user