From a872af9825cb5f2489031b3fbef2a7f8a9c3480d Mon Sep 17 00:00:00 2001 From: Niko Lindroos Date: Mon, 2 Feb 2026 14:37:52 +0200 Subject: [PATCH] fix(ks): employer application should allow empty target group YJDH-738. A critical fix to API data input serializer of employer application handling. When employer's UI creates a new draft, it always sends an empty target group. This empty string needs to be allowed also in serializer which is called by EmployerApplicationSerializer. --- backend/kesaseteli/applications/api/v1/serializers.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/backend/kesaseteli/applications/api/v1/serializers.py b/backend/kesaseteli/applications/api/v1/serializers.py index 13aac44973..d2a651a0f8 100644 --- a/backend/kesaseteli/applications/api/v1/serializers.py +++ b/backend/kesaseteli/applications/api/v1/serializers.py @@ -224,7 +224,10 @@ class EmployerSummerVoucherSerializer(serializers.ModelSerializer): ) target_group = serializers.ChoiceField( - choices=get_target_group_choices(), required=False + choices=get_target_group_choices(), + required=False, + allow_blank=True, + allow_null=True, ) class Meta: @@ -275,7 +278,9 @@ def _validate_non_draft_required_fields(self, data): } ) - def _update_target_group(self, instance: EmployerSummerVoucher, target_group: str): + def _update_target_group( + self, instance: EmployerSummerVoucher, target_group: Optional[str] + ): """ Update the target_group of the youth voucher if it exists.