mirror of
https://github.com/pretix/pretix.git
synced 2025-12-07 22:42:26 +00:00
Compare commits
6 Commits
fix-csv-er
...
lists-for-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4a59b5ab34 | ||
|
|
e08a1551ee | ||
|
|
65abae9cbc | ||
|
|
97da945fe4 | ||
|
|
faf50623d0 | ||
|
|
cacc051437 |
@@ -163,12 +163,27 @@ class CheckinListViewSet(viewsets.ModelViewSet):
|
||||
serializer.is_valid(raise_exception=True)
|
||||
kwargs = {}
|
||||
|
||||
if not serializer.validated_data.get('position'):
|
||||
kwargs['position'] = OrderPosition.all.filter(
|
||||
secret=serializer.validated_data['raw_barcode']
|
||||
).first()
|
||||
|
||||
clist = self.get_object()
|
||||
|
||||
if not serializer.validated_data.get('position'):
|
||||
# an offline checkin failed, let's see whether a ticket with the given secret actually exists and just
|
||||
# was not synced in time, so we can enrich the log message
|
||||
try:
|
||||
candidate_position = OrderPosition.all.get(
|
||||
organizer=self.request.organizer,
|
||||
secret=serializer.validated_data['raw_barcode']
|
||||
)
|
||||
except (OrderPosition.DoesNotExist, OrderPosition.MultipleObjectsReturned):
|
||||
pass
|
||||
else:
|
||||
if candidate_position.event.pk != clist.event.pk and 'candidate_checkin_lists' in self.request.data:
|
||||
try:
|
||||
clist = candidate_position.event.checkin_lists.get(pk__in=self.request.data['candidate_checkin_lists'])
|
||||
except CheckinList.DoesNotExist:
|
||||
pass # ignore if candidate position's event was not active on device, if list was deleted in between
|
||||
if candidate_position.event.pk == clist.event.pk:
|
||||
kwargs['position'] = candidate_position
|
||||
|
||||
if serializer.validated_data.get('nonce'):
|
||||
if kwargs.get('position'):
|
||||
prev = kwargs['position'].all_checkins.filter(nonce=serializer.validated_data['nonce']).first()
|
||||
|
||||
@@ -80,7 +80,7 @@ class OrderLogEntryType(EventLogEntryType):
|
||||
content_type = Order
|
||||
|
||||
def object_link_args(self, order):
|
||||
return {'code': order.code}
|
||||
return {'event': order.event.slug, 'code': order.code}
|
||||
|
||||
def object_link_display_name(self, order):
|
||||
return order.code
|
||||
|
||||
@@ -777,6 +777,50 @@ def test_store_failed(token_client, organizer, clist, event, order):
|
||||
assert resp.status_code == 400
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_store_failed_other_event(token_client, organizer, clist, event, clist_event2, event2, order):
|
||||
with scopes_disabled():
|
||||
p = order.positions.first()
|
||||
p.secret = 'xyzabc'
|
||||
p.save()
|
||||
resp = token_client.post('/api/v1/organizers/{}/events/{}/checkinlists/{}/failed_checkins/'.format(
|
||||
organizer.slug, event.slug, clist.pk,
|
||||
), {
|
||||
'raw_barcode': 'xyzabc',
|
||||
'error_reason': 'invalid',
|
||||
'nonce': '111',
|
||||
}, format='json')
|
||||
assert resp.status_code == 201
|
||||
with scopes_disabled():
|
||||
c = Checkin.all.get(nonce='111')
|
||||
assert c.position == p
|
||||
|
||||
resp = token_client.post('/api/v1/organizers/{}/events/{}/checkinlists/{}/failed_checkins/'.format(
|
||||
organizer.slug, event2.slug, clist_event2.pk,
|
||||
), {
|
||||
'raw_barcode': 'xyzabc',
|
||||
'error_reason': 'invalid',
|
||||
'nonce': '222',
|
||||
}, format='json')
|
||||
assert resp.status_code == 201
|
||||
with scopes_disabled():
|
||||
c = Checkin.all.get(nonce='222')
|
||||
assert c.position is None
|
||||
|
||||
resp = token_client.post('/api/v1/organizers/{}/events/{}/checkinlists/{}/failed_checkins/'.format(
|
||||
organizer.slug, event2.slug, clist_event2.pk,
|
||||
), {
|
||||
'raw_barcode': 'xyzabc',
|
||||
'error_reason': 'invalid',
|
||||
'candidate_checkin_lists': [clist.pk, clist_event2.pk],
|
||||
'nonce': '333',
|
||||
}, format='json')
|
||||
assert resp.status_code == 201
|
||||
with scopes_disabled():
|
||||
c = Checkin.all.get(nonce='333')
|
||||
assert c.position == p
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_redeem_unknown(token_client, organizer, clist, event, order):
|
||||
resp = _redeem(token_client, organizer, clist, 'unknown_secret', {'force': True})
|
||||
|
||||
Reference in New Issue
Block a user