From 8de7f98a0fa83d6f4ee9cc34bdbb5d3489fb2dc6 Mon Sep 17 00:00:00 2001 From: ybkang1108 Date: Tue, 13 Aug 2024 01:07:47 +0900 Subject: [PATCH 1/5] =?UTF-8?q?fix:=20=EB=B6=88=ED=95=84=EC=9A=94=ED=95=9C?= =?UTF-8?q?=20=EC=BB=A4=EB=B0=8B=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- accounts/views.py | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/accounts/views.py b/accounts/views.py index c43c3e1..0b10ad8 100644 --- a/accounts/views.py +++ b/accounts/views.py @@ -7,15 +7,12 @@ from rest_framework.response import Response from rest_framework.decorators import api_view from django.contrib.auth.hashers import check_password -from rest_framework.permissions import IsAuthenticated, AllowAny +from rest_framework.permissions import AllowAny from rest_framework.decorators import permission_classes from friends.models import Friend, FriendRequest from .models import User -# 테스트용 -from rest_framework import viewsets - @permission_classes([AllowAny]) class RegisterView(APIView): @@ -114,15 +111,6 @@ def delete(self, request): return response -# jwt 토근 인증 확인용 뷰셋 -# Header - Authorization : Bearer <발급받은토큰> -class UserViewSet(viewsets.ModelViewSet): - permission_classes = [IsAuthenticated] - queryset = User.objects.all() - serializer_class = UserSerializer - - -@permission_classes([IsAuthenticated]) class DeleteUserView(APIView): # 회원삭제 def delete(self, request): @@ -146,8 +134,6 @@ def delete(self, request): @api_view(["GET", "PATCH"]) -# @authentication_classes([TokenAuthentication]) -# @permission_classes([IsAuthenticated]) def profile(request): user = User.objects.get(id=21) # 임시 유저 지정 # user = request.user From a4c2b318aa9c2569fa3afb02197d9f27bdad95ea Mon Sep 17 00:00:00 2001 From: ybkang1108 Date: Tue, 13 Aug 2024 01:15:55 +0900 Subject: [PATCH 2/5] =?UTF-8?q?fix:=20=EB=B6=88=ED=95=84=EC=9A=94=ED=95=9C?= =?UTF-8?q?=20=EB=8D=B0=EC=BD=94=EB=A0=88=EC=9D=B4=ED=84=B0=20=EC=A0=9C?= =?UTF-8?q?=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- friends/views.py | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/friends/views.py b/friends/views.py index adfc53e..c9a7f4b 100644 --- a/friends/views.py +++ b/friends/views.py @@ -1,13 +1,9 @@ # from django.shortcuts import render from rest_framework.decorators import api_view -# from rest_framework.authentication import TokenAuthentication -from rest_framework.permissions import IsAuthenticated -from rest_framework.decorators import permission_classes from rest_framework.response import Response from rest_framework import status -# from django.contrib.auth.decorators import login_required from restaurants.models import UserRestaurantsList, Restaurant from .serializers import ( UserSerializer, @@ -17,11 +13,9 @@ FriendRecommendSerializer, ) -# from .serializers import FriendSerializer, FriendRequestSerializer from accounts.models import User from .models import Friend, FriendRequest -# from django.views.decorators.csrf import csrf_exempt from django.db.models import Count, Q import random @@ -29,8 +23,6 @@ @api_view(["GET", "POST"]) -# @authentication_classes([TokenAuthentication]) -@permission_classes([IsAuthenticated]) def friend_restaurant_list(request, pk): try: friend = User.objects.get(pk=pk) @@ -76,8 +68,6 @@ def friend_restaurant_list(request, pk): @api_view(["GET", "POST", "DELETE"]) -# @authentication_classes([TokenAuthentication]) -@permission_classes([IsAuthenticated]) def friends(request): # friends_list if request.method == "GET": @@ -279,8 +269,6 @@ def friends(request): @api_view(["GET"]) -# @authentication_classes([TokenAuthentication]) -@permission_classes([IsAuthenticated]) def friend_recommend(request): try: # user = request.user From 173a7f0753ed72720aa5bf8d4326fd4df78d5460 Mon Sep 17 00:00:00 2001 From: ybkang1108 Date: Tue, 13 Aug 2024 01:18:02 +0900 Subject: [PATCH 3/5] =?UTF-8?q?fix:=20=EB=94=94=ED=8F=B4=ED=8A=B8=20?= =?UTF-8?q?=EC=9D=B8=EC=A6=9D=20=EB=B0=A9=EC=8B=9D=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mustgou/settings.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/mustgou/settings.py b/mustgou/settings.py index 9fbdf02..13dbb63 100644 --- a/mustgou/settings.py +++ b/mustgou/settings.py @@ -118,9 +118,9 @@ REST_FRAMEWORK = { - # "DEFAULT_AUTHENTICATION_CLASSES": [ - # "rest_framework_simplejwt.authentication.JWTAuthentication", - # ], + "DEFAULT_AUTHENTICATION_CLASSES": [ + "rest_framework_simplejwt.authentication.JWTAuthentication", + ], "DEFAULT_PERMISSION_CLASSES": ("rest_framework.permissions.IsAuthenticated",), } @@ -129,8 +129,8 @@ "JWT_SECRET_KEY": SECRET_KEY, "JWT_ALGORITHM": "HS256", "JWT_ALLOW_REFRESH": True, - "JWT_EXPIRATION_DELTA": datetime.timedelta(days=7), - "JWT_REFRESH_EXPIRATION_DELTA": datetime.timedelta(days=28), + "JWT_EXPIRATION_DELTA": datetime.timedelta(days=365), + "JWT_REFRESH_EXPIRATION_DELTA": datetime.timedelta(days=730), } From 8a0cae5c37e1653e348323be04747399ed30a035 Mon Sep 17 00:00:00 2001 From: dkfla Date: Tue, 13 Aug 2024 14:50:39 +0900 Subject: [PATCH 4/5] =?UTF-8?q?fix:=20=EB=B6=88=ED=95=84=EC=9A=94=ED=95=9C?= =?UTF-8?q?=20=EB=8D=B0=EC=BD=94=EB=A0=88=EC=9D=B4=ED=84=B0=20=EC=A0=9C?= =?UTF-8?q?=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- accounts/views.py | 1 + friends/views.py | 6 ------ restaurants/views.py | 17 ----------------- reviews/views.py | 11 ----------- 4 files changed, 1 insertion(+), 34 deletions(-) diff --git a/accounts/views.py b/accounts/views.py index 0b10ad8..88e5326 100644 --- a/accounts/views.py +++ b/accounts/views.py @@ -134,6 +134,7 @@ def delete(self, request): @api_view(["GET", "PATCH"]) +@permission_classes([AllowAny]) def profile(request): user = User.objects.get(id=21) # 임시 유저 지정 # user = request.user diff --git a/friends/views.py b/friends/views.py index c9a7f4b..9d0ea34 100644 --- a/friends/views.py +++ b/friends/views.py @@ -1,9 +1,6 @@ -# from django.shortcuts import render from rest_framework.decorators import api_view - from rest_framework.response import Response from rest_framework import status - from restaurants.models import UserRestaurantsList, Restaurant from .serializers import ( UserSerializer, @@ -12,13 +9,10 @@ RestaurantlistSerializer, FriendRecommendSerializer, ) - from accounts.models import User from .models import Friend, FriendRequest - from django.db.models import Count, Q import random - from django.shortcuts import get_object_or_404 diff --git a/restaurants/views.py b/restaurants/views.py index 1446944..aeb4d0b 100644 --- a/restaurants/views.py +++ b/restaurants/views.py @@ -1,4 +1,3 @@ -# from django.shortcuts import render from rest_framework.decorators import api_view from rest_framework.response import Response from rest_framework import status @@ -10,18 +9,12 @@ RestaurantlistSerializer, RestaurantDetailSerializer, ) - -# from rest_framework.authentication import TokenAuthentication -from rest_framework.decorators import permission_classes -from rest_framework.permissions import IsAuthenticated -from django.views.decorators.csrf import csrf_exempt import logging from accounts.models import User # 임시 유저 지정을 위한 임포트, 추후 삭제 from django.db.models import Q, Subquery, OuterRef from django.utils import timezone -@csrf_exempt @api_view(["GET"]) def restaurant_list(request): restaurants = Restaurant.objects.all() @@ -30,8 +23,6 @@ def restaurant_list(request): @api_view(["GET", "POST", "DELETE"]) -# @authentication_classes([TokenAuthentication]) -@permission_classes([IsAuthenticated]) def search(request): user = User.objects.get(id=21) # 임시 유저 지정, 추후 삭제 if request.method == "GET": @@ -100,10 +91,7 @@ def search(request): ) -@csrf_exempt @api_view(["GET"]) -# @authentication_classes([TokenAuthentication]) -@permission_classes([IsAuthenticated]) def user_restaurant_list(request): try: user = User.objects.get(id=21) # 임시 유저 지정, 추후 삭제 @@ -119,10 +107,7 @@ def user_restaurant_list(request): ) -@csrf_exempt @api_view(["POST", "DELETE"]) -# @authentication_classes([TokenAuthentication]) -@permission_classes([IsAuthenticated]) def add_remove_restaurant(request, pk): user = User.objects.get(id=21) # 임시 유저 지정, 추후 삭제 try: @@ -159,8 +144,6 @@ def add_remove_restaurant(request, pk): @api_view(["GET"]) -# @authentication_classes([TokenAuthentication]) -@permission_classes([IsAuthenticated]) def restaurant_detail(request, pk): try: restaurant = Restaurant.objects.prefetch_related("reviews").get(pk=pk) diff --git a/reviews/views.py b/reviews/views.py index 1c8edc5..bce3cf4 100644 --- a/reviews/views.py +++ b/reviews/views.py @@ -11,18 +11,9 @@ ReplyListSerializer, ) -# from rest_framework.authentication import TokenAuthentication -# from rest_framework.permissions import IsAuthenticated - @api_view(["GET", "POST"]) -# @authentication_classes([TokenAuthentication]) -# @permission_classes([IsAuthenticated]) def review(request, pk): - """ - 한줄평 더보기 기능 (GET) - 한줄평 작성 기능 (POST) - """ if request.method == "GET": reviews = Review.objects.filter(restaurant_id=pk).order_by("-date") serializer = ReviewListSerializer(reviews, many=True) @@ -50,8 +41,6 @@ def review(request, pk): @api_view(["GET", "POST"]) -# @authentication_classes([TokenAuthentication]) -# @permission_classes([IsAuthenticated]) def reply(request, pk): if request.method == "GET": replies = Reply.objects.filter(review_id=pk).order_by("date") From 8557084220537d16bbf3a32a6c1ffc0487dd0c76 Mon Sep 17 00:00:00 2001 From: dkfla Date: Tue, 13 Aug 2024 16:00:39 +0900 Subject: [PATCH 5/5] =?UTF-8?q?fix:=20profile=20=ED=85=8C=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- accounts/views.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/accounts/views.py b/accounts/views.py index 88e5326..736a36f 100644 --- a/accounts/views.py +++ b/accounts/views.py @@ -8,7 +8,7 @@ from rest_framework.decorators import api_view from django.contrib.auth.hashers import check_password from rest_framework.permissions import AllowAny -from rest_framework.decorators import permission_classes +from rest_framework.decorators import authentication_classes, permission_classes from friends.models import Friend, FriendRequest from .models import User @@ -134,6 +134,7 @@ def delete(self, request): @api_view(["GET", "PATCH"]) +@authentication_classes([]) @permission_classes([AllowAny]) def profile(request): user = User.objects.get(id=21) # 임시 유저 지정