-
Couldn't load subscription status.
- Fork 26
fix: Create alias view errored #308
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: release/2.0.x
Are you sure you want to change the base?
Conversation
Reviewer's GuideThis PR refactors alias plugin handling by adding draft-content context propagation, streamlining placeholder and plugin tree operations during alias creation, improving plugin detachment logic with accurate position and hierarchy preservation, and cleaning up unused view parameters. Sequence diagram for improved alias plugin detachmentsequenceDiagram
participant User
participant "AliasPlugin"
participant "Alias"
participant "TargetPlaceholder"
participant "SourcePlugins"
User->>AliasPlugin: Request detach_alias_plugin(plugin, language)
AliasPlugin->>Alias: get_plugins(language, show_draft_content=True)
Alias->>SourcePlugins: Return source_plugins
AliasPlugin->>TargetPlaceholder: delete_plugin(plugin)
alt SourcePlugins exist
TargetPlaceholder->>TargetPlaceholder: get_last_plugin(language)
TargetPlaceholder->>TargetPlaceholder: _shift_plugin_positions(language, start=plugin.position, offset=...)
AliasPlugin->>TargetPlaceholder: copy_plugins_to_placeholder(source_plugins, root_plugin=plugin.parent, start_positions={language: plugin.position})
end
Class diagram for updated Alias and plugin handlingclassDiagram
class Alias {
+get_placeholder(language=None, show_draft_content=False)
+get_plugins(language=None, show_draft_content=False)
}
class AliasPlugin {
+detach_alias_plugin(plugin, language)
}
class Placeholder {
+delete_plugin(plugin)
+get_last_plugin(language)
+_shift_plugin_positions(language, start, offset)
}
class CMSPlugin {
+_get_descendants_ids()
+delete()
}
AliasPlugin --> Alias : uses
AliasPlugin --> Placeholder : manipulates
Alias --> Placeholder : retrieves
Placeholder --> CMSPlugin : manages
CMSPlugin --> Placeholder : belongs to
Class diagram for updated populate logic in AliasclassDiagram
class Alias {
+populate(replaced_placeholder=None, replaced_plugin=None, plugins=None)
}
class Placeholder {
+cmsplugin_set
+_recalculate_plugin_positions(language)
}
class CMSPlugin {
+pk
+placeholder
+position
+parent
+_get_descendants_ids()
+delete()
}
Alias --> Placeholder : updates
Alias --> CMSPlugin : copies/deletes
CMSPlugin --> Placeholder : belongs to
File-Level Changes
Assessment against linked issues
Possibly linked issues
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:
- In get_plugins, the cache key only includes language but not show_draft_content, so consider incorporating draft flag into the key or invalidating the cache when draft mode changes to prevent stale plugin lists.
- In detach_alias_plugin you call get_last_plugin with plugin.language but then use the language parameter for shifting—unify these to consistently use the passed-in language.
- You commented out passing source_plugin to render_replace_response in create_alias_view; ensure the downstream handler no longer requires that argument or update its signature accordingly.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In get_plugins, the cache key only includes language but not show_draft_content, so consider incorporating draft flag into the key or invalidating the cache when draft mode changes to prevent stale plugin lists.
- In detach_alias_plugin you call get_last_plugin with plugin.language but then use the language parameter for shifting—unify these to consistently use the passed-in language.
- You commented out passing source_plugin to render_replace_response in create_alias_view; ensure the downstream handler no longer requires that argument or update its signature accordingly.
## Individual Comments
### Comment 1
<location> `djangocms_alias/models.py:196` </location>
<code_context>
return getattr(content, "placeholder", None)
- def get_plugins(self, language=None):
+ def get_plugins(self, language=None, show_draft_content=False):
if not language:
language = get_language()
</code_context>
<issue_to_address>
**issue (bug_risk):** Consider updating cache key to include show_draft_content.
The cache key should account for show_draft_content to prevent returning incorrect plugin lists when this parameter varies.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Description
Fix alias creation and detachment flows by adding draft content support, streamlining plugin population logic, and correcting the create_alias_view handler to prevent errors.
Bug Fixes:
Enhancements:
Fixes #306
Related resources
Checklist