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
Fix get_route_for_model for ContentTypes #3341
Conversation
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.
LGTM. Curious to know why we can't use the Django default for ContentType. Doesn't appear we do anything fancy with our ContentType view. Is their default not read-only?
There is no default REST API provided by the |
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.
- Do we need a similar fix for the
Group
model and theusers/groups/
REST URL? - Would you mind looking into how difficult it would be to fix Unable to query
content_types
via GraphQL #3300 in this same PR?
DOH. Didn't think beyond the |
Co-authored-by: Glenn Matthews <glenn.matthews@networktocode.com>
|
No worries, that can be deferred since it's a separate issue. Thanks! |
@@ -0,0 +1 @@ | |||
Fix the issue with the ContentType reverse return, i.e get_route_for_model(ContentType, api=True...). |
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.
Perhaps:
Fix the issue with the ContentType reverse return, i.e get_route_for_model(ContentType, api=True...). | |
Fixed missing `get_route_for_model()` logic for the `ContentType` and `Group` models. |
self.assertEqual(get_route_for_model(ContentType, "list", api=True), "extras-api:contenttype-list") | ||
self.assertEqual(get_route_for_model(ContentType, "detail", api=True), "extras-api:contenttype-detail") | ||
self.assertEqual(get_route_for_model(Group, "list", api=True), "users-api:group-list") | ||
self.assertEqual(get_route_for_model(Group, "detail", api=True), "users-api:group-detail") |
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.
Hmm, I suppose for the api=False
case we don't actually have viable routes for either of these models, do we? I guess it's inline with how get_route_for_model
currently works that it just tries to guess the route name, but doesn't actually verify that it's valid though. Ah well.
Closes: #3080
What's Changed
Running
get_route_for_model(ConentType, api=True...)
would yieldcontent-types-api:contenttype-list
rather than the newly created endpoint for contenttypes becauseContentType
is not a core model in nautobot (extras-api:contenttype-list
)TODO