django-cms / djangocms-versioning

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

feat: Improve default copy method to also copy placeholders and plugins #345

Open fsbraun opened 1 year ago

fsbraun commented 1 year ago

Description

Versioning allows specifying a copy method to allow for copying foreign keys, one-to-one fields in a meaningful way for the specific model.

One of the most relevant relations will be placeholders and their plugins.

To avoid code repetition of largely identical copy methods in any package using djangocms-versioning, I propose to include coyping placeholders in versioned models by default.

This would make custom copy functions obsolete in alias and blog and other content objects to come.

Also, if the verisoned model has a method copy_relations it is called on the new object allowing to keep simple copy information within the model.

Tests follow.

Related resources

Checklist

codecov[bot] commented 1 year ago

Codecov Report

Attention: Patch coverage is 23.52941% with 13 lines in your changes are missing coverage. Please review.

Project coverage is 91.15%. Comparing base (f90c5b2) to head (b04488e). Report is 13 commits behind head on master.

Files Patch % Lines
djangocms_versioning/datastructures.py 23.52% 11 Missing and 2 partials :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #345 +/- ## ========================================== + Coverage 90.88% 91.15% +0.26% ========================================== Files 72 72 Lines 2546 2589 +43 Branches 361 373 +12 ========================================== + Hits 2314 2360 +46 + Misses 168 164 -4 - Partials 64 65 +1 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.