Skip to content

Commit

Permalink
Revert "Change JSONFields to more specific Fields"
Browse files Browse the repository at this point in the history
This reverts commit cf285d7.
  • Loading branch information
pedro-psb committed Jul 1, 2024
1 parent cf285d7 commit 23cfaee
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 75 deletions.
2 changes: 1 addition & 1 deletion pulp_rpm/app/serializers/advisory.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
52 changes: 16 additions & 36 deletions pulp_rpm/app/serializers/comps.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."),
Expand Down Expand Up @@ -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."),
)
Expand Down Expand Up @@ -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."))

Expand All @@ -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:
Expand Down
16 changes: 4 additions & 12 deletions pulp_rpm/app/serializers/modulemd.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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):
Expand Down Expand Up @@ -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):
Expand Down
40 changes: 20 additions & 20 deletions pulp_rpm/app/serializers/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand Down
9 changes: 3 additions & 6 deletions pulp_rpm/app/serializers/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 23cfaee

Please sign in to comment.