diff --git a/src/pretix/api/serializers/__init__.py b/src/pretix/api/serializers/__init__.py index dff4bbc5b..cf1ce268b 100644 --- a/src/pretix/api/serializers/__init__.py +++ b/src/pretix/api/serializers/__init__.py @@ -88,16 +88,20 @@ class SalesChannelMigrationMixin: } if data.get("all_sales_channels") and set(data["sales_channels"]) != all_channels: - raise ValidationError( - "If 'all_sales_channels' is set, the legacy attribute 'sales_channels' must not be set or set to " - "the list of all sales channels." - ) + raise ValidationError({ + "limit_sales_channels": [ + "If 'all_sales_channels' is set, the legacy attribute 'sales_channels' must not be set or set to " + "the list of all sales channels." + ] + }) if data.get("limit_sales_channels") and set(data["sales_channels"]) != set(data["limit_sales_channels"]): - raise ValidationError( - "If 'limit_sales_channels' is set, the legacy attribute 'sales_channels' must not be set or set to " - "the same list." - ) + raise ValidationError({ + "limit_sales_channels": [ + "If 'limit_sales_channels' is set, the legacy attribute 'sales_channels' must not be set or set to " + "the same list." + ] + }) if data["sales_channels"] == all_channels: data["all_sales_channels"] = True diff --git a/src/tests/api/test_events.py b/src/tests/api/test_events.py index 163b36702..8140f3ab3 100644 --- a/src/tests/api/test_events.py +++ b/src/tests/api/test_events.py @@ -807,6 +807,19 @@ def test_event_update_plugins_validation(token_client, organizer, event, item, m ) assert resp.status_code == 200 + resp = token_client.patch( + '/api/v1/organizers/{}/events/{}/'.format(organizer.slug, event.slug), + { + "all_sales_channels": False, + "limit_sales_channels": ["web"], + "sales_channels": ["bar"], + }, + format='json' + ) + assert resp.status_code == 400 + assert resp.content.decode() == ('{"limit_sales_channels":["If \'limit_sales_channels\' is set, the legacy ' + 'attribute \'sales_channels\' must not be set or set to the same list."]}') + @pytest.mark.django_db def test_event_test_mode(token_client, organizer, event):