Keep pre-existing behaviour in case the specified checkinlist matches, even without the new parameter

This commit is contained in:
Mira Weller
2025-02-07 13:34:31 +01:00
parent faf50623d0
commit 97da945fe4
+20 -16
View File
@@ -165,26 +165,30 @@ class CheckinListViewSet(viewsets.ModelViewSet):
clist = self.get_object() clist = self.get_object()
if not serializer.validated_data.get('position') and 'events_and_checkin_lists' in self.request.data: 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 # 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 # was not synced in time, so we can enrich the log message
candidate_position = OrderPosition.all.filter( try:
organizer=self.request.organizer, candidate_position = OrderPosition.all.get(
secret=serializer.validated_data['raw_barcode'] organizer=self.request.organizer,
).first() secret=serializer.validated_data['raw_barcode']
if candidate_position.event.pk != clist.event.pk: )
try: except (OrderPosition.DoesNotExist, OrderPosition.MultipleObjectsReturned):
list_id = next(list_id for event_slug, list_id in self.request.data['events_and_checkin_lists'] pass
if event_slug == candidate_position.event.slug) else:
except StopIteration: # ignore if candidate position's event was not active on device if candidate_position.event.pk != clist.event.pk and 'events_and_checkin_lists' in self.request.data:
pass
else:
try: try:
clist = candidate_position.event.checkin_lists.get(pk=list_id) list_id = next(list_id for event_slug, list_id in self.request.data['events_and_checkin_lists']
except CheckinList.DoesNotExist: # ignore if list deleted in between if event_slug == candidate_position.event.slug)
except StopIteration: # ignore if candidate position's event was not active on device
pass pass
if candidate_position.event.pk == clist.event.pk: else:
kwargs['position'] = candidate_position try:
clist = candidate_position.event.checkin_lists.get(pk=list_id)
except CheckinList.DoesNotExist: # ignore if list deleted in between
pass
if candidate_position.event.pk == clist.event.pk:
kwargs['position'] = candidate_position
if serializer.validated_data.get('nonce'): if serializer.validated_data.get('nonce'):
if kwargs.get('position'): if kwargs.get('position'):