mirror of
https://github.com/pretix/pretix.git
synced 2026-08-09 10:37:50 +00:00
add Seat annotations
This commit is contained in:
@@ -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',
|
||||
)
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user