aboutsummaryrefslogtreecommitdiffstats
path: root/pydis_site/apps/api/viewsets/bot
diff options
context:
space:
mode:
authorGravatar ks129 <[email protected]>2021-09-25 13:05:52 +0300
committerGravatar D0rs4n <[email protected]>2021-12-18 18:02:11 +0100
commit08a52168dd3b0a9a366f5ca68c10437b83af5cf1 (patch)
tree48ba24e7e2baf485259c3998398ccd1af39f8f8a /pydis_site/apps/api/viewsets/bot
parentRemove one-to-one relationships from filters tables (diff)
Remove old one-to-one filters relationships serializers, views and URLs
Diffstat (limited to 'pydis_site/apps/api/viewsets/bot')
-rw-r--r--pydis_site/apps/api/viewsets/bot/__init__.py6
-rw-r--r--pydis_site/apps/api/viewsets/bot/filters.py450
2 files changed, 2 insertions, 454 deletions
diff --git a/pydis_site/apps/api/viewsets/bot/__init__.py b/pydis_site/apps/api/viewsets/bot/__init__.py
index 781624bd..4649fcde 100644
--- a/pydis_site/apps/api/viewsets/bot/__init__.py
+++ b/pydis_site/apps/api/viewsets/bot/__init__.py
@@ -1,11 +1,7 @@
# flake8: noqa
from .filters import (
FilterListViewSet,
- FilterSettingsViewSet,
- FilterActionViewSet,
- FilterChannelRangeViewSet,
- FilterViewSet,
- FilterOverrideViewSet
+ FilterViewSet
)
from .bot_setting import BotSettingViewSet
from .deleted_message import DeletedMessageViewSet
diff --git a/pydis_site/apps/api/viewsets/bot/filters.py b/pydis_site/apps/api/viewsets/bot/filters.py
index 1b893f8c..5b21de26 100644
--- a/pydis_site/apps/api/viewsets/bot/filters.py
+++ b/pydis_site/apps/api/viewsets/bot/filters.py
@@ -2,19 +2,11 @@ from rest_framework.viewsets import ModelViewSet
from pydis_site.apps.api.models.bot.filters import ( # noqa: I101 - Preserving the filter order
FilterList,
- FilterSettings,
- FilterAction,
- ChannelRange,
- Filter,
- FilterOverride
+ Filter
)
from pydis_site.apps.api.serializers import ( # noqa: I101 - Preserving the filter order
FilterListSerializer,
- FilterSettingsSerializer,
- FilterActionSerializer,
- FilterChannelRangeSerializer,
FilterSerializer,
- FilterOverrideSerializer
)
@@ -90,311 +82,6 @@ class FilterListViewSet(ModelViewSet):
queryset = FilterList.objects.all()
-class FilterSettingsViewSet(ModelViewSet):
- """
- View providing CRUD operations on settings of items allowed or denied by our bot.
-
- ## Routes
- ### GET /bot/filter/filter_settings
- Returns all FilterSettings items in the database.
-
- #### Response format
- >>> [
- ... {
- ... "id": 1,
- ... "ping_type": [
- ... "onduty",
- ... ...
- ... ],
- ... "filter_dm": True,
- ... "dm_ping_type": [
- ... "onduty",
- ... ...
- ... ],
- ... "delete_messages": True,
- ... "bypass_roles": [
- ... 267630620367257601,
- ... ...
- ... ],
- ... "enabled": True,
- ... "default_action": 1,
- ... "default_range": 1
- ... },
- ... ...
- ... ]
-
- #### Status codes
- - 200: returned on success
- - 401: returned if unauthenticated
-
- ### GET /bot/filter/filter_settings/<id:int>
- Returns a specific FilterSettings item from the database.
-
- #### Response format
- >>> {
- ... "id": 1,
- ... "ping_type": [
- ... "onduty",
- ... ...
- ... ],
- ... "filter_dm": True,
- ... "dm_ping_type": [
- ... "onduty",
- ... ...
- ... ],
- ... "delete_messages": True,
- ... "bypass_roles": [
- ... 267630620367257601,
- ... ...
- ... ],
- ... "enabled": True,
- ... "default_action": 1,
- ... "default_range": 1
- ... }
-
- #### Status codes
- - 200: returned on success
- - 404: returned if the id was not found.
-
- ### POST /bot/filter/filter_settings
- Adds a single FilterSettings item to the database.
-
- #### Request body
- >>> {
- ... "ping_type": [
- ... "onduty",
- ... ...
- ... ],
- ... "filter_dm": True,
- ... "dm_ping_type": [
- ... "onduty",
- ... ...
- ... ],
- ... "delete_messages": True,
- ... "bypass_roles": [
- ... 267630620367257601,
- ... ...
- ... ],
- ... "enabled": True,
- ... "default_action": 1,
- ... "default_range": 1
- ... }
-
- #### Status codes
- - 201: returned on success
- - 400: if one of the given fields is invalid
-
- ### PATCH /bot/filter/filter_settings/<id:int>
- Updates a specific FilterSettings item from the database.
-
- #### Response format
- >>> {
- ... "id": 1,
- ... "ping_type": [
- ... "onduty",
- ... ...
- ... ],
- ... "filter_dm": True,
- ... "dm_ping_type": [
- ... "onduty",
- ... ...
- ... ],
- ... "delete_messages": True,
- ... "bypass_roles": [
- ... 267630620367257601,
- ... ...
- ... ],
- ... "enabled": True,
- ... "default_action": 1,
- ... "default_range": 1
- ... }
-
- #### Status codes
- - 200: returned on success
- - 400: if one of the given fields is invalid
-
- ### DELETE /bot/filter/filter_settings/<id:int>
- Deletes the FilterSettings item with the given `id`.
-
- #### Status codes
- - 204: returned on success
- - 404: if a tag with the given `id` does not exist
- """
-
- serializer_class = FilterSettingsSerializer
- queryset = FilterSettings.objects.all()
-
-
-class FilterActionViewSet(ModelViewSet):
- """
- View providing CRUD operations on actions taken by items allowed or denied by our bot.
-
- ## Routes
- ### GET /bot/filter/filter_action
- Returns all FilterAction items in the database.
-
- #### Response format
- >>> [
- ... {
- ... "id": 1,
- ... "dm_content": "message",
- ... "infraction_type": "Warn",
- ... "infraction_reason": "",
- ... "infraction_duration": "01 12:34:56.123456"
- ... },
- ... ...
- ... ]
-
- #### Status codes
- - 200: returned on success
- - 401: returned if unauthenticated
-
- ### GET /bot/filter/filter_action/<id:int>
- Returns a specific FilterAction item from the database.
-
- #### Response format
- >>> {
- ... "id": 1,
- ... "dm_content": "message",
- ... "infraction_type": "Warn",
- ... "infraction_reason": "",
- ... "infraction_duration": "01 12:34:56.123456"
- ... }
-
- #### Status codes
- - 200: returned on success
- - 404: returned if the id was not found.
-
- ### POST /bot/filter/filter_action
- Adds a single FilterAction item to the database.
-
- #### Request body
- >>> {
- ... "dm_content": "message",
- ... "infraction_type": "Warn",
- ... "infraction_reason": "",
- ... "infraction_duration": "01 12:34:56.123456"
- ... }
-
- #### Status codes
- - 201: returned on success
- - 400: if one of the given fields is invalid
-
- ### PATCH /bot/filter/filter_action/<id:int>
- Updates a specific FilterAction item from the database.
-
- #### Response format
- >>> {
- ... "id": 1,
- ... "dm_content": "message",
- ... "infraction_type": "Warn",
- ... "infraction_reason": "",
- ... "infraction_duration": "01 12:34:56.123456"
- ... }
-
- #### Status codes
- - 200: returned on success
- - 400: if one of the given fields is invalid
-
- ### DELETE /bot/filter/filter_action/<id:int>
- Deletes the FilterAction item with the given `id`.
-
- #### Status codes
- - 204: returned on success
- - 404: if a tag with the given `id` does not exist
- """
-
- serializer_class = FilterActionSerializer
- queryset = FilterAction.objects.all()
-
-
-class FilterChannelRangeViewSet(ModelViewSet):
- """
- View providing CRUD operations on channels targeted by items allowed or denied by our bot.
-
- ## Routes
- ### GET /bot/filter/channel_range
- Returns all ChannelRange items in the database.
-
- #### Response format
- >>> [
- ... {
- ... "id": 1,
- ... "disallowed_channels": [],
- ... "disallowed_categories": [],
- ... "allowed_channels": [],
- ... "allowed_categories": [],
- ... "default": True
- ... },
- ... ...
- ... ]
-
- #### Status codes
- - 200: returned on success
- - 401: returned if unauthenticated
-
- ### GET /bot/filter/channel_range/<id:int>
- Returns a specific ChannelRange item from the database.
-
- #### Response format
- >>> {
- ... "id": 1,
- ... "disallowed_channels": [],
- ... "disallowed_categories": [],
- ... "allowed_channels": [],
- ... "allowed_categories": [],
- ... "default": True
- ... }
-
- #### Status codes
- - 200: returned on success
- - 404: returned if the id was not found.
-
- ### POST /bot/filter/channel_range
- Adds a single ChannelRange item to the database.
-
- #### Request body
- >>> {
- ... "disallowed_channels": [],
- ... "disallowed_categories": [],
- ... "allowed_channels": [],
- ... "allowed_categories": [],
- ... "default": True
- ... }
-
- #### Status codes
- - 201: returned on success
- - 400: if one of the given fields is invalid
-
- ### PATCH /bot/filter/channel_range/<id:int>
- Updates a specific ChannelRange item from the database.
-
- #### Response format
- >>> {
- ... "id": 1,
- ... "disallowed_channels": [],
- ... "disallowed_categories": [],
- ... "allowed_channels": [],
- ... "allowed_categories": [],
- ... "default": True
- ... }
-
- #### Status codes
- - 200: returned on success
- - 400: if one of the given fields is invalid
-
- ### DELETE /bot/filter/channel_range/<id:int>
- Deletes the ChannelRange item with the given `id`.
-
- #### Status codes
- - 204: returned on success
- - 404: if a tag with the given `id` does not exist
- """
-
- serializer_class = FilterChannelRangeSerializer
- queryset = ChannelRange.objects.all()
-
-
class FilterViewSet(ModelViewSet):
"""
View providing CRUD operations on items allowed or denied by our bot.
@@ -477,138 +164,3 @@ class FilterViewSet(ModelViewSet):
serializer_class = FilterSerializer
queryset = Filter.objects.all()
-
-
-class FilterOverrideViewSet(ModelViewSet):
- """
- View providing CRUD operations setting overrides of items allowed or denied by our bot.
-
- ## Routes
- ### GET /bot/filter/filter_override
- Returns all FilterOverride items in the database.
-
- #### Response format
- >>> [
- ... {
- ... "id": 1,
- ... "ping_type": [
- ... "onduty",
- ... ...
- ... ],
- ... "filter_dm": True,
- ... "dm_ping_type": [
- ... "onduty",
- ... ...
- ... ],
- ... "delete_messages": True,
- ... "bypass_roles": [
- ... 267630620367257601,
- ... ...
- ... ],
- ... "enabled": True,
- ... "filter_action": 1,
- ... "filter_range": 1
- ... },
- ... ...
- ... ]
-
- #### Status codes
- - 200: returned on success
- - 401: returned if unauthenticated
-
- ### GET /bot/filter/filter_override/<id:int>
- Returns a specific FilterOverride item from the database.
-
- #### Response format
- >>> {
- ... "id": 1,
- ... "ping_type": [
- ... "onduty",
- ... ...
- ... ],
- ... "filter_dm": True,
- ... "dm_ping_type": [
- ... "onduty",
- ... ...
- ... ],
- ... "delete_messages": True,
- ... "bypass_roles": [
- ... 267630620367257601,
- ... ...
- ... ],
- ... "enabled": True,
- ... "filter_action": 1,
- ... "filter_range": 1
- ... }
-
- #### Status codes
- - 200: returned on success
- - 404: returned if the id was not found.
-
- ### POST /bot/filter/filter_override
- Adds a single FilterOverride item to the database.
-
- #### Request body
- >>> {
- ... "ping_type": [
- ... "onduty",
- ... ...
- ... ],
- ... "filter_dm": True,
- ... "dm_ping_type": [
- ... "onduty",
- ... ...
- ... ],
- ... "delete_messages": True,
- ... "bypass_roles": [
- ... 267630620367257601,
- ... ...
- ... ],
- ... "enabled": True,
- ... "filter_action": 1,
- ... "filter_range": 1
- ... }
-
- #### Status codes
- - 201: returned on success
- - 400: if one of the given fields is invalid
-
- ### PATCH /bot/filter/filter_override/<id:int>
- Updates a specific FilterOverride item from the database.
-
- #### Response format
- >>> {
- ... "id": 1,
- ... "ping_type": [
- ... "onduty",
- ... ...
- ... ],
- ... "filter_dm": True,
- ... "dm_ping_type": [
- ... "onduty",
- ... ...
- ... ],
- ... "delete_messages": True,
- ... "bypass_roles": [
- ... 267630620367257601,
- ... ...
- ... ],
- ... "enabled": True,
- ... "filter_action": 1,
- ... "filter_range": 1
- ... }
-
- #### Status codes
- - 200: returned on success
- - 400: if one of the given fields is invalid
-
- ### DELETE /bot/filter/filter_override/<id:int>
- Deletes the FilterOverride item with the given `id`.
-
- #### Status codes
- - 204: returned on success
- - 404: if a tag with the given `id` does not exist
- """
-
- serializer_class = FilterOverrideSerializer
- queryset = FilterOverride.objects.all()