diff options
author | 2019-07-10 11:10:49 +0200 | |
---|---|---|
committer | 2019-07-10 11:10:49 +0200 | |
commit | 0d69539cde6371e55dba8616870e6fd0df16bdeb (patch) | |
tree | 9a2cde339578df62857227ce0273fad9a17798fc /pydis_site/apps/api/viewsets | |
parent | Give a code a lint (diff) |
Removing all the snake-related stuff. The snakes cog is now handled by SeasonalBot, and no longer relies on any API endpoints.
Diffstat (limited to 'pydis_site/apps/api/viewsets')
-rw-r--r-- | pydis_site/apps/api/viewsets/__init__.py | 4 | ||||
-rw-r--r-- | pydis_site/apps/api/viewsets/bot/__init__.py | 4 | ||||
-rw-r--r-- | pydis_site/apps/api/viewsets/bot/snake_fact.py | 30 | ||||
-rw-r--r-- | pydis_site/apps/api/viewsets/bot/snake_idiom.py | 30 | ||||
-rw-r--r-- | pydis_site/apps/api/viewsets/bot/snake_name.py | 67 | ||||
-rw-r--r-- | pydis_site/apps/api/viewsets/bot/special_snake.py | 33 |
6 files changed, 0 insertions, 168 deletions
diff --git a/pydis_site/apps/api/viewsets/__init__.py b/pydis_site/apps/api/viewsets/__init__.py index 553ca2c3..224e6910 100644 --- a/pydis_site/apps/api/viewsets/__init__.py +++ b/pydis_site/apps/api/viewsets/__init__.py @@ -7,10 +7,6 @@ from .bot import ( # noqa OffTopicChannelNameViewSet, ReminderViewSet, RoleViewSet, - SnakeFactViewSet, - SnakeIdiomViewSet, - SnakeNameViewSet, - SpecialSnakeViewSet, TagViewSet, UserViewSet ) diff --git a/pydis_site/apps/api/viewsets/bot/__init__.py b/pydis_site/apps/api/viewsets/bot/__init__.py index 8e7d1290..465ba5f4 100644 --- a/pydis_site/apps/api/viewsets/bot/__init__.py +++ b/pydis_site/apps/api/viewsets/bot/__init__.py @@ -6,9 +6,5 @@ from .nomination import NominationViewSet # noqa from .off_topic_channel_name import OffTopicChannelNameViewSet # noqa from .reminder import ReminderViewSet # noqa from .role import RoleViewSet # noqa -from .snake_fact import SnakeFactViewSet # noqa -from .snake_idiom import SnakeIdiomViewSet # noqa -from .snake_name import SnakeNameViewSet # noqa -from .special_snake import SpecialSnakeViewSet # noqa from .tag import TagViewSet # noqa from .user import UserViewSet # noqa diff --git a/pydis_site/apps/api/viewsets/bot/snake_fact.py b/pydis_site/apps/api/viewsets/bot/snake_fact.py deleted file mode 100644 index 0b2e8ede..00000000 --- a/pydis_site/apps/api/viewsets/bot/snake_fact.py +++ /dev/null @@ -1,30 +0,0 @@ -from rest_framework.mixins import ListModelMixin -from rest_framework.viewsets import GenericViewSet - -from pydis_site.apps.api.models.bot.snake_fact import SnakeFact -from pydis_site.apps.api.serializers import SnakeFactSerializer - - -class SnakeFactViewSet(ListModelMixin, GenericViewSet): - """ - View providing snake facts created by the Pydis community in the first code jam. - - ## Routes - ### GET /bot/snake-facts - Returns snake facts from 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() diff --git a/pydis_site/apps/api/viewsets/bot/snake_idiom.py b/pydis_site/apps/api/viewsets/bot/snake_idiom.py deleted file mode 100644 index 9f274d2f..00000000 --- a/pydis_site/apps/api/viewsets/bot/snake_idiom.py +++ /dev/null @@ -1,30 +0,0 @@ -from rest_framework.mixins import ListModelMixin -from rest_framework.viewsets import GenericViewSet - -from pydis_site.apps.api.models.bot.snake_idiom import SnakeIdiom -from pydis_site.apps.api.serializers import SnakeIdiomSerializer - - -class SnakeIdiomViewSet(ListModelMixin, GenericViewSet): - """ - View providing snake idioms 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() diff --git a/pydis_site/apps/api/viewsets/bot/snake_name.py b/pydis_site/apps/api/viewsets/bot/snake_name.py deleted file mode 100644 index 113c6899..00000000 --- a/pydis_site/apps/api/viewsets/bot/snake_name.py +++ /dev/null @@ -1,67 +0,0 @@ -from rest_framework.response import Response -from rest_framework.viewsets import ViewSet - -from pydis_site.apps.api.models.bot.snake_name import SnakeName -from pydis_site.apps.api.serializers import SnakeNameSerializer - - -class SnakeNameViewSet(ViewSet): - """ - View providing snake names for the bot's snake cog from our first code jam's winners. - - ## Routes - ### GET /bot/snake-names - By default, return a single random snake name along with its name and scientific name. - If the `get_all` query parameter is given, for example using... - $ curl api.pythondiscord.local:8000/bot/snake-names?get_all=yes - ... then the API will return all snake names and scientific names in the database. - - #### Response format - Without `get_all` query parameter: - >>> { - ... 'name': "Python", - ... 'scientific': "Langus greatus" - ... } - - If the database is empty for whatever reason, this will return an empty dictionary. - - With `get_all` query parameter: - >>> [ - ... {'name': "Python 3", 'scientific': "Langus greatus"}, - ... {'name': "Python 2", 'scientific': "Langus decentus"} - ... ] - - #### Status codes - - 200: returned on success - - ## Authentication - Requires a API token. - """ - - serializer_class = SnakeNameSerializer - - def get_queryset(self): - """Returns a queryset that covers the entire SnakeName table.""" - return SnakeName.objects.all() - - def list(self, request): - """ - DRF method for listing SnakeName entries. - - Called by the Django Rest Framework in response to the corresponding HTTP request. - """ - if request.query_params.get('get_all'): - queryset = self.get_queryset() - serialized = self.serializer_class(queryset, many=True) - return Response(serialized.data) - - single_snake = SnakeName.objects.order_by('?').first() - if single_snake is not None: - body = { - 'name': single_snake.name, - 'scientific': single_snake.scientific - } - - return Response(body) - - return Response({}) diff --git a/pydis_site/apps/api/viewsets/bot/special_snake.py b/pydis_site/apps/api/viewsets/bot/special_snake.py deleted file mode 100644 index 446c79a1..00000000 --- a/pydis_site/apps/api/viewsets/bot/special_snake.py +++ /dev/null @@ -1,33 +0,0 @@ -from rest_framework.mixins import ListModelMixin -from rest_framework.viewsets import GenericViewSet - -from pydis_site.apps.api.models.bot import SpecialSnake -from pydis_site.apps.api.serializers import SpecialSnakeSerializer - - -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() |