Fail gracefully if seats exist multiple times

This commit is contained in:
Raphael Michel
2019-08-26 16:33:35 +02:00
parent 733a4ce8f4
commit ebf411b7a0
2 changed files with 4 additions and 0 deletions

View File

@@ -82,6 +82,8 @@ class CartPositionCreateSerializer(I18nAwareModelSerializer):
seat = self.context['event'].seats.get(seat_guid=validated_data['seat'], subevent=validated_data.get('subevent'))
except Seat.DoesNotExist:
raise ValidationError('The specified seat does not exist.')
except Seat.MultipleObjectsReturned:
raise ValidationError('The specified seat ID is not unique.')
else:
validated_data['seat'] = seat
if not seat.is_available():