-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
fix: Detect page when getting toolbar for endpoint (#8137) #8138
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
Conversation
Reviewer's Guide by SourceryThis pull request backports a fix to properly detect the page when obtaining the toolbar for an endpoint. The changes revolve around enhancing the logic for identifying the correct page from the request or the attached object, particularly handling instances where the attached object is of type PageContent, and adding tests to ensure the toolbar renders the page menu correctly. Minor formatting changes (e.g., switching from single to double quotes) were also applied in test files. Sequence diagram for detecting page in toolbar retrievalsequenceDiagram
participant Req as request
participant Settings as get_toolbar()
participant PC_Check as PageContent check
participant PageProvider as get_page_from_request()
Req->>Settings: Call get_toolbar(request)
Settings->>Settings: Extract cms_path and origin_url
Settings->>PC_Check: Check if attached_obj is instance of PageContent
alt attached_obj is PageContent
PC_Check-->>Settings: True, return attached_obj.page
else not PageContent
Settings->>PageProvider: get_page_from_request(request, origin_url.path)
PageProvider-->>Settings: Return current_page
end
Settings->>Req: Continue processing with current_page
Sequence diagram for admin form cleaning with PageContentsequenceDiagram
participant Req as Request
participant Form as clean()
participant TypeCheck as ModelClass check
participant AdminMgr as admin_manager
participant DefaultGetter as model_class.objects
Req->>Form: Call clean() with obj_id
Form->>TypeCheck: Check if model_class is subclass of PageContent
alt model_class is PageContent
TypeCheck-->>Form: Yes
Form->>AdminMgr: Use admin_manager.select_related("page").get(pk=obj_id)
AdminMgr-->>Form: Return generic_obj
else if admin_manager exists
TypeCheck-->>Form: No, but admin_manager exists
Form->>AdminMgr: Use admin_manager.get(pk=obj_id)
AdminMgr-->>Form: Return generic_obj
else
TypeCheck-->>Form: No admin_manager
Form->>DefaultGetter: Call objects.get(pk=obj_id)
DefaultGetter-->>Form: Return generic_obj
end
Form->>Req: Return generic_obj
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
👋 Hi there! Please remember to MERGE COMMIT pull requests from Do not SQUASH commits to preserve history for the changelog. |
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 adding a comment to explain why the
attached_obj
check was removed incms/admin/settingsadmin.py
.
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.
Description
Backport of #8137
Related resources
Checklist
develop-4
Summary by Sourcery
Bug Fixes: