django-cms / djangocms-versioning

General purpose versioning package for Django CMS 4 and above.
Other
33 stars 29 forks source link

Copy and pasting pages in page tree broken #294

Closed fsbraun closed 1 year ago

fsbraun commented 1 year ago

Copying and pasting a page or parts of the page tree only reflects currently published pages. Trying to view a copied page leads to Version matching query does not exist.exception.

Description

Steps to reproduce

Steps:

  1. Start from empty project with ./manage.py migrate, ./manage.py createsuperuser, and ./manage.py runserver
  2. Go to localhost:8000/admin and log in.
  3. Create new page content (e.g., test)
  4. Publish that page.
  5. Create another new page content (e.g., unpublished) and do not publish it.
  6. Copy all pages from the global burger menu in the page tree
  7. Paste the pages either from the global burger menu or from the page’s burger menu.

Expected behaviour

As an editor I will expect the page content objects to be copied that I am working with. IMHO this would be the first existing version in this order:

  1. Latest draft
  2. Published
  3. Latest unpublished

The copied page should appear in the page tree as draft versions.

Actual behaviour

Screenshots

page-tree-versioning

This issue is part of https://github.com/django-cms/django-cms/issues/7400 which cannot be fixed within the core.

Additional information (CMS/Python/Django versions)

Do you want to help fix this issue?

At first sight this might be deep rooted issue. I would assume it comes from monkey patching the model manager of the PageContent object. There potentially are design decisions to be taken:

The Page models copies self.pagecontent_set.all() which evaluates to an empty query set if djangocms-versioning is installed and the page is not published. Apparently versioning monkey patches the way pagecontent_set is evaluated and only reflects published pages (in its managers.py).

fsbraun commented 1 year ago

Fixed by #300