wagtail / wagtail-localize

Translation plugin for Wagtail CMS
https://wagtail-localize.org/
Other
226 stars 86 forks source link

Second-level nested InlinePanel child objects are not copied for translation #809

Open gasman opened 3 months ago

gasman commented 3 months ago

If a snippet model definition contains two nested levels of InlinePanel children, then copying an item for translation results in the grandchild objects being moved from the source record to the translated record, instead of being copied.

Starting with a fresh Wagtail 6.2a0 instance with wagtail-localize installed and configured as

WAGTAIL_I18N_ENABLED = True
WAGTAIL_CONTENT_LANGUAGES = LANGUAGES = [
    ("en", "English"),
    ("fr", "French"),
]

and home/models.py as follows:

from django.db import models

from modelcluster.fields import ParentalKey
from modelcluster.models import ClusterableModel
from wagtail.admin.panels import FieldPanel, InlinePanel
from wagtail.models import Page, TranslatableMixin
from wagtail.snippets.models import register_snippet

class HomePage(Page):
    pass

@register_snippet
class Event(TranslatableMixin, ClusterableModel):
    name = models.CharField(max_length=255)

    def __str__(self):
        return self.name

    panels = [
        FieldPanel('name'),
        InlinePanel('sessions', label="Sessions"),
    ]

class Session(TranslatableMixin, ClusterableModel):
    event = ParentalKey(Event, related_name='sessions')
    name = models.CharField(max_length=255)

    def __str__(self):
        return self.name

    panels = [
        FieldPanel('name'),
        InlinePanel('speakers', label="Speakers"),
    ]

class Speaker(TranslatableMixin, models.Model):
    session = ParentalKey(Session, related_name='speakers')
    name = models.CharField(max_length=255)

    def __str__(self):
        return self.name

    panels = [
        FieldPanel('name'),
    ]