API: fix event creation sales-channel-migration (#4949)

* API: fix event creation sales-channel-migration

* do not allow sales_channels to be None

* fix wrong validation error-key
This commit is contained in:
Richard Schreiber
2025-03-25 16:52:29 +01:00
committed by GitHub
parent 06efb37d5d
commit a903cfa4d1

View File

@@ -81,6 +81,13 @@ class SalesChannelMigrationMixin:
def to_internal_value(self, data):
if "sales_channels" in data:
if data["sales_channels"] is None:
raise ValidationError({
"sales_channels": [
"The legacy attribute 'sales_channels' cannot be set to None, it must be a list."
]
})
prefetch_related_objects([self.organizer], "sales_channels")
all_channels = {
s.identifier for s in
@@ -89,7 +96,7 @@ class SalesChannelMigrationMixin:
if data.get("all_sales_channels") and set(data["sales_channels"]) != all_channels:
raise ValidationError({
"limit_sales_channels": [
"all_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."
]
@@ -109,6 +116,7 @@ class SalesChannelMigrationMixin:
else:
data["all_sales_channels"] = False
data["limit_sales_channels"] = data["sales_channels"]
del data["sales_channels"]
if data.get("all_sales_channels"):