django-cms / djangocms-versioning

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

feat: Django 4.2, Django CMS 4.1.0rc2 compatibility, and version locking #326

Closed fsbraun closed 1 year ago

fsbraun commented 1 year ago

Description

This PR adds tests for Django 4.2 and mixins for django CMS' GrouperModelAdmin class (new in 4.2rc2). It includes the version locking functionality. Version locking is activated by setting DJANGOCMS_VERSIONING_LOCK_VERSIONS = True in the project settings.

Documentation has been updated and tests have been added.

To stay DRY and avoid code repetition, the djangocms_versioning.admin module has been slightly refactored. ExtendedListDisplayMixin encapsulates the extension of the change list view of versioned objects using django CMS 4's new config feature. Both versioned grouper admins and versioned content admins inherit it.

Djangocms Versioning now supports both versioned grouper model admins and versioned content model admins. The latter are backwards compatible.

Related resources

Checklist

codecov[bot] commented 1 year ago

Codecov Report

Merging #326 (d836487) into master (2ce8647) will increase coverage by 0.37%. The diff coverage is 94.84%.

@@            Coverage Diff             @@
##           master     #326      +/-   ##
==========================================
+ Coverage   90.55%   90.93%   +0.37%     
==========================================
  Files          69       72       +3     
  Lines        2329     2536     +207     
  Branches      314      358      +44     
==========================================
+ Hits         2109     2306     +197     
- Misses        165      170       +5     
- Partials       55       60       +5     
Impacted Files Coverage Δ
djangocms_versioning/__init__.py 100.00% <ø> (ø)
...s_versioning/migrations/0013_auto_20181005_1404.py 100.00% <ø> (ø)
djangocms_versioning/cms_config.py 80.90% <50.00%> (-0.87%) :arrow_down:
djangocms_versioning/emails.py 82.14% <82.14%> (ø)
djangocms_versioning/models.py 94.44% <89.47%> (-0.62%) :arrow_down:
djangocms_versioning/helpers.py 91.35% <92.30%> (-0.14%) :arrow_down:
djangocms_versioning/admin.py 90.70% <97.81%> (+1.56%) :arrow_up:
djangocms_versioning/cms_toolbars.py 96.90% <100.00%> (+0.95%) :arrow_up:
djangocms_versioning/conditions.py 98.18% <100.00%> (+1.51%) :arrow_up:
djangocms_versioning/conf.py 100.00% <100.00%> (ø)
... and 7 more
marksweb commented 1 year ago

Ok so my first thing here was to try to install this to see it in action but it's broken version locking. I'll see if I can look into that today and continue with just looking at the code;

  File "/Users/mwalker/Sites/consoles/.env/lib/python3.9/site-packages/cms/app_registration.py", line 93, in autodiscover_cms_configs
    app_config.cms_extension = extension()
  File "/Users/mwalker/Sites/consoles/.env/src/djangocms-version-locking/djangocms_version_locking/cms_config.py", line 10, in __init__
    from .monkeypatch import admin as monkeypatch_admin  # noqa: F401
  File "/Users/mwalker/Sites/consoles/.env/src/djangocms-version-locking/djangocms_version_locking/monkeypatch/admin.py", line 148, in <module>
    admin.VersionAdmin.get_state_actions = get_state_actions(admin.VersionAdmin.get_state_actions)
AttributeError: type object 'VersionAdmin' has no attribute 'get_state_actions'
fsbraun commented 1 year ago

That actually was to be expected 😬. For version locking and moderation, I believe we need to extend versioning's CMS config and get rid of the monkey patching. This can be a next step, or, we do it in one step and make this a draft for now.

Alternatively, I can imagine a compatibility hook for version locking.

Another step would then be to include version locking in versioning, since we do not have access to the repo.

fsbraun commented 1 year ago

Just added ruff as linter link just as in #329