8000 [BUG] Page copy does not always work · Issue #7710 · django-cms/django-cms · GitHub
[go: up one dir, main page]

Skip to content
[BUG] Page copy does not always work #7710
Closed
@jrief

Description

@jrief

Description

In CMS4 copying a page does not work, if there is more than one version

Steps to reproduce

  • use CMS-4.1 and djangocms-versioning.
  • create a page
  • edit that page, so that there are at least two versions
  • go into page tree view and click on the hamburger menu of that page. Then copy that page to the clipboard.
  • go somewhere else and paste that page from the clipboard. An error-popup shows up on top.

Expected behaviour

The copy of the page should appear below the target page.

Actual behaviour

The problem occurs in ExtensionPool._copy_content_extensions
with this error: cms.models.contentmodels.PageContent.MultipleObjectsReturned

This causes an Internal Server (500) Error.

Additional information (CMS/Python/Django versions)

django-CMS (devel-4 branch, commit 79f7ff2)
djangocms-versioning (HEAD on master, version 2.0.0rc1)

Do you want to help fix this issue?

After applying this patch to that method, it seems to work. However, I'm unsure if this does not cause any unwanted side-effects, hence I didn't create a PR.

    def _copy_content_extensions(self, source_page, target_page, language):
-        source_content = source_page.pagecontent_set(manager="admin_manager").get(language=language)
-        target_title = target_page.pagecontent_set(manager="admin_manager").get(language=language)
+        source_content = source_page.pagecontent_set(manager="admin_manager").current_content(language=language).get()
+        target_title = target_page.pagecontent_set(manager="admin_manager").current_content(language=language).get()
         for extension in self.page_content_extensions:
             for instance in extension.objects.filter(extended_object=source_content):
                 instance.copy(target_title, language)
  • Yes, I want to help fix this issue and I will join #workgroup-pr-review on Slack to confirm with the community that a PR is welcome.
  • No, I only want to report the issue.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0