diff --git a/src/pretix/api/views/checkin.py b/src/pretix/api/views/checkin.py index 325f5017f..afd9ce9ba 100644 --- a/src/pretix/api/views/checkin.py +++ b/src/pretix/api/views/checkin.py @@ -152,6 +152,11 @@ class CheckinListViewSet(viewsets.ModelViewSet): @action(detail=True, methods=['POST'], url_name='failed_checkins') @transaction.atomic() def failed_checkins(self, *args, **kwargs): + additional_log_data = {} + if 'debug_data' in self.request.data: + # Intentionally undocumented, might be removed again + additional_log_data['debug_data'] = self.request.data.pop('debug_data') + serializer = FailedCheckinSerializer( data=self.request.data, context={'event': self.request.event} @@ -194,14 +199,16 @@ class CheckinListViewSet(viewsets.ModelViewSet): 'reason_explanation': c.error_explanation, 'datetime': c.datetime, 'type': c.type, - 'list': c.list.pk + 'list': c.list.pk, + **additional_log_data, }, user=self.request.user, auth=self.request.auth) else: self.request.event.log_action('pretix.event.checkin.unknown', data={ 'datetime': c.datetime, 'type': c.type, 'list': c.list.pk, - 'barcode': c.raw_barcode + 'barcode': c.raw_barcode, + **additional_log_data, }, user=self.request.user, auth=self.request.auth) return Response(serializer.data, status=201) diff --git a/src/tests/api/test_checkin.py b/src/tests/api/test_checkin.py index 1a4bbff59..ef79d2196 100644 --- a/src/tests/api/test_checkin.py +++ b/src/tests/api/test_checkin.py @@ -35,7 +35,7 @@ from tests.const import SAMPLE_PNG from pretix.api.serializers.item import QuestionSerializer from pretix.base.models import ( - Checkin, CheckinList, InvoiceAddress, Order, OrderPosition, + Checkin, CheckinList, InvoiceAddress, Order, OrderPosition, LogEntry, ) @@ -1128,11 +1128,17 @@ def test_store_failed(token_client, organizer, clist, event, order): ), { 'raw_barcode': '123456', 'nonce': '4321', - 'error_reason': 'invalid' + 'error_reason': 'invalid', + 'debug_data': {'foo': 'bar'}, }, format='json') assert resp.status_code == 201 with scopes_disabled(): assert Checkin.all.filter(successful=False).exists() + for le in LogEntry.objects.filter(): + print(le.parsed_data) + assert LogEntry.objects.filter(action_type='pretix.event.checkin.unknown').first().parsed_data['debug_data'] == { + 'foo': 'bar' + } resp = token_client.post('/api/v1/organizers/{}/events/{}/checkinlists/{}/failed_checkins/'.format( organizer.slug, event.slug, clist.pk, @@ -1162,7 +1168,7 @@ def test_store_failed(token_client, organizer, clist, event, order): 'raw_barcode': '123456', 'nonce': '1234', 'position': p.pk, - 'error_reason': 'unpaid' + 'error_reason': 'unpaid', }, format='json') assert resp.status_code == 201 with scopes_disabled():