API: Add exclude parameter to check-in lists

This commit is contained in:
Raphael Michel
2020-08-26 15:20:44 +02:00
parent 7a3418e32f
commit 7956074d8b
2 changed files with 13 additions and 1 deletions

View File

@@ -58,7 +58,7 @@ rules object Custom check-in
.. versionchanged:: 3.11
The ``subevent_match`` filter has been added.
The ``subevent_match`` and ``exclude`` query parameters have been added.
Endpoints
---------
@@ -114,6 +114,7 @@ Endpoints
:query integer page: The page number in case of a multi-page result set, default is 1
:query integer subevent: Only return check-in lists of the sub-event with the given ID
:query integer subevent_match: Only return check-in lists that are valid for the sub-event with the given ID (i.e. also lists valid for all subevents)
:query string exclude: Exclude a field from the output, e.g. ``checkin_count``. Can be used as a performance optimization. Can be passed multiple times.
:param organizer: The ``slug`` field of the organizer to fetch
:param event: The ``slug`` field of the event to fetch
:statuscode 200: no error

View File

@@ -17,6 +17,17 @@ class CheckinListSerializer(I18nAwareModelSerializer):
'include_pending', 'auto_checkin_sales_channels', 'allow_multiple_entries', 'allow_entry_after_exit',
'rules')
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
for exclude_field in self.context['request'].query_params.getlist('exclude'):
p = exclude_field.split('.')
if p[0] in self.fields:
if len(p) == 1:
del self.fields[p[0]]
elif len(p) == 2:
self.fields[p[0]].child.fields.pop(p[1])
def validate(self, data):
data = super().validate(data)
event = self.context['event']