From 714ec7ffc63dc1b930d1ae80cabd964b8e48f55d Mon Sep 17 00:00:00 2001 From: Johannes Christ Date: Sun, 18 Nov 2018 22:28:02 +0100 Subject: Add viewsets and serializers. --- api/viewsets.py | 41 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 38 insertions(+), 3 deletions(-) (limited to 'api/viewsets.py') diff --git a/api/viewsets.py b/api/viewsets.py index 08660810..bc34de1d 100644 --- a/api/viewsets.py +++ b/api/viewsets.py @@ -11,20 +11,55 @@ from rest_framework_bulk import BulkCreateModelMixin from .models import ( DocumentationLink, Member, - OffTopicChannelName, + MessageDeletionContext, OffTopicChannelName, SnakeFact, SnakeIdiom, SnakeName, SpecialSnake, Tag ) from .serializers import ( - DocumentationLinkSerializer, - MemberSerializer, OffTopicChannelNameSerializer, + DocumentationLinkSerializer, MemberSerializer, + MessageDeletionContextSerializer, OffTopicChannelNameSerializer, SnakeFactSerializer, SnakeIdiomSerializer, SnakeNameSerializer, SpecialSnakeSerializer, TagSerializer ) +class DeletedMessageViewSet(GenericViewSet): + """ + View providing support for posting bulk deletion logs generated by the bot. + + ## Routes + ### POST /bot/deleted-messages + Post messages from bulk deletion logs. + + #### Body schema + >>> { + ... # The member ID of the original actor, if applicable. + ... # If a member ID is given, it must be present on the site. + ... 'actor': Optional[int] + ... 'creation': datetime, + ... 'messages': [ + ... { + ... 'id': int, + ... 'author': int, + ... 'channel_id': int, + ... 'content': str, + ... 'embeds': [ + ... # Discord embed objects + ... ] + ... } + ... ] + ... } + + #### Status codes + - 204: returned on success + """ + + queryset = MessageDeletionContext.objects.all() + serializer = MessageDeletionContextSerializer + + class DocumentationLinkViewSet( CreateModelMixin, DestroyModelMixin, ListModelMixin, RetrieveModelMixin, GenericViewSet ): -- cgit v1.2.3