From b4dbede91d94b3fbe8cec0d23d992c381289fd14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Redrejo?= Date: Wed, 23 Nov 2022 09:37:35 +0100 Subject: [PATCH] Serializar does not return invalid path names for secondary locations --- kolibri/core/device/serializers.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/kolibri/core/device/serializers.py b/kolibri/core/device/serializers.py index ffaec369c04..8248afb643e 100644 --- a/kolibri/core/device/serializers.py +++ b/kolibri/core/device/serializers.py @@ -134,11 +134,20 @@ def create(self, validated_data): } +class PathListField(serializers.ListField): + def to_representation(self, data): + return [ + self.child.to_representation(item) + for item in data + if check_is_directory(item) + ] + + class DeviceSettingsSerializer(DeviceSerializerMixin, serializers.ModelSerializer): extra_settings = serializers.JSONField(required=False) primary_storage_location = serializers.CharField(required=False) - secondary_storage_locations = serializers.ListField( + secondary_storage_locations = PathListField( child=serializers.CharField(required=False), required=False )