diff options
author | 2020-07-16 13:27:08 +0200 | |
---|---|---|
committer | 2020-07-16 13:27:08 +0200 | |
commit | ce3d207a65a888e30e55448d7c902475a03906d3 (patch) | |
tree | da4c545c524dc715bf388ae2de5e4d18363dd551 /pydis_site | |
parent | Add tests for the AllowList model. (diff) |
Improve some docstrings.
https://github.com/python-discord/site/issues/305
Diffstat (limited to 'pydis_site')
-rw-r--r-- | pydis_site/apps/api/models/mixins.py | 2 | ||||
-rw-r--r-- | pydis_site/apps/api/viewsets/bot/allowlist.py | 30 |
2 files changed, 26 insertions, 6 deletions
diff --git a/pydis_site/apps/api/models/mixins.py b/pydis_site/apps/api/models/mixins.py index 942edaa1..5d75b78b 100644 --- a/pydis_site/apps/api/models/mixins.py +++ b/pydis_site/apps/api/models/mixins.py @@ -26,4 +26,6 @@ class ModelTimestampMixin(models.Model): updated_at = models.DateTimeField(auto_now=True) class Meta: + """Metaconfig for the mixin.""" + abstract = True diff --git a/pydis_site/apps/api/viewsets/bot/allowlist.py b/pydis_site/apps/api/viewsets/bot/allowlist.py index 9b907d05..7cc82ff7 100644 --- a/pydis_site/apps/api/viewsets/bot/allowlist.py +++ b/pydis_site/apps/api/viewsets/bot/allowlist.py @@ -27,27 +27,45 @@ class AllowListViewSet(ModelViewSet): #### Status codes - 200: returned on success + - 401: returned if unauthenticated + + ### GET /bot/allowlists/<id:int> + Returns a specific AllowList item from the database. + + #### Response format + >>> { + ... 'id': "2309268224", + ... 'created_at': "01-01-2020 ...", + ... 'updated_at': "01-01-2020 ...", + ... 'type': "file_format", + ... 'allowed': 'true', + ... 'content': ".jpeg", + ... } + + #### Status codes + - 200: returned on success + - 404: returned if the id was not found. ### POST /bot/allowedlists Adds a single allowedlist item to the database. #### Request body >>> { - ... 'type': str, - ... 'allowed': bool, - ... 'content': str, + ... 'type': str, + ... 'allowed': bool, + ... 'content': str, ... } #### Status codes - 201: returned on success - 400: if one of the given fields is invalid - ### DELETE /bot/allowedlists/<title:str> - Deletes the tag with the given `title`. + ### DELETE /bot/allowedlists/<id:int> + Deletes the tag with the given `id`. #### Status codes - 204: returned on success - - 404: if a tag with the given `title` does not exist + - 404: if a tag with the given `id` does not exist """ serializer_class = AllowListSerializer |