Skip to content

Commit cf76a7a

Browse files
committed
Merge remote-tracking branch 'origin/main' into code-review
2 parents 5b4fd59 + 8afbcec commit cf76a7a

6 files changed

Lines changed: 34 additions & 16 deletions

File tree

v2/src/config/settings/base.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,7 @@
160160

161161
REST_FRAMEWORK = {
162162
"EXCEPTION_HANDLER": "common.exceptions.custom_exception_handler",
163-
"DEFAULT_AUTHENTICATION_CLASSES": [
164-
"ctrlf_auth.authentication.CtrlfAuthentication",
165-
],
163+
"DEFAULT_AUTHENTICATION_CLASSES": [],
166164
}
167165

168166
JWT_AUTH = {

v2/src/ctrlfbe/admin.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
from ctrlfbe.models import Note
1+
from ctrlfbe.models import ContentRequest, Issue, Note, Page, PageComment, Topic
22
from django.contrib import admin
33

44
admin.site.register(Note)
5+
admin.site.register(ContentRequest)
6+
admin.site.register(Topic)
7+
admin.site.register(Page)
8+
admin.site.register(PageComment)
9+
admin.site.register(Issue)

v2/src/ctrlfbe/mixins.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from ctrlf_auth.authentication import CtrlfAuthentication
2+
3+
4+
class CtrlfAuthenticationMixin:
5+
def __init__(self):
6+
self.auth = CtrlfAuthentication()
7+
8+
def _ctrlf_authentication(self, request):
9+
self.authentication_classes = [CtrlfAuthentication]
10+
user, _ = self.auth.authenticate(request)
11+
return user

v2/src/ctrlfbe/swagger.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from ctrlfbe.serializers import (
2+
NoteCreateRequestBodySerializer,
23
NoteListQuerySerializer,
34
NoteSerializer,
45
PageSerializer,
@@ -33,6 +34,13 @@
3334
"tags": ["메인 화면"],
3435
}
3536

37+
SWAGGER_NOTE_CREATE_VIEW = {
38+
"operation_summary": "Note Create API",
39+
"operation_description": "비활성화된 Note와 이슈를 생성 합니다.",
40+
"request_body": NoteCreateRequestBodySerializer,
41+
"tags": ["메인 화면"],
42+
}
43+
3644
SWAGGER_TOPIC_DETAIL_VIEW = {
3745
"responses": {200: TopicSerializer()},
3846
"operation_summary": "Topic Detail API",

v2/src/ctrlfbe/views.py

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
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
44
from ctrlfbe.swagger import (
5+
SWAGGER_NOTE_CREATE_VIEW,
56
SWAGGER_NOTE_DETAIL_VIEW,
67
SWAGGER_NOTE_LIST_VIEW,
78
SWAGGER_PAGE_DETAIL_VIEW,
@@ -19,15 +20,13 @@
1920
from .models import CtrlfIssueStatus, Note, Page, Topic
2021
from .serializers import (
2122
IssueCreateSerializer,
22-
NoteCreateRequestBodySerializer,
2323
NoteSerializer,
2424
PageSerializer,
2525
TopicSerializer,
2626
)
2727

2828

2929
class 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

Comments
 (0)