From 23cfaee5530c722964ff1b31e93f15c005737d45 Mon Sep 17 00:00:00 2001 From: Pedro Brochado Date: Mon, 1 Jul 2024 14:00:23 -0300 Subject: [PATCH] Revert "Change JSONFields to more specific Fields" This reverts commit cf285d7cd4155c0f18f48cc66c3101c0278fe2bc. --- pulp_rpm/app/serializers/advisory.py | 2 +- pulp_rpm/app/serializers/comps.py | 52 ++++++++------------------ pulp_rpm/app/serializers/modulemd.py | 16 ++------ pulp_rpm/app/serializers/package.py | 40 ++++++++++---------- pulp_rpm/app/serializers/repository.py | 9 ++--- 5 files changed, 44 insertions(+), 75 deletions(-) diff --git a/pulp_rpm/app/serializers/advisory.py b/pulp_rpm/app/serializers/advisory.py index f102b1a4c..6c9e99238 100644 --- a/pulp_rpm/app/serializers/advisory.py +++ b/pulp_rpm/app/serializers/advisory.py @@ -43,7 +43,7 @@ class UpdateCollectionSerializer(ModelSerializer): help_text=_("Collection short name."), allow_blank=True, allow_null=True ) - module = serializers.CharField(help_text=_("Collection modular NSVCA."), allow_null=True) + module = serializers.JSONField(help_text=_("Collection modular NSVCA."), allow_null=True) packages = UpdateCollectionPackagesField( source="*", read_only=True, help_text=_("List of packages") diff --git a/pulp_rpm/app/serializers/comps.py b/pulp_rpm/app/serializers/comps.py index b65e2e376..4b94ea9c5 100644 --- a/pulp_rpm/app/serializers/comps.py +++ b/pulp_rpm/app/serializers/comps.py @@ -31,19 +31,13 @@ class PackageGroupSerializer(NoArtifactContentSerializer): ) name = serializers.CharField(help_text=_("PackageGroup name."), allow_blank=True) description = serializers.CharField(help_text=_("PackageGroup description."), allow_blank=True) - packages = serializers.ListField( - help_text=_("PackageGroup package list."), child=serializers.CharField(), allow_null=True - ) + packages = serializers.JSONField(help_text=_("PackageGroup package list."), allow_null=True) biarch_only = serializers.BooleanField(help_text=_("PackageGroup biarch only."), required=False) - desc_by_lang = serializers.DictField( - help_text=_("PackageGroup description by language."), - child=serializers.CharField(), - allow_null=True, + desc_by_lang = serializers.JSONField( + help_text=_("PackageGroup description by language."), allow_null=True ) - name_by_lang = serializers.DictField( - help_text=_("PackageGroup name by language."), - child=serializers.CharField(), - allow_null=True, + name_by_lang = serializers.JSONField( + help_text=_("PackageGroup name by language."), allow_null=True ) digest = serializers.CharField( help_text=_("PackageGroup digest."), @@ -79,17 +73,11 @@ class PackageCategorySerializer(NoArtifactContentSerializer): display_order = serializers.IntegerField( help_text=_("Category display order."), allow_null=True ) - group_ids = serializers.ListField( - help_text=_("Category group list."), child=serializers.CharField(), allow_null=True - ) - desc_by_lang = serializers.DictField( - help_text=_("Category description by language."), - child=serializers.CharField(), - allow_null=True, - ) - name_by_lang = serializers.DictField( - help_text=_("Category name by language."), child=serializers.CharField(), allow_null=True + group_ids = serializers.JSONField(help_text=_("Category group list."), allow_null=True) + desc_by_lang = serializers.JSONField( + help_text=_("Category description by language."), allow_null=True ) + name_by_lang = serializers.JSONField(help_text=_("Category name by language."), allow_null=True) digest = serializers.CharField( help_text=_("Category digest."), ) @@ -121,19 +109,13 @@ class PackageEnvironmentSerializer(NoArtifactContentSerializer): display_order = serializers.IntegerField( help_text=_("Environment display order."), allow_null=True ) - group_ids = serializers.ListField( - help_text=_("Environment group list."), child=serializers.CharField(), allow_null=True + group_ids = serializers.JSONField(help_text=_("Environment group list."), allow_null=True) + option_ids = serializers.JSONField(help_text=_("Environment option ids"), allow_null=True) + desc_by_lang = serializers.JSONField( + help_text=_("Environment description by language."), allow_null=True ) - option_ids = serializers.ListField( - help_text=_("Environment option ids"), child=serializers.CharField(), allow_null=True - ) - desc_by_lang = serializers.DictField( - help_text=_("Environment description by language."), - child=serializers.CharField(), - allow_null=True, - ) - name_by_lang = serializers.DictField( - help_text=_("Environment name by language."), child=serializers.CharField(), allow_null=True + name_by_lang = serializers.JSONField( + help_text=_("Environment name by language."), allow_null=True ) digest = serializers.CharField(help_text=_("Environment digest.")) @@ -157,9 +139,7 @@ class PackageLangpacksSerializer(NoArtifactContentSerializer): PackageLangpacks serializer. """ - matches = serializers.ListField( - help_text=_("Langpacks matches."), child=serializers.CharField(), allow_null=True - ) + matches = serializers.JSONField(help_text=_("Langpacks matches."), allow_null=True) digest = serializers.CharField(help_text=_("Langpacks digest."), allow_null=True) class Meta: diff --git a/pulp_rpm/app/serializers/modulemd.py b/pulp_rpm/app/serializers/modulemd.py index 0233368f0..1b35e39d2 100644 --- a/pulp_rpm/app/serializers/modulemd.py +++ b/pulp_rpm/app/serializers/modulemd.py @@ -31,12 +31,8 @@ class ModulemdSerializer(NoArtifactContentSerializer): arch = serializers.CharField( help_text=_("Modulemd architecture."), ) - artifacts = serializers.ListField( - help_text=_("Modulemd artifacts."), child=serializers.CharField(), allow_null=True - ) - dependencies = serializers.ListField( - help_text=_("Modulemd dependencies."), child=serializers.CharField(), allow_null=True - ) + artifacts = serializers.JSONField(help_text=_("Modulemd artifacts."), allow_null=True) + dependencies = serializers.JSONField(help_text=_("Modulemd dependencies."), allow_null=True) # TODO: The performance of this is not great, there's a noticable difference in response # time before/after. Since this will only return Package content hrefs, we might benefit # from creating a specialized version of this Field that can skip some of the work. @@ -49,9 +45,7 @@ class ModulemdSerializer(NoArtifactContentSerializer): view_name="content-rpm/packages-detail", many=True, ) - profiles = serializers.ListField( - help_text=_("Modulemd profiles."), child=serializers.CharField(), allow_null=True - ) + profiles = serializers.JSONField(help_text=_("Modulemd profiles."), allow_null=True) snippet = serializers.CharField(help_text=_("Modulemd snippet"), write_only=True) def create(self, validated_data): @@ -93,9 +87,7 @@ class ModulemdDefaultsSerializer(NoArtifactContentSerializer): module = serializers.CharField(help_text=_("Modulemd name.")) stream = serializers.CharField(help_text=_("Modulemd default stream.")) - profiles = serializers.ListField( - help_text=_("Default profiles for modulemd streams."), child=serializers.CharField() - ) + profiles = serializers.JSONField(help_text=_("Default profiles for modulemd streams.")) snippet = serializers.CharField(help_text=_("Modulemd default snippet"), write_only=True) def create(self, validated_data): diff --git a/pulp_rpm/app/serializers/package.py b/pulp_rpm/app/serializers/package.py index d78444482..819fd2078 100644 --- a/pulp_rpm/app/serializers/package.py +++ b/pulp_rpm/app/serializers/package.py @@ -77,64 +77,64 @@ class PackageSerializer(SingleArtifactContentUploadSerializer, ContentChecksumSe read_only=True, ) - changelogs = serializers.ListField( + changelogs = serializers.JSONField( help_text=_("Changelogs that package contains"), - child=serializers.CharField(), + default="[]", required=False, read_only=True, ) - files = serializers.ListField( + files = serializers.JSONField( help_text=_("Files that package contains"), - child=serializers.CharField(), + default="[]", required=False, read_only=True, ) - requires = serializers.ListField( + requires = serializers.JSONField( help_text=_("Capabilities the package requires"), - child=serializers.CharField(), + default="[]", required=False, read_only=True, ) - provides = serializers.ListField( + provides = serializers.JSONField( help_text=_("Capabilities the package provides"), - child=serializers.CharField(), + default="[]", required=False, read_only=True, ) - conflicts = serializers.ListField( + conflicts = serializers.JSONField( help_text=_("Capabilities the package conflicts"), - child=serializers.CharField(), + default="[]", required=False, read_only=True, ) - obsoletes = serializers.ListField( + obsoletes = serializers.JSONField( help_text=_("Capabilities the package obsoletes"), - child=serializers.CharField(), + default="[]", required=False, read_only=True, ) - suggests = serializers.ListField( + suggests = serializers.JSONField( help_text=_("Capabilities the package suggests"), - child=serializers.CharField(), + default="[]", required=False, read_only=True, ) - enhances = serializers.ListField( + enhances = serializers.JSONField( help_text=_("Capabilities the package enhances"), - child=serializers.CharField(), + default="[]", required=False, read_only=True, ) - recommends = serializers.ListField( + recommends = serializers.JSONField( help_text=_("Capabilities the package recommends"), - child=serializers.CharField(), + default="[]", required=False, read_only=True, ) - supplements = serializers.ListField( + supplements = serializers.JSONField( help_text=_("Capabilities the package supplements"), - child=serializers.CharField(), + default="[]", required=False, read_only=True, ) diff --git a/pulp_rpm/app/serializers/repository.py b/pulp_rpm/app/serializers/repository.py index 4baa072e3..682cf8132 100644 --- a/pulp_rpm/app/serializers/repository.py +++ b/pulp_rpm/app/serializers/repository.py @@ -139,10 +139,9 @@ class RpmRepositorySerializer(RepositorySerializer): ), read_only=True, ) - repo_config = serializers.DictField( + repo_config = serializers.JSONField( required=False, help_text=_("A JSON document describing config.repo file"), - child=serializers.CharField(), ) def validate(self, data): @@ -403,10 +402,9 @@ class RpmPublicationSerializer(PublicationSerializer): ), read_only=True, ) - repo_config = serializers.DictField( + repo_config = serializers.JSONField( required=False, help_text=_("A JSON document describing config.repo file"), - child=serializers.CharField(), ) def validate(self, data): @@ -543,9 +541,8 @@ class CopySerializer(ValidateFieldsMixin, serializers.Serializer): A serializer for Content Copy API. """ - config = serializers.DictField( + config = serializers.JSONField( help_text=_("A JSON document describing sources, destinations, and content to be copied"), - child=serializers.CharField(), ) dependency_solving = serializers.BooleanField(