diff options
author | 2020-07-14 15:48:34 +0200 | |
---|---|---|
committer | 2020-07-14 15:48:34 +0200 | |
commit | ee743f622dd0ba6f8c0b9801b1db1d85d60fa697 (patch) | |
tree | 09e66d2d24f26b46f86349a0816ef3440e6ff360 /pydis_site/apps/api/models | |
parent | Add a mixin for adding created and updated times. (diff) |
Add the AllowList model and serializer.
This is the model which we will use for items that are either
blacklisted or whitelisted.
https://github.com/python-discord/site/issues/305
Diffstat (limited to 'pydis_site/apps/api/models')
-rw-r--r-- | pydis_site/apps/api/models/__init__.py | 1 | ||||
-rw-r--r-- | pydis_site/apps/api/models/bot/__init__.py | 1 | ||||
-rw-r--r-- | pydis_site/apps/api/models/bot/allowlist.py | 28 |
3 files changed, 30 insertions, 0 deletions
diff --git a/pydis_site/apps/api/models/__init__.py b/pydis_site/apps/api/models/__init__.py index 1c9e1d07..04d0fc50 100644 --- a/pydis_site/apps/api/models/__init__.py +++ b/pydis_site/apps/api/models/__init__.py @@ -1,5 +1,6 @@ # flake8: noqa from .bot import ( + AllowList, BotSetting, DocumentationLink, DeletedMessage, diff --git a/pydis_site/apps/api/models/bot/__init__.py b/pydis_site/apps/api/models/bot/__init__.py index 8ae47746..b373ee84 100644 --- a/pydis_site/apps/api/models/bot/__init__.py +++ b/pydis_site/apps/api/models/bot/__init__.py @@ -1,4 +1,5 @@ # flake8: noqa +from .allowlist import AllowList from .bot_setting import BotSetting from .deleted_message import DeletedMessage from .documentation_link import DocumentationLink diff --git a/pydis_site/apps/api/models/bot/allowlist.py b/pydis_site/apps/api/models/bot/allowlist.py new file mode 100644 index 00000000..c8fa2e33 --- /dev/null +++ b/pydis_site/apps/api/models/bot/allowlist.py @@ -0,0 +1,28 @@ +from django.db import models + +from pydis_site.apps.api.models import ModelReprMixin, ModelTimestampMixin + + +class AllowList(ModelTimestampMixin, ModelReprMixin, models.Model): + """An item that is either allowed or denied.""" + + AllowListType = models.TextChoices( + 'guild_invite_id', + 'file_format', + 'domain_name', + 'word_watchlist', + ) + type = models.CharField( + max_length=50, + help_text=( + "The type of allowlist this is on. The value must be one of the following: " + f"{','.join(AllowListType.choices)}." + ), + choices=AllowListType.choices, + ) + allowed = models.BooleanField( + help_text="Whether this item is on the allowlist or the denylist." + ) + content = models.TextField( + help_text="The data to add to the allowlist." + ) |