-
Couldn't load subscription status.
- Fork 21
chore: Clean up get_extra_menu_items methods #50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Reviewer's guide (collapsed on small PRs)Reviewer's GuideCentralize 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.pyclassDiagram
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
Flow diagram for centralized menu item URL constructionflowchart 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"]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this 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>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| @classmethod | ||
| def get_extra_plugin_menu_items(cls, request, plugin): | ||
| if plugin.plugin_type == cls.__name__: | ||
| return |
There was a problem hiding this comment.
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.
| @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 Report❌ Patch coverage is
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. 🚀 New features to boost your workflow:
|
Description
Not ready for merge yet
Related resources
Checklist
masterDiscord 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: