Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor collection serializer #1860

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions pulp_ansible/app/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -684,16 +684,12 @@ def is_valid(self, raise_exception=False):
See Validating Models:
https://docs.pulpproject.org/pulpcore/plugins/plugin-writer/concepts/index.html
"""
write_fields = set(CollectionVersionUploadSerializer.Meta.fields) - {
"pulp_created",
"pulp_last_updated",
}
if hasattr(self, "initial_data"):
if any((x in self.initial_data for x in self.Meta.read_fields)):
# Pop shared fields: artifact & repository
artifact = self.initial_data.pop("artifact", None)
repository = self.initial_data.pop("repository", None)
if any((x in self.initial_data for x in write_fields)):
if any((x in self.initial_data for x in self.Meta.write_fields)):
if raise_exception:
raise ValidationError(
_("Read and write fields can not be used at the same time")
Expand Down Expand Up @@ -738,6 +734,10 @@ class Meta:
+ ContentChecksumSerializer.Meta.fields
+ read_fields
)
write_fields = set(CollectionVersionUploadSerializer.Meta.fields) - {
"pulp_created",
"pulp_last_updated",
}
model = CollectionVersion


Expand Down
Loading