diff options
author | 2018-11-02 18:39:48 +0000 | |
---|---|---|
committer | 2018-11-02 18:39:48 +0000 | |
commit | 6c4666d36d2853a4ee8b9fd61086a1e4f1dd7776 (patch) | |
tree | 3ae797514bd5d13582075165936aaa503e38daef /api/viewsets.py | |
parent | Merge branch 'snake_idioms' into 'django' (diff) | |
parent | Added help text (diff) |
Merge branch 'special_snakes' into 'django'
Django - Special Snakes API
See merge request python-discord/projects/site!45
Diffstat (limited to 'api/viewsets.py')
-rw-r--r-- | api/viewsets.py | 42 |
1 files changed, 36 insertions, 6 deletions
diff --git a/api/viewsets.py b/api/viewsets.py index 24c2aef9..08660810 100644 --- a/api/viewsets.py +++ b/api/viewsets.py @@ -11,14 +11,16 @@ from rest_framework_bulk import BulkCreateModelMixin from .models import ( DocumentationLink, Member, - OffTopicChannelName, SnakeFact, - SnakeIdiom, SnakeName, + OffTopicChannelName, + SnakeFact, SnakeIdiom, + SnakeName, SpecialSnake, Tag ) from .serializers import ( - DocumentationLinkSerializer, MemberSerializer, - OffTopicChannelNameSerializer, SnakeFactSerializer, - SnakeIdiomSerializer, SnakeNameSerializer, + DocumentationLinkSerializer, + MemberSerializer, OffTopicChannelNameSerializer, + SnakeFactSerializer, SnakeIdiomSerializer, + SnakeNameSerializer, SpecialSnakeSerializer, TagSerializer ) @@ -203,7 +205,7 @@ class SnakeFactViewSet(ListModelMixin, GenericViewSet): class SnakeIdiomViewSet(ListModelMixin, GenericViewSet): """ - View providing for the snake cog. + View providing snake idioms for the snake cog. ## Routes ### GET /bot/snake-idioms @@ -282,6 +284,34 @@ class SnakeNameViewSet(ViewSet): return Response({}) +class SpecialSnakeViewSet(ListModelMixin, GenericViewSet): + """ + View providing special snake names for our bot's snake cog. + + ## Routes + ### GET /bot/special-snakes + Returns a list of special snake names. + + #### Response Format + >>> [ + ... { + ... 'name': 'Snakky sneakatus', + ... 'info': 'Scary snek', + ... 'image': 'https://discordapp.com/assets/53ef346458017da2062aca5c7955946b.svg' + ... } + ... ] + + #### Status codes + - 200: returned on success + + ## Authentication + Requires an API token. + """ + + serializer_class = SpecialSnakeSerializer + queryset = SpecialSnake.objects.all() + + class TagViewSet(ModelViewSet): """ View providing CRUD operations on tags shown by our bot. |