aboutsummaryrefslogtreecommitdiffstats
path: root/api/viewsets.py
diff options
context:
space:
mode:
authorGravatar Johannes Christ <[email protected]>2018-10-21 20:22:11 +0000
committerGravatar Johannes Christ <[email protected]>2018-10-21 20:22:11 +0000
commit0232d1a8b4a00c3e03153f0820810397effc9285 (patch)
treeed6ba70cc3801be8cc513883a532a415f4639e3a /api/viewsets.py
parentDrop extra whitespace. (diff)
parentfixed linting issues (diff)
Merge branch 'snake_idioms' into 'django'
Snake idioms API See merge request python-discord/projects/site!44
Diffstat (limited to 'api/viewsets.py')
-rw-r--r--api/viewsets.py35
1 files changed, 31 insertions, 4 deletions
diff --git a/api/viewsets.py b/api/viewsets.py
index c65cbac6..24c2aef9 100644
--- a/api/viewsets.py
+++ b/api/viewsets.py
@@ -12,12 +12,14 @@ from rest_framework_bulk import BulkCreateModelMixin
from .models import (
DocumentationLink, Member,
OffTopicChannelName, SnakeFact,
- SnakeName, Tag
+ SnakeIdiom, SnakeName,
+ Tag
)
from .serializers import (
DocumentationLinkSerializer, MemberSerializer,
OffTopicChannelNameSerializer, SnakeFactSerializer,
- SnakeNameSerializer, TagSerializer
+ SnakeIdiomSerializer, SnakeNameSerializer,
+ TagSerializer
)
@@ -179,8 +181,8 @@ 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.
+ ### GET /bot/snake-facts
+ Returns snake facts from the database.
#### Response format
>>> [
@@ -199,6 +201,31 @@ class SnakeFactViewSet(ListModelMixin, GenericViewSet):
queryset = SnakeFact.objects.all()
+class SnakeIdiomViewSet(ListModelMixin, GenericViewSet):
+ """
+ View providing for the snake cog.
+
+ ## Routes
+ ### GET /bot/snake-idioms
+ Returns snake idioms from the database.
+
+ #### Response format
+ >>> [
+ ... {'idiom': 'Sneky snek'},
+ ... {'idiom': 'Snooky Snake'}
+ ... ]
+
+ #### Status codes
+ - 200: returned on success
+
+ ## Authentication
+ Requires an API token
+ """
+
+ serializer_class = SnakeIdiomSerializer
+ queryset = SnakeIdiom.objects.all()
+
+
class SnakeNameViewSet(ViewSet):
"""
View providing snake names for the bot's snake cog from our first code jam's winners.