django-cms / djangocms-versioning

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

PageContentExtension should offer hook copy_relations #342

Closed jrief closed 1 year ago

jrief commented 1 year ago

If someone extends model PageContent by creating a model inheriting from PageContentExtension, that extension only creates flat copies. This is because no hook method copy_relations is called.

I'm using a model MySpecialContent which inherits from PageContentExtension. That model has a one-to-one-relation with PageContent. PageContent is versioned using djangocms-versioning. If I create a new version of a CMS page, in the database a new row appears containing a copy of MySpecialContent. This is expected behavior.

MySpecialContent has some relations which must also be copied whenever I create a new version. CMS3 offered the method copy_relations which would perform this action. In CMS3 this method was called implicitly. In CMS4 it however is not called when creating a new copy of a PageContentExtension.

I have a patch for this. PR is coming soon.