-
Notifications
You must be signed in to change notification settings - Fork 0
refactor: 일정 만들기 주소 추가 #35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The head ref may contain hidden characters: "feat/#5-\uCF54\uC2A4\uB9CC\uB4E4\uAE30,\uC870\uD68C,\uC218\uC815,\uC0AD\uC81C"
Changes from 4 commits
61f3357
46f6392
eecf651
cbac5d7
831542c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,21 +25,18 @@ class Meta: | |
| model = ScheduleEntry | ||
| fields = '__all__' | ||
|
|
||
| class CreateCourseSerializser(serializers.ModelSerializer): | ||
| user_id = serializers.CharField(write_only=True) # 요청에서 유저 ID (id 필드) 처리 | ||
|
|
||
| class CreateCourseSerializer(serializers.ModelSerializer): | ||
| class Meta: | ||
| model = Schedule | ||
| fields = '__all__' | ||
| # [ | ||
| # 'meet_date_first', 'meet_date_second', 'meet_date_third', | ||
| # 'course_name', 'meet_place', 'latitude', 'longitude', 'user_id' | ||
| # ] | ||
| fields = '__all__' # 모든 필드 포함 | ||
|
|
||
| def create(self, validated_data): | ||
| # user_id로 User 객체 가져오기 | ||
| user_id = validated_data.pop('user_id') # 요청 데이터에서 user_id 추출 | ||
| user = get_object_or_404(CustomUser, id=user_id) # User 모델의 id 필드로 조회 | ||
| request = self.context.get('request') | ||
| if not request or not request.user: | ||
| raise serializers.ValidationError("유효한 사용자 정보를 찾을 수 없습니다.") | ||
|
|
||
| user = request.user # request.user 사용 | ||
|
|
||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 여기서 http body로 user_id로 받던거 수정했습니다! |
||
| # 일정 생성 | ||
| schedule = Schedule.objects.create(**validated_data) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -273,12 +273,12 @@ class ScheduleUpdateView(APIView): | |
| @swagger_auto_schema( | ||
| tags=["일정(코스)"], | ||
| operation_summary="일정(코스) 생성", | ||
| request_body=CreateCourseSerializser, | ||
| responses={201: CreateCourseSerializser, 400: "Validation Error"} | ||
| request_body=CreateCourseSerializer, | ||
| responses={201: CreateCourseSerializer, 400: "Validation Error"} | ||
| ) | ||
| def post(self, request, *args, **kwargs): | ||
|
|
||
| serializer = CreateCourseSerializser(data=request.data, context={'request': request}) | ||
| serializer = CreateCourseSerializer(data=request.data, context={'request': request}) | ||
|
|
||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 시리얼라이저 오타가 있길래 그것도 수정해줬어요! |
||
| if serializer.is_valid(): | ||
| serializer.save() | ||
|
|
@@ -294,12 +294,12 @@ class ScheduleDetailView(APIView): | |
| @swagger_auto_schema( | ||
| tags=["일정(코스)"], | ||
| operation_summary="일정 수정", | ||
| request_body=CreateCourseSerializser, | ||
| responses={200: CreateCourseSerializser, 400: "Validation Error"} | ||
| request_body=CreateCourseSerializer, | ||
| responses={200: CreateCourseSerializer, 400: "Validation Error"} | ||
| ) | ||
| def patch(self, request, schedule_id, *args, **kwargs): | ||
| schedule = get_object_or_404(Schedule, pk=schedule_id) | ||
| serializer = CreateCourseSerializser(schedule, data=request.data, partial=True, context={'request': request}) | ||
| serializer = CreateCourseSerializer(schedule, data=request.data, partial=True, context={'request': request}) | ||
|
|
||
| if serializer.is_valid(): | ||
| serializer.save() | ||
|
|
@@ -317,7 +317,7 @@ def patch(self, request, schedule_id, *args, **kwargs): | |
| def get(self, request, schedule_id, *args, **kwargs): | ||
| # 특정일정 상세조회 | ||
| schedule = get_object_or_404(Schedule, pk=schedule_id) | ||
| serializer = CreateCourseSerializser(schedule) | ||
| serializer = CreateCourseSerializer(schedule) | ||
|
|
||
| schedule_entry = ScheduleEntry.objects.filter(schedule=schedule_id) | ||
| entry_serializer = ScheduleEntrySerializer(schedule_entry, many=True) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -100,7 +100,7 @@ def get_secret(setting,secrets_dict = secrets): | |
|
|
||
| SIMPLE_JWT = { | ||
| 'SIGNING_KEY': 'hellomakourse', | ||
| 'ACCESS_TOKEN_LIFETIME': timedelta(hours=1), | ||
| 'ACCESS_TOKEN_LIFETIME': timedelta(days=30), | ||
| 'REFRESH_TOKEN_LIFETIME': timedelta(days=7), | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Accesstoken 기한 30일로 변경해서 개발하는데 편리하게 해줬습니다! |
||
| 'ROTATE_REFRESH_TOKENS': True, | ||
| 'BLACKLIST_AFTER_ROTATION': True, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
여기 "일정 이름을 정해주세요" 로 default값을 수정했슴다!