-
Notifications
You must be signed in to change notification settings - Fork 19
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
Add Django CMS 4 support #38
Conversation
@stefanw Thanks for this work. Looks good at first sight! I will review in more detail, but
|
@sourcery-ai review |
Reviewer's Guide by SourceryThis PR updates djangocms-transfer to be compatible with Django CMS 4.1 by refactoring the plugin import/export functionality and updating page content handling. The main changes focus on modernizing the plugin restoration process, handling many-to-many relationships, and adapting to Django CMS 4's new page content model. Class diagram for updated plugin restoration processclassDiagram
class PluginRestoration {
+restore(placeholder, language, parent)
-m2m_data: dict
-data: dict
}
class CMSPlugin {
+add_root()
+set_base_attr()
}
class Model {
+_meta: Meta
}
class Meta {
+get_fields()
}
PluginRestoration --> CMSPlugin : uses
PluginRestoration --> Model : uses
Model --> Meta : has
note for PluginRestoration "Handles plugin restoration with m2m relationships"
Class diagram for updated page content handlingclassDiagram
class PageContent {
+pk
+get_slug(language)
}
class ExportImportForm {
+cms_page: ModelChoiceField
+get_filename()
}
ExportImportForm --> PageContent : uses
note for ExportImportForm "Updated to use PageContent model"
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 @stefanw - I've reviewed your changes - here's some feedback:
Overall Comments:
- Please add tests to verify the changes, especially around plugin restoration and page content handling. This will help ensure compatibility with Django CMS 4.1 without regressions.
- Follow the conventional commits guidelines to properly document these architectural changes in the commit history.
Here's what I looked at during the review
- 🟡 General issues: 1 issue found
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟡 Complexity: 1 issue found
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
for field in fields: | ||
if field.related_model is not None and m2m_data.get(field.name): | ||
if field.many_to_many: | ||
objs = field.related_model.objects.filter( |
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: Consider adding error handling for invalid many-to-many relations
The code silently ignores invalid PKs in many-to-many relations. Consider logging or raising warnings when related objects don't exist to prevent silent data loss.
requested_pks = m2m_data[field.name]
objs = field.related_model.objects.filter(pk__in=requested_pks)
if objs.count() != len(requested_pks):
logger.warning(
f"Some {field.name} relations could not be found: "
f"requested {len(requested_pks)}, found {objs.count()}"
)
Description
This PR makes
djangocms-transfer
roughly work with Django CMS 4.1 installations.We needed import/export between different installations and this works for us.
Maybe this can be a starting point for a 4.1 compatible release.
Checklist
master
Slack to find a “pr review buddy” who is going to review my pull request.
Summary by Sourcery
Add support for Django CMS 4.1 in the djangocms-transfer package, enabling import/export functionality. Refactor methods to handle many-to-many relationships and related model fields more effectively, and simplify plugin import and export processes by removing unnecessary operations.
New Features:
Enhancements: