Apply suggestions from code review

Co-authored-by: Raphael Michel <michel@rami.io>
This commit is contained in:
Mira
2024-07-26 17:12:05 +02:00
committed by GitHub
co-authored by Raphael Michel
parent c928e08955
commit 09a7987b61
3 changed files with 10 additions and 12 deletions
+5 -5
View File
@@ -1,9 +1,9 @@
.. _`rest-reusablemedia`:
Seats
==============
=====
Seat resources represent the seats in a seating plan in a specific event or subevent.
The seat resource represents the seats in a seating plan in a specific event or subevent.
Resource description
--------------------
@@ -25,9 +25,6 @@ seat_label string Additional labe
seat_guid string Identifier of the seat within the seating plan
product integer
blocked boolean Whether this seat is blocked manually.
sorting_rank integer
x float
y float
orderposition integer / object Internal ID of an order position reserving this seat.
cartposition integer / object Internal ID of a cart position reserving this seat.
voucher integer / object Internal ID of a voucher reserving this seat.
@@ -88,6 +85,7 @@ Endpoints
:statuscode 200: no error
:statuscode 401: Authentication failure
:statuscode 403: The requested organizer does not exist **or** you have no permission to view this resource.
:statuscode 404: Endpoint without subevent id was used for event with subevents, or vice versa.
.. http:get:: /api/v1/organizers/(organizer)/events/(event)/seats/(id)/
.. http:get:: /api/v1/organizers/(organizer)/events/(event)/subevents/(subevent_id)/seats/(id)/
@@ -126,6 +124,7 @@ Endpoints
:statuscode 200: no error
:statuscode 401: Authentication failure
:statuscode 403: The requested organizer does not exist **or** you have no permission to view this resource.
:statuscode 404: Seat does not exist; or the endpoint without subevent id was used for event with subevents, or vice versa.
.. http:patch:: /api/v1/organizers/(organizer)/events/(event)/seats/(id)/
.. http:patch:: /api/v1/organizers/(organizer)/events/(event)/subevents/(id)/seats/(id)/
@@ -168,3 +167,4 @@ Endpoints
:statuscode 400: The seat could not be modified due to invalid submitted data
:statuscode 401: Authentication failure
:statuscode 403: The requested organizer or event does not exist **or** you have no permission to change this resource.
:statuscode 404: Seat does not exist; or the endpoint without subevent id was used for event with subevents, or vice versa.
+5 -5
View File
@@ -971,15 +971,15 @@ class ItemMetaPropertiesSerializer(I18nAwareModelSerializer):
fields = ('id', 'name', 'default', 'required', 'allowed_values')
def prefetch_by_id(items, manager, id_attr, id_filter, target_attr):
def prefetch_by_id(items, qs, id_attr, id_filter, target_attr):
"""
Prefetches a related object on each item in the given list of items by searching by id or another
unique field. The id value is read from the attribute on item specified in `id_attr`, searched on manager by the
unique field. The id value is read from the attribute on item specified in `id_attr`, searched on queryset `qs` by the
field specified in `id_filter`, and the resulting prefetched model object is stored into `target_attr` on the item.
"""
ids = [getattr(item, id_attr) for item in items if getattr(item, id_attr)]
if ids:
result = manager.order_by(id_filter).distinct(id_filter).in_bulk(id_list=ids, field_name=id_filter)
result = qs.order_by(id_filter).distinct(id_filter).in_bulk(id_list=ids, field_name=id_filter)
for item in items:
setattr(item, target_attr, result.get(getattr(item, id_attr)))
@@ -993,12 +993,12 @@ class SeatSerializer(I18nAwareModelSerializer):
model = Seat
read_only_fields = (
'id', 'subevent', 'zone_name', 'row_name', 'row_label',
'seat_number', 'seat_label', 'seat_guid', 'product', 'sorting_rank', 'x', 'y',
'seat_number', 'seat_label', 'seat_guid', 'product',
'orderposition', 'cartposition', 'voucher',
)
fields = (
'id', 'subevent', 'zone_name', 'row_name', 'row_label',
'seat_number', 'seat_label', 'seat_guid', 'product', 'blocked', 'sorting_rank', 'x', 'y',
'seat_number', 'seat_label', 'seat_guid', 'product', 'blocked',
'orderposition', 'cartposition', 'voucher',
)
-2
View File
@@ -697,8 +697,6 @@ class SeatViewSet(ConditionalListView, viewsets.ModelViewSet):
ctx['order_context'] = {
'event': self.request.event,
'pdf_data': None,
'include': self.request.query_params.getlist('order_include'),
'exclude': self.request.query_params.getlist('order_exclude'),
}
return ctx