Skip to content

Conversation

fsbraun
Copy link
Member

@fsbraun fsbraun commented Oct 9, 2025

Summary by Sourcery

Add a path field to the NavigationNode API response and ensure URL fields always emit an empty string instead of null, with minor serializer cleanup.

New Features:

  • Expose a new path field in the navigation node serializer

Enhancements:

  • Default url and api_endpoint to empty strings when missing
  • Simplify get_children serializer instantiation in one line

Fixes #61

Copy link
Contributor

sourcery-ai bot commented Oct 9, 2025

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Adds a new path field to the NavigationNodeSerializer, introduces empty-string fallbacks for url and api_endpoint, and includes minor formatting and conditional-expression cleanups in the serializer.

Class diagram for updated NavigationNodeSerializer

classDiagram
    class NavigationNodeSerializer {
        +namespace: CharField (allow_null=True)
        +title: CharField
        +url: URLField (allow_null=True)
        +api_endpoint: URLField (allow_null=True)
        +path: CharField (allow_null=True)  %% newly added
        +visible: BooleanField
        +selected: BooleanField
        +attr
        +level
        +children
        +get_children(obj: NavigationNode) list[dict]
        +to_representation(obj: NavigationNode) dict
    }
Loading

File-Level Changes

Change Details Files
Added new path field to NavigationNodeSerializer
  • Declared path field in serializer definition
  • Included path key in to_representation using getattr
djangocms_rest/serializers/menus.py
Ensured url and api_endpoint always produce strings
  • Appended or "" fallback to get_absolute_frontend_url calls
djangocms_rest/serializers/menus.py
Simplified serializer instantiation formatting
  • Collapsed multiline NavigationNodeSerializer constructor into a single line
djangocms_rest/serializers/menus.py
Streamlined selected flag expression
  • Condensed the selected logic into one line with combined boolean conditions
djangocms_rest/serializers/menus.py

Assessment against linked issues

Issue Objective Addressed Explanation
#61 Add a 'path' field to the menu endpoint response, following the pattern and naming from the 'pages' endpoint.
#61 Add a 'path' field to the breadcrumbs endpoint response, following the pattern and naming from the 'pages' endpoint. The PR only modifies the menu endpoint serializer (NavigationNodeSerializer) and does not make any changes to the breadcrumbs endpoint or its serializer.

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

codecov bot commented Oct 9, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.76%. Comparing base (98eaa14) to head (b937056).

Additional details and impacted files
@@           Coverage Diff           @@
##             main      #65   +/-   ##
=======================================
  Coverage   91.75%   91.76%           
=======================================
  Files          18       18           
  Lines         825      826    +1     
  Branches       89       89           
=======================================
+ Hits          757      758    +1     
  Misses         42       42           
  Partials       26       26           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a 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 and they look great!

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location> `djangocms_rest/serializers/menus.py:36` </location>
<code_context>
-            ),
+            "url": get_absolute_frontend_url(self.request, obj.url) or "",
+            "api_endpoint": get_absolute_frontend_url(self.request, getattr(obj, "api_endpoint", None)) or "",
+            "path": getattr(obj, "api_endpoint", ""),
             "visible": obj.visible,
-            "selected": obj.selected
</code_context>

<issue_to_address>
**question:** The 'path' field is set to the value of 'api_endpoint'; clarify if this is intentional.

If 'path' should refer to a different attribute, update it to use the correct property.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@fsbraun fsbraun requested a review from metaforx October 9, 2025 16:50
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

Successfully merging this pull request may close these issues.

add path field to menu and breadcrumbs endpoints

1 participant