Skip to content
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

Feature: Menu Tree REST API #4

Open
macolo opened this issue Jun 4, 2024 · 3 comments
Open

Feature: Menu Tree REST API #4

macolo opened this issue Jun 4, 2024 · 3 comments

Comments

@macolo
Copy link

macolo commented Jun 4, 2024

Some use the page tree hierarchy for menu structure, so that the site menu, for example, can be built automagically from the page tree as sometimes it is easier for editors if page tree and main menu are tightly connected.

Alternative Use Case that doesn't require knowledge of the page tree: By creating a custom Plugin called let's say "CustomMenuNodePlugin", hierarchical menus can be built in a djangocms-aliases Alias and from there exposed via the REST API.

@fsbraun
Copy link
Owner

fsbraun commented Jun 4, 2024

The page tree is available including structure. We need an additional endpoint for the menu of a page.

@fsbraun fsbraun changed the title Feature: Page Tree REST API Feature: Menu Tree REST API Jun 4, 2024
@fsbraun
Copy link
Owner

fsbraun commented Nov 19, 2024

@sourcery-ai plan

Copy link

sourcery-ai bot commented Nov 19, 2024

Objectives

  • Create a new MenuTreeSerializer to handle hierarchical menu structures
  • Implement a new REST API endpoint /api/menu/ to expose menu data
  • Add support for retrieving page-based menu structures from the CMS page tree
  • Enable serialization of custom menu plugins (like CustomMenuNodePlugin) through the API
  • Ensure menu data includes essential navigation properties (title, URL, children)
  • Support menu data retrieval for specific languages
  • Implement caching mechanism for menu structures similar to existing placeholder caching
  • Add documentation for both page-tree and custom plugin menu API usage

Setup commands

File changes

djangocms_rest/serializers/menuserializer.py

  • Create new MenuNodeSerializer class to handle individual menu nodes with properties like title, url, and children
  • Create new MenuTreeSerializer class that uses MenuNodeSerializer to build hierarchical menu structures
  • Add support for both page-based menus and custom menu plugin serialization
  • Implement caching mechanism similar to placeholder caching

djangocms_rest/views.py

  • Add new MenuTreeView class that inherits from APIView
  • Implement menu tree retrieval logic using django CMS menu system
  • Add language support and permission checks similar to existing views
  • Support both page-based menus and custom menu plugins

djangocms_rest/urls.py

  • Add new URL pattern for menu tree endpoint at <slug:language>/menu/

tests/test_menu.py

  • Create test class MenuAPITestCase inheriting from RESTTestCase
  • Add tests for menu tree structure and hierarchy
  • Add tests for menu item properties and URLs
  • Add tests for language handling and permissions
  • Add tests for custom menu plugin integration

Verify commands

  • python -m pytest tests/test_menu.py -v - ❌

This plan was automatically generated.
Please review the plan carefully and make any necessary adjustments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants