forked from ansible/galaxy_ng
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix err 500 on listing /api/v1/namespaces with browsable api enabled (a…
…nsible#1915) * fix 500 on namespaces endpoint * add custom renderer with disabled forms for non superuser * add CustomBrowsableAPI to dev, stage and prod * LegacyRole queryset to LegacyRoleVersionsViewSet * add test_custom_browsable_format * add test_v1_role_versions * test with basic_user Issue: AAH-2733
- Loading branch information
1 parent
739f2ee
commit 9823b29
Showing
7 changed files
with
124 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Fixed server error 500 on ``/api/v1/namespaces`` if browsable api is enabled |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from rest_framework.renderers import BrowsableAPIRenderer | ||
|
||
|
||
class CustomBrowsableAPIRenderer(BrowsableAPIRenderer): | ||
"""Overrides the standard DRF Browsable API renderer.""" | ||
|
||
def show_form_for_method(self, view, method, request, obj): | ||
"""Display forms only for superuser.""" | ||
if request.user.is_superuser: | ||
return super().show_form_for_method(view, method, request, obj) | ||
return False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters