1- from typing import List , Optional
1+ from typing import Optional
22
3- from ctrlf_auth . authentication import CtrlfAuthentication
3+ from ctrlfbe . mixins import CtrlfAuthenticationMixin
44from ctrlfbe .swagger import (
5+ SWAGGER_NOTE_CREATE_VIEW ,
56 SWAGGER_NOTE_DETAIL_VIEW ,
67 SWAGGER_NOTE_LIST_VIEW ,
78 SWAGGER_PAGE_DETAIL_VIEW ,
1920from .models import CtrlfIssueStatus , Note , Page , Topic
2021from .serializers import (
2122 IssueCreateSerializer ,
22- NoteCreateRequestBodySerializer ,
2323 NoteSerializer ,
2424 PageSerializer ,
2525 TopicSerializer ,
2626)
2727
2828
2929class BaseContentView (APIView ):
30- authentication_classes : List [str ] = []
3130 child_model : Optional [Model ] = None
3231 many = False
3332
@@ -52,11 +51,7 @@ def get(self, request, *args, **kwargs):
5251 return Response (data = serializer .data , status = status .HTTP_200_OK )
5352
5453
55- class NoteListCreateView (APIView ):
56- authentication_classes = [
57- CtrlfAuthentication ,
58- ]
59-
54+ class NoteListCreateView (CtrlfAuthenticationMixin , APIView ):
6055 @swagger_auto_schema (** SWAGGER_NOTE_LIST_VIEW )
6156 def get (self , request ):
6257 current_cursor = int (request .query_params ["cursor" ])
@@ -68,16 +63,17 @@ def get(self, request):
6863 status = status .HTTP_200_OK ,
6964 )
7065
71- @swagger_auto_schema (request_body = NoteCreateRequestBodySerializer )
66+ @swagger_auto_schema (** SWAGGER_NOTE_CREATE_VIEW )
7267 def post (self , request , * args , ** kwargs ):
68+ ctrlf_user = self ._ctrlf_authentication (request )
7369 note_data = {
7470 "title" : request .data ["title" ],
75- "owners" : [request . user .id ],
71+ "owners" : [ctrlf_user .id ],
7672 }
7773 issue_data = {
7874 "title" : request .data ["title" ],
7975 "content" : request .data ["content" ],
80- "owner" : request . user .id ,
76+ "owner" : ctrlf_user .id ,
8177 "status" : CtrlfIssueStatus .REQUESTED ,
8278 }
8379 note_serializer = NoteSerializer (data = note_data )
0 commit comments