API: Allow to set seating_allow_blocked_seats_for_channel (Z#23159519) (#4333)

This commit is contained in:
Raphael Michel
2024-07-30 16:28:08 +02:00
committed by GitHub
parent bbc175d3d6
commit ad33785f4c
3 changed files with 30 additions and 1 deletions

View File

@@ -3363,7 +3363,9 @@ Your {organizer} team""")) # noqa: W291
},
'seating_allow_blocked_seats_for_channel': {
'default': [],
'type': list
'type': list,
'serializer_class': serializers.ListField,
'serializer_kwargs': lambda: dict(child=serializers.CharField()),
},
'seating_distance_within_row': {
'default': 'False',
@@ -3801,6 +3803,16 @@ def validate_event_settings(event, settings_dict):
'payment_term_last': _('The last payment date cannot be before the end of presale.')
})
if settings_dict.get('seating_allow_blocked_seats_for_channel'):
allowed_channels = set(event.organizer.sales_channels.values_list("identifier", flat=True))
for channel in settings_dict['seating_allow_blocked_seats_for_channel']:
if channel not in allowed_channels:
raise ValidationError({
'seating_allow_blocked_seats_for_channel': _('The value "{identifier}" is not a valid sales channel.').format(
identifier=channel
)
})
if isinstance(event, Event):
validate_event_settings.send(sender=event, settings_dict=settings_dict)