Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

why in my wagtail-modeltranslation the EN and NL versions are completely separated and i must to rebuild again for NL version. #437

Open
Matu-sunuwawa opened this issue Aug 30, 2024 · 0 comments

Comments

@Matu-sunuwawa
Copy link

When i make a new page, i need to build the content with all the blocks. Text, images, and all that. When i want to do the same for the Dutch version, i need to repeat all those steps to rebuild the page from scratch. This is a waste of time. i would like a function that allows us to copy the blocks from one language, and paste them into the section of the other language, so i only need to change the text, and not add all the images and stuff again.

but if there are best other solution am glad to hear!!!

the targeted flexindexpage ==>
the models.py:

from django.db import models

from modelcluster.fields import ParentalKey
from wagtail.admin.panels import FieldPanel, InlinePanel, MultiFieldPanel
from wagtail.fields import StreamField
from wagtail.models import Orderable, Page
from wagtailmenus.models import MenuPage

from except_wagtail.abstract_models import AbstractHero
from except_wagtail.blocks import BaseStreamBlock


class FlexIndexHeroImage(Orderable):
    """
    Image for carousel in hero section.

    """

    image = models.ForeignKey(
        "wagtailimages.Image",
        on_delete=models.SET_NULL,
        blank=True,
        null=True,
        related_name="+",
    )
    page = ParentalKey("FlexIndexPage", related_name="hero_images")

    panels = [
        FieldPanel("image"),
    ]


class FlexIndexPage(AbstractHero, MenuPage):
    intro_free_content = StreamField(
        BaseStreamBlock(),
        null=True,
        blank=True,
        use_json_field=True,
        verbose_name="Working area free content",
        help_text="Working Page Free Content Area",
    )

    content_panels = Page.content_panels + [
        MultiFieldPanel(
            [
                FieldPanel("hero_title"),
                FieldPanel("hero_subtitle"),
                FieldPanel("hero_video"),
                FieldPanel("hero_video_poster"),
                FieldPanel("hero_image"),
                FieldPanel("hero_halved"),
                FieldPanel("hero_slider_parallax"),
                InlinePanel(
                    "hero_images",
                    classname="full",
                    label="Hero section carousel images",
                ),
            ],
            heading="Hero section",
            classname="collapsible",
        ),
        FieldPanel("intro_free_content"),
    ]

    # parent_page_types = ["index.HomePage", "flex.FlexIndexPage"]

    def get_context(self, request):
        context = super().get_context(request)
        context["parallax"] = self.hero_slider_parallax

        return context

translations.py:

from modeltranslation.decorators import register
from modeltranslation.translator import TranslationOptions

from .models import FlexIndexPage


@register(FlexIndexPage)
class FlexIndexPageTR(TranslationOptions):
    fields = (
        "hero_title",
        "hero_subtitle",
        "intro_free_content",
    )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant