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

@@ -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']