diff options
| author | 2018-10-17 19:50:23 +0000 | |
|---|---|---|
| committer | 2018-10-17 19:50:23 +0000 | |
| commit | 7b0e0ce545238bfa21f710f983b595950a636b52 (patch) | |
| tree | 66f92f9d6328e2ad4484bf412cebe3057af7056a /api/viewsets.py | |
| parent | Add `docker` tag to use proper runners. (diff) | |
| parent | Merge branch 'django' of https://gitlab.com/python-discord/projects/site into... (diff) | |
Merge branch 'snake_facts' into 'django'
Snake Facts API
See merge request python-discord/projects/site!41
Diffstat (limited to 'api/viewsets.py')
| -rw-r--r-- | api/viewsets.py | 33 | 
1 files changed, 29 insertions, 4 deletions
| diff --git a/api/viewsets.py b/api/viewsets.py index e3fa219c..22862c16 100644 --- a/api/viewsets.py +++ b/api/viewsets.py @@ -11,13 +11,13 @@ from rest_framework_bulk import BulkCreateModelMixin  from .models import (      DocumentationLink, Member, -    OffTopicChannelName, SnakeName, -    Tag +    OffTopicChannelName, SnakeFact,  +    SnakeName, Tag  )  from .serializers import (      DocumentationLinkSerializer, MemberSerializer, -    OffTopicChannelNameSerializer, SnakeNameSerializer, -    TagSerializer +    OffTopicChannelNameSerializer, SnakeFactSerializer,  +    SnakeNameSerializer, 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. | 
