-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto-publish doesn't update distributions
fixes: #8762 Required PR: pulp/pulpcore#1351
- Loading branch information
Showing
6 changed files
with
69 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Auto-publish no longer modifies distributions. | ||
Auto-distribute now only requires setting a distribution's ``repository`` field. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
from django.db import migrations, transaction | ||
from django.core.exceptions import ObjectDoesNotExist | ||
|
||
def remove_publications_from_auto_distributed(apps, schema_editor): | ||
with transaction.atomic(): | ||
FileDistribution = apps.get_model("file", "FileDistribution") | ||
distributions = FileDistribution.objects.filter(repository__isnull=False, publication__isnull=False) | ||
distributions.update(publication=None) | ||
|
||
def add_publications_to_auto_distributed(apps, schema_editor): | ||
with transaction.atomic(): | ||
FileDistribution = apps.get_model("file", "FileDistribution") | ||
distributions = list(FileDistribution.objects.filter(repository__isnull=False).select_related("repository")) | ||
for distribution in distributions: | ||
repo_version = distribution.repository.latest_version() | ||
try: | ||
publication = repo_version.publication_set.earliest("pulp_created") | ||
except ObjectDoesNotExist: | ||
publication = None | ||
distribution.publication = publication | ||
FileDistribution.objects.bulk_update(distributions, ['publication']) | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('file', '0010_auto_publish'), | ||
] | ||
|
||
operations = [ | ||
migrations.RunPython( | ||
remove_publications_from_auto_distributed, | ||
reverse_code=add_publications_to_auto_distributed | ||
) | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
pulpcore>=3.12 | ||
pulpcore>=3.13.0.dev |