aboutsummaryrefslogtreecommitdiffstats
path: root/pydis_site
diff options
context:
space:
mode:
authorGravatar D0rs4n <[email protected]>2021-12-09 20:53:49 +0100
committerGravatar D0rs4n <[email protected]>2021-12-18 18:02:12 +0100
commit3e8f164525bdd3a728bb7383da237feb9aacb44e (patch)
treefb86c93de377bb200d036b609f464b0fc2b574da /pydis_site
parentAdjust FilterList Representation (diff)
Adjust FilterList Schema to group settings into subcategories
- This commit patches the FilterList serializer's schema, and puts the settings into the relevant subcategories.
Diffstat (limited to 'pydis_site')
-rw-r--r--pydis_site/apps/api/serializers.py9
-rw-r--r--pydis_site/apps/api/viewsets/bot/filters.py93
2 files changed, 54 insertions, 48 deletions
diff --git a/pydis_site/apps/api/serializers.py b/pydis_site/apps/api/serializers.py
index 267cf761..89005a9b 100644
--- a/pydis_site/apps/api/serializers.py
+++ b/pydis_site/apps/api/serializers.py
@@ -269,7 +269,14 @@ class FilterListSerializer(ModelSerializer):
That does not affect how the Serializer works in general.
"""
ret = super().to_representation(instance)
- ret["settings"] = {name: getattr(instance, name) for name in SETTINGS_FIELDS}
+ schema_base = {name: getattr(instance, name) for name in BASE_SETTINGS_FIELDS}
+ schema_settings = {
+ "infraction":
+ {name: getattr(instance, name) for name in INFRACTION_FIELDS}} \
+ | {
+ "channel_scope":
+ {name: getattr(instance, name) for name in CHANNEL_SCOPE_FIELDS}}
+ ret["settings"] = schema_base | schema_settings
return ret
diff --git a/pydis_site/apps/api/viewsets/bot/filters.py b/pydis_site/apps/api/viewsets/bot/filters.py
index cbadcf2b..2b587696 100644
--- a/pydis_site/apps/api/viewsets/bot/filters.py
+++ b/pydis_site/apps/api/viewsets/bot/filters.py
@@ -52,31 +52,29 @@ class FilterListViewSet(ModelViewSet):
... },
... ...
... ],
- ... "settings": {
- ... "dm_content": None,
- ... "infraction_type": None,
- ... "infraction_reason": "",
- ... "infraction_duration": None,
- ... "ping_type": [
- ... "onduty"
- ... ],
- ... "filter_dm": True,
- ... "dm_ping_type": [
- ... "onduty"
- ... ],
- ... "delete_messages": True,
- ... "bypass_roles": [
- ... 267630620367257601
- ... ],
- ... "enabled": False,
- ... "disallowed_channels": [],
- ... "disallowed_categories": [],
- ... "allowed_channels": [],
- ... "allowed_categories": []
- ... }
- ... },
- ... ...
- ... ]
+ ... "settings": {
+ ... "ping_type": [
+ ... "onduty"
+ ... ],
+ ... "dm_ping_type": [
+ ... "onduty"
+ ... ],
+ ... "bypass_roles": [
+ ... 267630620367257601
+ ... ],
+ ... "filter_dm": True,
+ ... "infraction": {
+ ... "infraction_type": None,
+ ... "infraction_reason": "",
+ ... "infraction_duration": None,
+ ... }
+ ... "channel_scope": {
+ ... "disallowed_channels": [],
+ ... "disallowed_categories": [],
+ ... "allowed_channels": [],
+ ... "allowed_categories": []
+ ... }
+ ... }
#### Status codes
- 200: returned on success
@@ -120,28 +118,29 @@ class FilterListViewSet(ModelViewSet):
...
... ],
... "settings": {
- ... "dm_content": None,
- ... "infraction_type": None,
- ... "infraction_reason": "",
- ... "infraction_duration": None,
- ... "ping_type": [
- ... "onduty"
- ... ],
- ... "filter_dm": True,
- ... "dm_ping_type": [
- ... "onduty"
- ... ],
- ... "delete_messages": True,
- ... "bypass_roles": [
- ... 267630620367257601
- ... ],
- ... "enabled": False,
- ... "disallowed_channels": [],
- ... "disallowed_categories": [],
- ... "allowed_channels": [],
- ... "allowed_categories": []
- ... }
- ... }
+ ... "ping_type": [
+ ... "onduty"
+ ... ],
+ ... "dm_ping_type": [
+ ... "onduty"
+ ... ],
+ ... "bypass_roles": [
+ ... 267630620367257601
+ ... ],
+ ... "filter_dm": True,
+ ... "infraction": {
+ ... "infraction_type": None,
+ ... "infraction_reason": "",
+ ... "infraction_duration": None,
+ ... }
+ ... "channel_scope": {
+ ... "disallowed_channels": [],
+ ... "disallowed_categories": [],
+ ... "allowed_channels": [],
+ ... "allowed_categories": []
+ ... }
+ ... }
+ ... }
#### Status codes
- 200: returned on success