diff options
| -rw-r--r-- | api/viewsets.py | 54 | 
1 files changed, 27 insertions, 27 deletions
| diff --git a/api/viewsets.py b/api/viewsets.py index 29eb5782..4e36aa8e 100644 --- a/api/viewsets.py +++ b/api/viewsets.py @@ -12,12 +12,12 @@ from rest_framework_bulk import BulkCreateModelMixin  from .models import (      DocumentationLink, Member,      OffTopicChannelName, SnakeName, -    Tag, SnakeFact, +    SnakeFact, Tag,  )  from .serializers import (      DocumentationLinkSerializer, MemberSerializer,      OffTopicChannelNameSerializer, SnakeNameSerializer, -    TagSerializer, SnakeFactSerializer +    SnakeFactSerializer, TagSerializer,  ) @@ -174,6 +174,31 @@ class OffTopicChannelNameViewSet(DestroyModelMixin, ViewSet):          return Response(serialized.data) +class SnakeFactViewSet(ListModelMixin, GenericViewSet): +    """ +    View providing snake facts created by the Pydis community in the first code jam. + +    ## Routes +    ### GET /bot/snake-fact/<fact> +    Returns a snake fact in the database. + +    #### Response format +    >>> [ +    ...     {'fact': 'Snakes are dangerous'}, +    ...     {'fact': 'Except for Python, we all love it'} +    ... ] + +    #### Status codes +    - 200: returned on success + +    ## Authentication +    Requires an API token. +    """ + +    serializer_class = SnakeFactSerializer +    queryset = SnakeFact.objects.all() + +  class SnakeNameViewSet(ViewSet):      """      View providing snake names for the bot's snake cog from our first code jam's winners. @@ -230,31 +255,6 @@ class SnakeNameViewSet(ViewSet):          return Response({}) -class SnakeFactViewSet(RetrieveModelMixin, GenericViewSet): -    """ -    View providing snake facts created by the Pydis community in the first code jam. - -    ## Routes -    ### GET /bot/snake-fact/<fact> -    Returns a snake fact in the database. - -    #### Response format -    >>> [ -    ...     {'fact': 'Snakes are dangerous'}, -    ...     {'fact': 'Except for Python, we all love it'} -    ... ] - -    #### Status codes -    - 200: returned on success - -    ## Authentication -    Requires an API token. -    """ - -    serializer_class = SnakeFactSerializer -    queryset = SnakeFact.objects.all() - -  class TagViewSet(ModelViewSet):      """      View providing CRUD operations on tags shown by our bot. | 
