-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
fix: Placeholder page getter failed for unpublished pages (#8115) #8124
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
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…#8115) * Fix: Placeholder page getter fails for unpublished pages * Update cms/models/placeholdermodel.py * Update cms/models/placeholdermodel.py
Reviewer's Guide by SourceryThe placeholder page getter was failing for unpublished pages. This change fixes the issue by using the PageContent model to get the page associated with the placeholder. Sequence diagram for placeholder page gettersequenceDiagram
participant Placeholder
participant PageContent
participant Page
Placeholder->>PageContent: admin_manager.filter(placeholders=self)
PageContent->>PageContent: select_related('page')
PageContent->>Placeholder: first().page
Note over Placeholder: Returns None if no page found
Note over Placeholder: Works for both published and unpublished pages
Class diagram showing the relationship between Placeholder and Page modelsclassDiagram
class Placeholder {
+page_getter()
}
class PageContent {
+admin_manager
+placeholders
+page
}
class Page {
}
Placeholder "*" -- "1" PageContent
PageContent "*" -- "1" Page
note for Placeholder "Now uses PageContent as intermediary
to fetch associated Page"
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 @fsbraun - I've reviewed your changes - here's some feedback:
Overall Comments:
- Consider using more specific error handling instead of catching AttributeError, which could mask other potential issues. The original exceptions (DoesNotExist, MultipleObjectsReturned) were more explicit about what could go wrong.
- Since this changes error handling behavior, please add tests to verify the placeholder page getter works correctly for both published and unpublished pages.
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
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix: Placeholder page getter fails for unpublished pages
Update cms/models/placeholdermodel.py
Update cms/models/placeholdermodel.py
Description
Related resources
Checklist
develop-4
Summary by Sourcery
Bug Fixes: