Add option to limit events to specific sales channels (#1867)

This commit is contained in:
Martin Gross
2020-12-03 17:10:54 +01:00
committed by GitHub
parent 55d8639ecc
commit b3e95f54dd
17 changed files with 185 additions and 23 deletions

View File

@@ -28,6 +28,7 @@ with scopes_disabled():
is_past = django_filters.rest_framework.BooleanFilter(method='is_past_qs')
is_future = django_filters.rest_framework.BooleanFilter(method='is_future_qs')
ends_after = django_filters.rest_framework.IsoDateTimeFilter(method='ends_after_qs')
sales_channel = django_filters.rest_framework.CharFilter(method='sales_channel_qs')
class Meta:
model = Event
@@ -69,6 +70,9 @@ with scopes_disabled():
else:
return queryset.exclude(expr)
def sales_channel_qs(self, queryset, name, value):
return queryset.filter(sales_channels__contains=value)
class EventViewSet(viewsets.ModelViewSet):
serializer_class = EventSerializer