diff --git a/src/pretix/api/serializers/event.py b/src/pretix/api/serializers/event.py index 609466042e..38965fefd8 100644 --- a/src/pretix/api/serializers/event.py +++ b/src/pretix/api/serializers/event.py @@ -972,9 +972,19 @@ class ItemMetaPropertiesSerializer(I18nAwareModelSerializer): class SeatSerializer(I18nAwareModelSerializer): + has_order = serializers.BooleanField() + has_cart = serializers.BooleanField() + has_voucher = serializers.BooleanField() + class Meta: model = Seat - read_only_fields = ('id', 'subevent', 'zone_name', 'row_name', 'row_label', - 'seat_number', 'seat_label', 'seat_guid', 'product', 'sorting_rank', 'x', 'y',) - fields = ('id', 'subevent', 'zone_name', 'row_name', 'row_label', - 'seat_number', 'seat_label', 'seat_guid', 'product', 'blocked', 'sorting_rank', 'x', 'y',) + read_only_fields = ( + 'id', 'subevent', 'zone_name', 'row_name', 'row_label', + 'seat_number', 'seat_label', 'seat_guid', 'product', 'sorting_rank', 'x', 'y', + 'has_order', 'has_cart', 'has_voucher', + ) + fields = ( + 'id', 'subevent', 'zone_name', 'row_name', 'row_label', + 'seat_number', 'seat_label', 'seat_guid', 'product', 'blocked', 'sorting_rank', 'x', 'y', + 'has_order', 'has_cart', 'has_voucher', + ) diff --git a/src/pretix/api/views/event.py b/src/pretix/api/views/event.py index b28c339bf8..dbbb27aa9f 100644 --- a/src/pretix/api/views/event.py +++ b/src/pretix/api/views/event.py @@ -674,10 +674,16 @@ class SeatViewSet(ConditionalListView, viewsets.ModelViewSet): queryset = Seat.objects.none() write_permission = 'can_change_event_settings' filter_backends = [DjangoFilterBackend] - filterset_fields = ['zone_name', 'row_name', 'row_label', 'seat_number', 'seat_label', 'seat_guid', 'blocked'] + filterset_fields = ['subevent', + 'zone_name', 'row_name', 'row_label', 'seat_number', 'seat_label', + 'seat_guid', 'blocked',] def get_queryset(self): - return self.request.event.seats.all() + if self.request.event.has_subevents: + subevent = self.request.event.subevents.get(pk=self.request.GET.get('subevent')) + return Seat.annotated(event_id=self.request.event.id, subevent=subevent, qs=subevent.seats.all()) + else: + return Seat.annotated(event_id=self.request.event.id, subevent=None, qs=self.request.event.seats.all()) def perform_update(self, serializer): super().perform_update(serializer)