-
Notifications
You must be signed in to change notification settings - Fork 43
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
[Low Priority] View documentation #374
base: devel
Are you sure you want to change the base?
[Low Priority] View documentation #374
Conversation
9d0664c
to
a5b79cb
Compare
Quality Gate passedIssues Measures |
Where string is the name of the field under the related section in the API and URL is the URL to that object. For example, a return like: | ||
``` | ||
{ | ||
'authenticators': reverse('user-authenticators-list', kwargs={'pk': obj.pk}), |
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.
Where does obj
come from?
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.
...a return like:
...from UserViewSet.extra_related_fields
...
``` | ||
Would cause `authenticators` to be listed under the related field and the related URL will be generated from the user-authenticators-list url and should end up as something like `/api/users/:id/authenticators/`. | ||
|
||
This can be particularly useful if a feature in DAB wants to extend a view that is created by a service. In this case you can create a MixIn like `ansible_base.oauth2_provider.views/user_mixin.DABOAuth2UserViewsetMixin` which can set `extra_related_fields` and then have the view in the service extend the MixIn. |
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.
This can be particularly useful if a feature in DAB wants to extend a view that is created by a service.
As I said in #363, I don't think that's actually a good idea.
ansible_base.oauth2_provider.views/user_mixin.DABOAuth2UserViewsetMixin
/
-> .
?
and then have the view in the service extend the MixIn.
I'd prefer capitalization "Mixin"
And I also don't get it. Wouldn't the app just import a AuthenticatorViewSet
from DAB and declare that in related views when registering UserViewSet
? This thing here is really complicated and I don't see what it does that's useful.
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.
There's too much ground to cover here. Start with the basics. You have a model in the end-user app, and a related model in DAB. You want to define related endpoints of the end-user's model (User) in the DAB app. You make it sound like you're doing this in DAB, but that's not 100% true even in what you're describing here. You define a mixin and use that in the end-user's app. That needs to be spelled out in greater detail. It is defined in the end-user app, what you're describing is just a method for vendoring helper code that the end-user app can use, from DAB, when there is references between those models.
'authenticators': reverse('user-authenticators-list', kwargs={'pk': obj.pk}), | ||
} | ||
``` | ||
Would cause `authenticators` to be listed under the related field and the related URL will be generated from the user-authenticators-list url and should end up as something like `/api/users/:id/authenticators/`. |
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.
cause
authenticators
to be listed under the related field and the related URL
The language isn't super clear. I would suggest "under the related field" --> "inside of the "related" dictionary in the User model's serializer"
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.
Given these are internal project docs, it doesn't have to be perfect on the first commit.
Fixes #371
Requires #133 (needs rebase after this has merged)