aboutsummaryrefslogtreecommitdiffstats
path: root/api/viewsets.py
diff options
context:
space:
mode:
authorGravatar Hasan-Ahmad <[email protected]>2018-10-11 16:14:34 +0100
committerGravatar Hasan-Ahmad <[email protected]>2018-10-11 16:14:34 +0100
commit2ae5f5205ec19dbc1574b6136da9479e080c6ba2 (patch)
tree9059566c30cc1e4f1496d2b750eb6cc8f0795013 /api/viewsets.py
parentUse proper keyword argument. (diff)
Added snake facts api
Diffstat (limited to 'api/viewsets.py')
-rw-r--r--api/viewsets.py29
1 files changed, 27 insertions, 2 deletions
diff --git a/api/viewsets.py b/api/viewsets.py
index e3fa219c..29eb5782 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
+ Tag, SnakeFact,
)
from .serializers import (
DocumentationLinkSerializer, MemberSerializer,
OffTopicChannelNameSerializer, SnakeNameSerializer,
- TagSerializer
+ TagSerializer, SnakeFactSerializer
)
@@ -230,6 +230,31 @@ 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.