Skip to content
This repository has been archived by the owner on Jan 9, 2023. It is now read-only.

Commit

Permalink
Fix reverse accessor clashes.
Browse files Browse the repository at this point in the history
  • Loading branch information
ipanova committed Sep 19, 2019
1 parent 7603684 commit 2c0a704
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
5 changes: 2 additions & 3 deletions README.md
Expand Up @@ -115,8 +115,7 @@ from Pulp 2 to Pulp 3, here are some guidelines.
4. Add a Content model to pre-migrate Pulp 2 content to (subclass the provided `Pulp2to3Content`
class). It has to have:
- a field `type` which will correspond to the `_content_type_id` of your Content in Pulp 2.
- a ForeignKey to the `pulp_2to3_migrate.app.models.Pulp2Content` model with the `related_name`
set to `'detail_model'` (provided by `Pulp2to3Content`).
- on a Meta class a `default_related_name` set to `<your pulp 2 content type>_detail_model`
- a classmethod `pre_migrate_content_detail` (see `Pulp2to3Content` for more details)
- a classmethod `migrate_content_to_pulp3` (see `Pulp2to3Content` for more details)
- a method `create_pulp3_content` (see `Pulp2to3Content` for more details)
Expand All @@ -129,4 +128,4 @@ class). It has to have:
artifact creation.

5. Subclass the provided `Pulp2to3Importer` class and define `migrate_to_pulp3` method which
create a plugin Remote instance based on the provided pre-migrated `Pulp2Importer`.
create a plugin Remote instance based on the provided pre-migrated `Pulp2Importer`.
10 changes: 7 additions & 3 deletions pulp_2to3_migrate/app/models/content.py
Expand Up @@ -31,13 +31,17 @@ class Meta:
unique_together = ('pulp2_id', 'pulp2_content_type_id')


@property
def detail_model(self):
return getattr(self, f'{self.pulp2_content_type_id}_detail_model').get()


class Pulp2to3Content(Model):
"""
Pulp 2to3 detail content model to store pulp 2 content details for Pulp 3 content creation.
"""
pulp2content = models.ForeignKey(Pulp2Content,
related_name='detail_model',
on_delete=models.CASCADE)
pulp2content = models.ForeignKey(Pulp2Content, on_delete=models.CASCADE)

type = '<your pulp 2 content type>'

class Meta:
Expand Down
2 changes: 1 addition & 1 deletion pulp_2to3_migrate/app/plugin/content.py
Expand Up @@ -170,7 +170,7 @@ async def migrate_to_pulp3(self, batch, pb=None):
batch: A batch of Pulp2Content objects to migrate to Pulp 3
"""
for pulp2content in batch:
pulp_2to3_detail_content = pulp2content.detail_model.get()
pulp_2to3_detail_content = pulp2content.detail_model
pulp3content = pulp_2to3_detail_content.create_pulp3_content()
future_relations = {'pulp2content': pulp2content}

Expand Down
1 change: 1 addition & 0 deletions pulp_2to3_migrate/app/plugin/iso/pulp3/models.py
Expand Up @@ -24,6 +24,7 @@ class Pulp2ISO(Pulp2to3Content):

class Meta:
unique_together = ('name', 'checksum', 'size', 'pulp2content')
default_related_name = 'iso_detail_model'

@property
def expected_digests(self):
Expand Down

0 comments on commit 2c0a704

Please sign in to comment.