Skip to content

Conversation

@mrbazzan
Copy link
Contributor

@mrbazzan mrbazzan commented Oct 23, 2025

Description

Not ready for merge yet

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
    Discord to find a “pr review buddy” who is going to review my pull request.

Summary by Sourcery

Extract common logic for building plugin and placeholder export/import menu items into a new static helper and remove the deprecated compatibility method

Enhancements:

  • Removed the deprecated get_extra_global_plugin_menu_items method
  • Introduced a private _get_extra_menu_items helper to DRY up URL parameter encoding and menu item construction
  • Updated get_extra_plugin_menu_items and get_extra_placeholder_menu_items to delegate to the new helper

@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Oct 23, 2025

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Centralize extra menu item URL construction by introducing a static helper and refactor plugin and placeholder menu item methods to use it, removing legacy compatibility stubs.

Class diagram for refactored menu item methods in cms_plugins.py

classDiagram
    class TransferPlugin {
        +get_plugin_urls()
        +get_extra_plugin_menu_items(request, plugin)
        +get_extra_placeholder_menu_items(request, placeholder)
        +import_plugins_view(request)
        -_get_extra_menu_items(url_data, request)
    }
    TransferPlugin : static _get_extra_menu_items(url_data, request)
    TransferPlugin : classmethod get_extra_plugin_menu_items(request, plugin)
    TransferPlugin : classmethod get_extra_placeholder_menu_items(request, placeholder)
    TransferPlugin : get_plugin_urls()
    TransferPlugin : import_plugins_view(request)
    TransferPlugin --> PluginMenuItem
    TransferPlugin --> admin_reverse
    TransferPlugin --> get_language_from_request
Loading

Flow diagram for centralized menu item URL construction

flowchart TD
    A["get_extra_plugin_menu_items(request, plugin)"] --> B["_get_extra_menu_items({'plugin': plugin.pk}, request)"]
    A2["get_extra_placeholder_menu_items(request, placeholder)"] --> B2["_get_extra_menu_items({'placeholder': placeholder.pk}, request)"]
    B & B2 --> C["urlencode({language, ...url_data})"]
    C --> D["Return PluginMenuItem list"]
Loading

File-Level Changes

Change Details Files
Extract common URL building logic into a dedicated helper
  • Introduce static method _get_extra_menu_items
  • Move urlencode logic and PluginMenuItem list construction into helper
djangocms_transfer/cms_plugins.py
Simplify get_extra_plugin_menu_items to use new helper
  • Remove inline urlencode and data assembly
  • Pass minimal plugin data dict to _get_extra_menu_items
djangocms_transfer/cms_plugins.py
Simplify get_extra_placeholder_menu_items to use new helper
  • Remove inline urlencode and PluginMenuItem duplication
  • Pass minimal placeholder data dict to _get_extra_menu_items
djangocms_transfer/cms_plugins.py
Remove legacy Django CMS 3.4 compatibility stub
  • Delete get_extra_global_plugin_menu_items method
djangocms_transfer/cms_plugins.py

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
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 there - I've reviewed your changes - here's some feedback:

  • The removal of get_extra_global_plugin_menu_items drops django-cms 3.4 compatibility—consider preserving it as a deprecated alias or adding a deprecation warning so clients relying on it have time to migrate.
  • Consider renaming the url_data parameter in _get_extra_menu_items to something more descriptive like query_params for improved readability.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The removal of get_extra_global_plugin_menu_items drops django-cms 3.4 compatibility—consider preserving it as a deprecated alias or adding a deprecation warning so clients relying on it have time to migrate.
- Consider renaming the url_data parameter in _get_extra_menu_items to something more descriptive like query_params for improved readability.

## Individual Comments

### Comment 1
<location> `djangocms_transfer/cms_plugins.py:63-66` </location>
<code_context>
-
-    @classmethod
-    def get_extra_plugin_menu_items(cls, request, plugin):
-        if plugin.plugin_type == cls.__name__:
-            return
-
</code_context>

<issue_to_address>
**suggestion:** Returning None may be inconsistent with expected return type.

If a list is expected, return an empty list rather than None to maintain consistency and prevent issues for callers.

```suggestion
    @classmethod
    def get_extra_plugin_menu_items(cls, request, plugin):
        if plugin.plugin_type == cls.__name__:
            return []
```
</issue_to_address>

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.

Comment on lines +63 to +66
@classmethod
def get_extra_plugin_menu_items(cls, request, plugin):
if plugin.plugin_type == cls.__name__:
return
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion: Returning None may be inconsistent with expected return type.

If a list is expected, return an empty list rather than None to maintain consistency and prevent issues for callers.

Suggested change
@classmethod
def get_extra_plugin_menu_items(cls, request, plugin):
if plugin.plugin_type == cls.__name__:
return
@classmethod
def get_extra_plugin_menu_items(cls, request, plugin):
if plugin.plugin_type == cls.__name__:
return []

@codecov
Copy link

codecov bot commented Oct 23, 2025

Codecov Report

❌ Patch coverage is 36.36364% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 58.77%. Comparing base (56b392a) to head (909318d).

Files with missing lines Patch % Lines
djangocms_transfer/cms_plugins.py 36.36% 7 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master      #50      +/-   ##
==========================================
- Coverage   58.82%   58.77%   -0.05%     
==========================================
  Files          10       10              
  Lines         391      393       +2     
  Branches       56       56              
==========================================
+ Hits          230      231       +1     
- Misses        148      149       +1     
  Partials       13       13              

☔ 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.

@fsbraun fsbraun marked this pull request as draft October 29, 2025 07:13
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