aboutsummaryrefslogtreecommitdiffstats
path: root/pydis_site/apps/api/serializers.py
diff options
context:
space:
mode:
authorGravatar mbaruh <[email protected]>2022-10-08 15:44:37 +0300
committerGravatar mbaruh <[email protected]>2022-10-10 22:33:42 +0300
commitc3747b6d09ff968858eab698eb5fcffb9c3fbd1f (patch)
tree1d7b5a872d113100ff2d26166eb340ed9eb5e6b2 /pydis_site/apps/api/serializers.py
parentAllow ping arrays to be empty (diff)
Allow char fields to be blank
This is necessary allow filters to define a blank message when the default is not blank. Additionally allows bypass_roles to be empty like the other array fields
Diffstat (limited to 'pydis_site/apps/api/serializers.py')
-rw-r--r--pydis_site/apps/api/serializers.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/pydis_site/apps/api/serializers.py b/pydis_site/apps/api/serializers.py
index 7a5e76b7..a42d567b 100644
--- a/pydis_site/apps/api/serializers.py
+++ b/pydis_site/apps/api/serializers.py
@@ -151,6 +151,13 @@ ALWAYS_OPTIONAL_SETTINGS = (
'infraction_channel',
)
+ALWAYS_BLANKABLE_SETTINGS = (
+ 'dm_content',
+ 'dm_embed',
+ 'infraction_type',
+ 'infraction_reason',
+)
+
REQUIRED_FOR_FILTER_LIST_SETTINGS = (
'guild_pings',
'filter_dm',
@@ -310,7 +317,10 @@ class FilterListSerializer(ModelSerializer):
extra_kwargs = {
field: {'required': False, 'allow_null': True} for field in ALWAYS_OPTIONAL_SETTINGS
} | {
- 'infraction_reason': {'allow_blank': True, 'allow_null': True, 'required': False},
+ field: {'allow_blank': True, 'allow_null': True, 'required': False}
+ for field in ALWAYS_BLANKABLE_SETTINGS
+ } | {
+ 'bypass_roles': {'allow_empty': True},
'enabled_channels': {'allow_empty': True},
'disabled_channels': {'allow_empty': True},
'enabled_categories': {'allow_empty': True},