Skip to content

Conversation

fsbraun
Copy link
Member

@fsbraun fsbraun commented May 13, 2025

Description

This PR stops loading the versioned django CMS menu which only is needed for django CMS 4.0. It will not work with django CMS 5.1 due to use of deprecated django CMS references.

Related resources

  • #...
  • #...

Checklist

  • I have opened this pull request against master
  • I have added or modified the tests when changing logic
  • I have followed the conventional commits guidelines to add meaningful information into the changelog
  • I have read the contribution guidelines and I have joined #workgroup-pr-review on
    Slack to find a “pr review buddy” who is going to review my pull request.

Summary by Sourcery

Gate the legacy django CMS menu integration behind a feature flag to prevent loading deprecated references by default, update supported framework classifiers, and adjust tests to match the new registration behavior.

Enhancements:

  • Gate legacy CMSMenu registration behind ENABLE_MENU_REGISTRATION to disable deprecated django CMS 4.x menu by default

Build:

  • Add Django CMS 4.1 and 5.0 to supported framework classifiers in setup.py

Tests:

  • Relax status code assertion in test_handlers to accept 200 or 302
  • Remove obsolete test for core CMSMenu removal due to updated registration logic

Copy link
Contributor

sourcery-ai bot commented May 13, 2025

Reviewer's Guide

This PR removes deprecated django CMS 4.x menu integration by gating the versioned CMS menu implementation and registration behind an ENABLE_MENU_REGISTRATION flag, updates tests to remove legacy assertions and relax status code checks, and updates setup.py classifiers to include support for Django CMS 4.1 and 5.0.

Sequence Diagram: Conditional Menu Registration Logic

sequenceDiagram
    participant AppInit as "Application Initialization"
    participant conf as "djangocms_versioning.conf"
    participant menu_pool as "menus.menu_pool"
    participant OriginalCMSMenu_Class as "OriginalCMSMenu (Class Name)"
    participant CMSMenu_Versioned_Class as "CMSMenu (Versioned Class from djangocms_versioning)"

    AppInit->>conf: Check value of ENABLE_MENU_REGISTRATION
    alt conf.ENABLE_MENU_REGISTRATION is True
        AppInit->>menu_pool: menus.pop(OriginalCMSMenu.__name__)
        AppInit->>menu_pool: register_menu(CMSMenu_Versioned_Class)
        Note over menu_pool: Versioned CMSMenu from djangocms_versioning is active
    else conf.ENABLE_MENU_REGISTRATION is False
        Note over AppInit, menu_pool: OriginalCMSMenu (from django CMS core) remains active.
        Note over AppInit, menu_pool: No changes to menu_pool by djangocms_versioning's cms_menus.py.
    end
Loading

File-Level Changes

Change Details Files
Gate legacy django CMS menu code behind a feature flag
  • Wrapped imports, class definitions, and menu registration calls in cms_menus.py under ENABLE_MENU_REGISTRATION
  • Moved menu_pool.pop and menu_pool.register_menu into the conditional block
djangocms_versioning/cms_menus.py
Refactor tests to match gated menu registration
  • Removed test asserting core CMSMenu removal
  • Relaxed status code assertion in handlers test to accept both 200 and 302
tests/test_menus.py
tests/test_handlers.py
Update supported django CMS versions in package metadata
  • Added 'Framework :: Django CMS :: 4.1' and 'Framework :: Django CMS :: 5.0' classifiers
setup.py

Possibly linked issues

  • #0: PR removes the slow legacy versioned menu, addressing the performance issue described.

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

codecov bot commented May 13, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 93.67%. Comparing base (a132204) to head (466dd7a).
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #465      +/-   ##
==========================================
+ Coverage   90.55%   93.67%   +3.11%     
==========================================
  Files          72       75       +3     
  Lines        2732     2671      -61     
  Branches      322        0     -322     
==========================================
+ Hits         2474     2502      +28     
+ Misses        182      169      -13     
+ Partials       76        0      -76     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @fsbraun - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@vinitkumar vinitkumar merged commit bafc4e0 into master May 13, 2025
45 checks passed
@fsbraun fsbraun deleted the feat/djangocms-5.1-prep branch May 13, 2025 17:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants