filter /api/v2/users/N/tokens/ to only show tokens for _that_ user

see: https://github.com/ansible/tower/issues/1773
This commit is contained in:
Ryan Petrello
2018-05-17 13:16:48 -04:00
parent 46add35f98
commit 51f66b8c0a
3 changed files with 23 additions and 2 deletions

View File

@@ -1598,6 +1598,18 @@ class OAuth2TokenList(ListCreateAPIView):
model = OAuth2AccessToken
serializer_class = OAuth2TokenSerializer
swagger_topic = 'Authentication'
class OAuth2UserTokenList(SubListCreateAPIView):
view_name = _("OAuth2 User Tokens")
model = OAuth2AccessToken
serializer_class = OAuth2TokenSerializer
parent_model = User
relationship = 'main_oauth2accesstoken'
parent_key = 'user'
swagger_topic = 'Authentication'
class OAuth2AuthorizedTokenList(SubListCreateAPIView):