From 34dc3ace82e50def0ce06e7a33f10bc11871f6e2 Mon Sep 17 00:00:00 2001 From: ybkang1108 Date: Thu, 15 Aug 2024 15:24:04 +0900 Subject: [PATCH 1/4] =?UTF-8?q?fix:=20=EC=98=A4=ED=83=80=20=EC=88=98?= =?UTF-8?q?=EC=A0=95=20is=5FEvaluated=20->=20is=5Fevaluated?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- friends/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/friends/views.py b/friends/views.py index 492d333..7a4cafb 100644 --- a/friends/views.py +++ b/friends/views.py @@ -55,7 +55,7 @@ def friend_restaurant_list(request, pk): { "message": "Friend evaluated successfully", "reliability": friend.reliability, - "is_Evaluated": Friend.objects.get( + "is_evaluated": Friend.objects.get( user=request.user, friend=friend ).is_evaluated, }, From 4512e4e8e2e03bf13d1565bde9a3f74405b7338c Mon Sep 17 00:00:00 2001 From: ybkang1108 Date: Thu, 15 Aug 2024 16:34:52 +0900 Subject: [PATCH 2/4] =?UTF-8?q?feat:=20=EC=9C=A0=EC=A0=80=20=EC=9D=B4?= =?UTF-8?q?=EB=AF=B8=EC=A7=80=20=EC=97=85=EB=A1=9C=EB=93=9C=20=EC=88=98?= =?UTF-8?q?=EC=A0=95=20=EC=9D=B4=EB=AF=B8=EC=A7=80=EB=A5=BC=20=EC=97=85?= =?UTF-8?q?=EB=A1=9C=EB=93=9C=ED=95=A0=20=EA=B2=BD=EC=9A=B0=20=EA=B8=B0?= =?UTF-8?q?=EC=A1=B4=20=EC=9D=B4=EB=AF=B8=EC=A7=80=EB=8A=94=20=EC=82=AD?= =?UTF-8?q?=EC=A0=9C=EB=90=98=EA=B3=A0=20=EC=83=88=EB=A1=9C=EC=9A=B4=20?= =?UTF-8?q?=EC=9D=B4=EB=AF=B8=EC=A7=80=EA=B0=80=20=EC=A0=80=EC=9E=A5?= =?UTF-8?q?=EB=90=A8=20=EC=9D=B4=EB=A6=84=EC=9D=80=20=EC=9C=A0=EC=A0=80id?= =?UTF-8?q?=20+=20jpg?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- accounts/models.py | 18 +++++++++++++++++- accounts/serializers.py | 3 +++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/accounts/models.py b/accounts/models.py index da9f3c4..75e0254 100644 --- a/accounts/models.py +++ b/accounts/models.py @@ -1,5 +1,19 @@ +import os +from django.conf import settings from django.db import models from django.contrib.auth.models import AbstractUser +from django.core.files.storage import FileSystemStorage + + +def profile_img_upload_to(instance, filename): + return f"profile_img/{instance.id}.jpg" + + +class OverwriteStorage(FileSystemStorage): + def get_aavailable_name(self, name): + if self.exists(name): + os.remove(os.path.join(settings.MEDIA_ROOT, name)) + return name class User(AbstractUser): @@ -13,7 +27,9 @@ class User(AbstractUser): ) profile_img = models.ImageField( - default="default_profile_img.jpg", upload_to="profile_img/" + default="default_profile_img.jpg", + upload_to=profile_img_upload_to, + storage=OverwriteStorage(), ) reliability = models.SmallIntegerField(default=80) diff --git a/accounts/serializers.py b/accounts/serializers.py index b9fef82..73e0218 100644 --- a/accounts/serializers.py +++ b/accounts/serializers.py @@ -52,3 +52,6 @@ class Meta: def get_friend_count(self, obj): return Friend.objects.filter(user=obj).count() + + def update(self, instance, validated_data): + return super().update(instance, validated_data) From dc1e6144ba2b666e7fa3aa132caf036eed653f5a Mon Sep 17 00:00:00 2001 From: ybkang1108 Date: Thu, 15 Aug 2024 13:46:23 +0900 Subject: [PATCH 3/4] =?UTF-8?q?feat:=20=EC=B9=9C=EA=B5=AC=20=ED=8F=89?= =?UTF-8?q?=EA=B0=80=20=ED=9B=84=20is=5Fevaluated=EA=B0=80=20true=EA=B0=80?= =?UTF-8?q?=20=EB=90=98=EB=8F=84=EB=A1=9D=20=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- friends/views.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/friends/views.py b/friends/views.py index 7a4cafb..20fb950 100644 --- a/friends/views.py +++ b/friends/views.py @@ -51,6 +51,10 @@ def friend_restaurant_list(request, pk): check_evaluation.is_evaluated = True check_evaluation.save() + check_evaluation = Friend.objects.get(user=request.user, friend=friend) + check_evaluation.is_evaluated = True + check_evaluation.save() + return Response( { "message": "Friend evaluated successfully", From fa7031446424947890a60aba761cf1c0e1d684ca Mon Sep 17 00:00:00 2001 From: ybkang1108 Date: Thu, 15 Aug 2024 16:40:07 +0900 Subject: [PATCH 4/4] =?UTF-8?q?fix:=20=EC=A4=91=EB=B3=B5=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- friends/views.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/friends/views.py b/friends/views.py index 20fb950..7a4cafb 100644 --- a/friends/views.py +++ b/friends/views.py @@ -51,10 +51,6 @@ def friend_restaurant_list(request, pk): check_evaluation.is_evaluated = True check_evaluation.save() - check_evaluation = Friend.objects.get(user=request.user, friend=friend) - check_evaluation.is_evaluated = True - check_evaluation.save() - return Response( { "message": "Friend evaluated successfully",