mirror of
https://github.com/pretix/pretix.git
synced 2026-05-05 15:14:04 +00:00
Add API endpoint /seats to event (Z#23159536) (#4321)
* add API endpoint /seats to event
* fix logging
* add Seat annotations
* add seats endpoint for subevents
* return ids of occupying objects instead of boolean flags
* wip
* include orderposition instead of order in seat info
* add API documentation
* Apply suggestions from code review
Co-authored-by: Raphael Michel <michel@rami.io>
* Apply suggestions from code review
* Clarify API docs
* add api examples
* add test cases
* require can_view_orders permission for retrieving seats
* improve permission handling
* Revert "improve permission handling"
This reverts commit f32b532cc6.
* improve permission handling (minimal version)
* formatting
* add permission tests
* fix bug
* update permission checks
* Apply suggestions from code review
Co-authored-by: Raphael Michel <michel@rami.io>
* add tests for permission checks
* add tests for expand=voucher and expand=cartposition
* remove unused parameter
* test query count
* codestyle
---------
Co-authored-by: Raphael Michel <michel@rami.io>
This commit is contained in:
@@ -185,7 +185,7 @@ class Seat(models.Model):
|
||||
|
||||
@classmethod
|
||||
def annotated(cls, qs, event_id, subevent, ignore_voucher_id=None, minimal_distance=0,
|
||||
ignore_order_id=None, ignore_cart_id=None, distance_only_within_row=False):
|
||||
ignore_order_id=None, ignore_cart_id=None, distance_only_within_row=False, annotate_ids=False):
|
||||
from . import CartPosition, Order, OrderPosition, Voucher
|
||||
|
||||
vqs = Voucher.objects.filter(
|
||||
@@ -214,17 +214,24 @@ class Seat(models.Model):
|
||||
)
|
||||
if ignore_cart_id:
|
||||
cqs = cqs.exclude(cart_id=ignore_cart_id)
|
||||
qs_annotated = qs.annotate(
|
||||
has_order=Exists(
|
||||
opqs
|
||||
),
|
||||
has_cart=Exists(
|
||||
cqs
|
||||
),
|
||||
has_voucher=Exists(
|
||||
vqs
|
||||
if annotate_ids:
|
||||
qs_annotated = qs.annotate(
|
||||
orderposition_id=Subquery(opqs.values('id')),
|
||||
cartposition_id=Subquery(cqs.values('id')),
|
||||
voucher_id=Subquery(vqs.values('id')),
|
||||
)
|
||||
else:
|
||||
qs_annotated = qs.annotate(
|
||||
has_order=Exists(
|
||||
opqs
|
||||
),
|
||||
has_cart=Exists(
|
||||
cqs
|
||||
),
|
||||
has_voucher=Exists(
|
||||
vqs
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
if minimal_distance > 0:
|
||||
# TODO: Is there a more performant implementation on PostgreSQL using
|
||||
|
||||
Reference in New Issue
Block a user