diff --git a/CHANGES/1836.bugfix b/CHANGES/1836.bugfix new file mode 100644 index 000000000..519712fe2 --- /dev/null +++ b/CHANGES/1836.bugfix @@ -0,0 +1 @@ +Fixed import failing to associate signatures and marks with their collection version. diff --git a/pulp_ansible/app/modelresource.py b/pulp_ansible/app/modelresource.py index f82d671e6..06fd51319 100644 --- a/pulp_ansible/app/modelresource.py +++ b/pulp_ansible/app/modelresource.py @@ -138,6 +138,19 @@ def set_up_queryset(self): """ return CollectionVersionSignature.objects.filter(pk__in=self.repo_version.content) + def before_import_row(self, row, **kwargs): + """ + Finds and sets collection version using upstream_id. + + Args: + row (tablib.Dataset row): incoming import-row representing a single content. + kwargs: args passed along from the import() call. + """ + super().before_import_row(row, **kwargs) + + cv = CollectionVersion.objects.get(upstream_id=row["signed_collection"]) + row["signed_collection"] = str(cv.pk) + class Meta: model = CollectionVersionSignature import_id_fields = ("pubkey_fingerprint", "signed_collection") @@ -155,6 +168,19 @@ def set_up_queryset(self): """ return CollectionVersionMark.objects.filter(pk__in=self.repo_version.content) + def before_import_row(self, row, **kwargs): + """ + Finds and sets collection version using upstream_id. + + Args: + row (tablib.Dataset row): incoming import-row representing a single content. + kwargs: args passed along from the import() call. + """ + super().before_import_row(row, **kwargs) + + cv = CollectionVersion.objects.get(upstream_id=row["marked_collection"]) + row["marked_collection"] = str(cv.pk) + class Meta: model = CollectionVersionMark import_id_fields = ("value", "marked_collection")