aboutsummaryrefslogtreecommitdiffstats
path: root/pydis_site/apps/api/viewsets
diff options
context:
space:
mode:
authorGravatar kosayoda <[email protected]>2021-07-23 18:58:35 +0800
committerGravatar D0rs4n <[email protected]>2021-12-18 18:02:11 +0100
commitb082de6662e1b57f6831d219b44d95f93ed8a884 (patch)
tree399e94a76d334a82bbb7b3158c8740b4ab935056 /pydis_site/apps/api/viewsets
parentMigrate misc field names and help text changes. (diff)
Correct Filter-FilterList relationship.
Instead of a many-many relationship, one filterlist has multiple filters. Nested serialization is read-only by default, so not all CRUD methods are implemented yet for the FilterList viewset.
Diffstat (limited to 'pydis_site/apps/api/viewsets')
-rw-r--r--pydis_site/apps/api/viewsets/bot/filters.py64
1 files changed, 19 insertions, 45 deletions
diff --git a/pydis_site/apps/api/viewsets/bot/filters.py b/pydis_site/apps/api/viewsets/bot/filters.py
index 9553fcac..1b893f8c 100644
--- a/pydis_site/apps/api/viewsets/bot/filters.py
+++ b/pydis_site/apps/api/viewsets/bot/filters.py
@@ -20,7 +20,7 @@ from pydis_site.apps.api.serializers import ( # noqa: I101 - Preserving the fil
class FilterListViewSet(ModelViewSet):
"""
- View providing CRUD operations on lists of items allowed or denied by our bot.
+ View providing GET/DELETE on lists of items allowed or denied by our bot.
## Routes
### GET /bot/filter/filter_lists
@@ -33,8 +33,14 @@ class FilterListViewSet(ModelViewSet):
... "name": "guild_invite",
... "list_type": 1,
... "filters": [
- ... 1,
- ... 2,
+ ... {
+ ... "id": 1,
+ ... "content": "267624335836053506",
+ ... "description": "Python Discord",
+ ... "additional_field": None,
+ ... "override": 1,
+ ... "filter_list": 1
+ ... },
... ...
... ],
... "default_settings": 1
@@ -55,8 +61,14 @@ class FilterListViewSet(ModelViewSet):
... "name": "guild_invite",
... "list_type": 1,
... "filters": [
- ... 1,
- ... 2,
+ ... {
+ ... "id": 1,
+ ... "content": "267624335836053506",
+ ... "description": "Python Discord",
+ ... "additional_field": None,
+ ... "override": 1,
+ ... "filter_list": 1
+ ... },
... ...
... ],
... "default_settings": 1
@@ -66,45 +78,6 @@ class FilterListViewSet(ModelViewSet):
- 200: returned on success
- 404: returned if the id was not found.
- ### POST /bot/filter/filter_lists
- Adds a single FilterList item to the database.
-
- #### Request body
- >>> {
- ... "name": "guild_invite",
- ... "list_type": 1,
- ... "filters": [
- ... 1,
- ... 2,
- ... ...
- ... ],
- ... "default_settings": 1
- ... }
-
- #### Status codes
- - 201: returned on success
- - 400: if one of the given fields is invalid
-
- ### PATCH /bot/filter/filter_lists/<id:int>
- Updates a specific FilterList item from the database.
-
- #### Response format
- >>> {
- ... "id": 1,
- ... "name": "guild_invite",
- ... "list_type": 1,
- ... "filters": [
- ... 1,
- ... 2,
- ... ...
- ... ],
- ... "default_settings": 1
- ... }
-
- #### Status codes
- - 200: returned on success
- - 400: if one of the given fields is invalid
-
### DELETE /bot/filter/filter_lists/<id:int>
Deletes the FilterList item with the given `id`.
@@ -437,7 +410,8 @@ class FilterViewSet(ModelViewSet):
... "content": "267624335836053506",
... "description": "Python Discord",
... "additional_field": None,
- ... "override": 1
+ ... "override": 1,
+ ... "filter_list": 1
... },
... ...
... ]