Skip to content

Commit

Permalink
Add missing .specific
Browse files Browse the repository at this point in the history
  • Loading branch information
kaedroho committed Jan 10, 2020
1 parent 45f9c0f commit b65db54
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 4 additions & 4 deletions wagtail_localize/translation/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,15 @@ class TranslatableRevision(models.Model):

@classmethod
def get_or_create_from_page_revision(cls, page_revision):
object, created = TranslatableObject.objects.get_or_create_from_instance(
page_revision.page
)
page = page_revision.page.specific

object, created = TranslatableObject.objects.get_or_create_from_instance(page)

return TranslatableRevision.objects.get_or_create(
object=object,
page_revision=page_revision,
defaults={
"locale_id": page_revision.page.locale_id,
"locale_id": page.locale_id,
"content_json": page_revision.content_json,
"created_at": page_revision.created_at,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ def test_create(self):
TranslatableRevision.objects.all().delete()

page_revision = self.page.get_latest_revision()

# Refetch the page revision so that it has the generic Page object associated
page_revision.refresh_from_db()

revision, created = TranslatableRevision.get_or_create_from_page_revision(
page_revision
)
Expand Down

0 comments on commit b65db54

Please sign in to comment.