API: Validate input locales (Z#23182219) (#4833)

This commit is contained in:
Raphael Michel
2025-02-12 12:50:13 +01:00
committed by GitHub
parent 943193e8e0
commit 7afe2e66d7
5 changed files with 26 additions and 1 deletions

View File

@@ -19,6 +19,7 @@
# You should have received a copy of the GNU Affero General Public License along with this program. If not, see
# <https://www.gnu.org/licenses/>.
#
from rest_framework import serializers
from rest_framework.exceptions import ValidationError
from pretix.api.serializers.i18n import I18nAwareModelSerializer
@@ -26,12 +27,17 @@ from pretix.base.models import WaitingListEntry
class WaitingListSerializer(I18nAwareModelSerializer):
locale = serializers.ChoiceField(choices=[])
class Meta:
model = WaitingListEntry
fields = ('id', 'created', 'name', 'name_parts', 'email', 'phone', 'voucher', 'item', 'variation', 'locale', 'subevent', 'priority')
read_only_fields = ('id', 'created', 'voucher')
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.fields["locale"].choices = self.context['event'].settings.locales
def validate(self, data):
data = super().validate(data)
event = self.context['event']