Skip to content

Commit

Permalink
Merge pull request #84 from snypy/language-endpoint
Browse files Browse the repository at this point in the history
Allow public access to language list endpoint
  • Loading branch information
nezhar authored May 11, 2022
2 parents 8ac26b3 + ec1716a commit 0d48d34
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions snypy/snippets/rest/viewsets.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,16 @@ class LanguageViewSet(BaseModelViewSet):
serializer_class = LanguageSerializer
search_fields = ("name",)

def get_permissions(self):
"""
Allow unautheticated access to the list endpoint
"""
if self.action == "list":
return [
AllowAny(),
]
return super().get_permissions()

def get_queryset(self):
viewable_snippets = Snippet.objects.viewable().values_list("pk", flat=True)

Expand Down

0 comments on commit 0d48d34

Please sign in to comment.