From 857b66aeadf801e8038e2c3a90c61a7a05418847 Mon Sep 17 00:00:00 2001 From: dpfls0922 Date: Sun, 12 May 2024 23:34:09 +0900 Subject: [PATCH 1/9] =?UTF-8?q?[Add]=20#47=20=ED=9A=8C=EC=9B=90=ED=83=88?= =?UTF-8?q?=ED=87=B4=20url=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- users/urls.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/users/urls.py b/users/urls.py index aca08e0..1e5f4be 100644 --- a/users/urls.py +++ b/users/urls.py @@ -1,10 +1,11 @@ #users/urls.py from django.urls import path -from .views import SignUpView, LoginView, LogoutView, ProfileView +from .views import SignUpView, LoginView, LogoutView, ProfileView, DeleteAccountView urlpatterns = [ path('signup/', SignUpView.as_view()), path('login/', LoginView.as_view()), path('logout/', LogoutView.as_view()), path('profile//', ProfileView.as_view()), + path('withdraw/', DeleteAccountView.as_view()), ] \ No newline at end of file From d49a044334a4bdbf6fb921c7ca79c8e87a4aa9ec Mon Sep 17 00:00:00 2001 From: dpfls0922 Date: Sun, 12 May 2024 23:38:19 +0900 Subject: [PATCH 2/9] =?UTF-8?q?[Chore]=20#47=20=ED=83=88=ED=87=B4=ED=95=98?= =?UTF-8?q?=EB=A0=A4=EB=8A=94=20=ED=9A=8C=EC=9B=90=EC=9D=B4=20=EC=8B=A0?= =?UTF-8?q?=EA=B3=A0=ED=95=9C=20=EB=8D=B0=EC=9D=B4=ED=84=B0=EB=8A=94=20?= =?UTF-8?q?=EB=82=A8=EA=B2=A8=EB=91=90=EB=8F=84=EB=A1=9D=20=EB=A1=9C?= =?UTF-8?q?=EC=A7=81=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mypage/models.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/mypage/models.py b/mypage/models.py index c553be2..0bd0900 100644 --- a/mypage/models.py +++ b/mypage/models.py @@ -12,13 +12,19 @@ class UmbrellaReport(models.Model): ) umbrella = models.ForeignKey(Umbrella, on_delete = models.CASCADE) - user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete = models.CASCADE) + user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete = models.CASCADE, null = True) report_reason = models.CharField(max_length = 10, choices = REPORT_CHOICES) description = models.TextField(max_length = 200, blank = True, null = True) is_done = models.BooleanField(default = False) def __str__(self): - if self.is_done: - return f'[{self.user.username}] 우산{self.umbrella.number} {self.report_reason} - 해결완료(O)' + if self.user: + if self.is_done: + return f'[{self.user.username}] 우산{self.umbrella.number} {self.report_reason} - 해결완료(O)' + else: + return f'[{self.user.username}] 우산{self.umbrella.number} {self.report_reason} - 해결안됨(X)' else: - return f'[{self.user.username}] 우산{self.umbrella.number} {self.report_reason} - 해결안됨(X)' \ No newline at end of file + if self.is_done: + return f'[탈퇴한 회원] 우산{self.umbrella.number} {self.report_reason} - 해결완료(O)' + else: + return f'[탈퇴한 회원] 우산{self.umbrella.number} {self.report_reason} - 해결안됨(X)' \ No newline at end of file From 17c0a45a5f80bfe1ea1ea809ad4f477393bd47b0 Mon Sep 17 00:00:00 2001 From: dpfls0922 Date: Sun, 12 May 2024 23:40:49 +0900 Subject: [PATCH 3/9] =?UTF-8?q?[Chore]=20#47=20=ED=9A=8C=EC=9B=90=ED=83=88?= =?UTF-8?q?=ED=87=B4=20url=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- users/urls.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/users/urls.py b/users/urls.py index 1e5f4be..666bd78 100644 --- a/users/urls.py +++ b/users/urls.py @@ -7,5 +7,5 @@ path('login/', LoginView.as_view()), path('logout/', LogoutView.as_view()), path('profile//', ProfileView.as_view()), - path('withdraw/', DeleteAccountView.as_view()), + path('withdrawal/', DeleteAccountView.as_view()), ] \ No newline at end of file From f749b86ad3b97175a3f1bf34b098fa9dae1f73b6 Mon Sep 17 00:00:00 2001 From: dpfls0922 Date: Sun, 12 May 2024 23:50:18 +0900 Subject: [PATCH 4/9] =?UTF-8?q?[Add]=20#47=20=ED=9A=8C=EC=9B=90=ED=83=88?= =?UTF-8?q?=ED=87=B4=20=EA=B8=B0=EB=A1=9D=20=EB=AA=A8=EB=8D=B8=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../0004_alter_umbrellareport_user.py | 21 +++++++++++++++ .../0004_alter_rent_return_due_date.py | 19 ++++++++++++++ .../0005_alter_rent_return_due_date.py | 19 ++++++++++++++ users/migrations/0003_withdrawalrecord.py | 26 +++++++++++++++++++ users/models.py | 22 ++++++++++++++-- 5 files changed, 105 insertions(+), 2 deletions(-) create mode 100644 mypage/migrations/0004_alter_umbrellareport_user.py create mode 100644 umbrella/migrations/0004_alter_rent_return_due_date.py create mode 100644 umbrella/migrations/0005_alter_rent_return_due_date.py create mode 100644 users/migrations/0003_withdrawalrecord.py diff --git a/mypage/migrations/0004_alter_umbrellareport_user.py b/mypage/migrations/0004_alter_umbrellareport_user.py new file mode 100644 index 0000000..2da0425 --- /dev/null +++ b/mypage/migrations/0004_alter_umbrellareport_user.py @@ -0,0 +1,21 @@ +# Generated by Django 5.0.1 on 2024-05-12 23:42 + +import django.db.models.deletion +from django.conf import settings +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('mypage', '0003_initial'), + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ] + + operations = [ + migrations.AlterField( + model_name='umbrellareport', + name='user', + field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL), + ), + ] diff --git a/umbrella/migrations/0004_alter_rent_return_due_date.py b/umbrella/migrations/0004_alter_rent_return_due_date.py new file mode 100644 index 0000000..6a9de95 --- /dev/null +++ b/umbrella/migrations/0004_alter_rent_return_due_date.py @@ -0,0 +1,19 @@ +# Generated by Django 5.0.1 on 2024-04-22 22:12 + +import datetime +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('umbrella', '0003_alter_rent_return_due_date'), + ] + + operations = [ + migrations.AlterField( + model_name='rent', + name='return_due_date', + field=models.DateTimeField(default=datetime.datetime(2024, 4, 25, 22, 12, 37, 10220)), + ), + ] diff --git a/umbrella/migrations/0005_alter_rent_return_due_date.py b/umbrella/migrations/0005_alter_rent_return_due_date.py new file mode 100644 index 0000000..2e25bc3 --- /dev/null +++ b/umbrella/migrations/0005_alter_rent_return_due_date.py @@ -0,0 +1,19 @@ +# Generated by Django 5.0.1 on 2024-05-12 23:42 + +import datetime +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('umbrella', '0004_alter_rent_return_due_date'), + ] + + operations = [ + migrations.AlterField( + model_name='rent', + name='return_due_date', + field=models.DateTimeField(default=datetime.datetime(2024, 5, 15, 23, 42, 54, 658653)), + ), + ] diff --git a/users/migrations/0003_withdrawalrecord.py b/users/migrations/0003_withdrawalrecord.py new file mode 100644 index 0000000..eb68874 --- /dev/null +++ b/users/migrations/0003_withdrawalrecord.py @@ -0,0 +1,26 @@ +# Generated by Django 5.0.1 on 2024-05-12 23:42 + +import datetime +import django.utils.timezone +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('users', '0002_profile_fcm_token'), + ] + + operations = [ + migrations.CreateModel( + name='WithdrawalRecord', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('studentID', models.IntegerField(default=0, unique=True)), + ('withdrawal_reason', models.CharField(choices=[('수량', '우산 수량이 적어서 사용을 잘 안해요.'), ('관리', '우산 관리가 잘 안되어 사용할 수 없어요.'), ('새계정', '새 계정을 만들고 싶어요.'), ('기타', '기타사항 (직접 입력)')], max_length=10)), + ('description', models.TextField(blank=True, max_length=200, null=True)), + ('withdrawal_date', models.DateTimeField(default=django.utils.timezone.now)), + ('expiration_date', models.DateTimeField(default=datetime.datetime(2024, 5, 19, 23, 42, 54, 660042))), + ], + ), + ] diff --git a/users/models.py b/users/models.py index 2b1f1c1..588f9c2 100644 --- a/users/models.py +++ b/users/models.py @@ -3,7 +3,7 @@ from umbrella.models import Umbrella from django.contrib.auth.models import AbstractUser from django.conf import settings - +from django.utils import timezone class CustomUser(AbstractUser): username = models.CharField(max_length = 10, unique = False) @@ -22,4 +22,22 @@ class Profile(models.Model): studentCard = models.ImageField(upload_to = f'profile') phoneNumber = models.CharField(max_length = 20) umbrella = models.OneToOneField(Umbrella, related_name = 'user', null = True, blank = True, on_delete = models.SET_NULL) - fcm_token = models.CharField(max_length = 200, blank = True, null = True) \ No newline at end of file + fcm_token = models.CharField(max_length = 200, blank = True, null = True) + + +class WithdrawalRecord(models.Model): + REPORT_CHOICES = ( + ('수량', '우산 수량이 적어서 사용을 잘 안해요.'), + ('관리', '우산 관리가 잘 안되어 사용할 수 없어요.'), + ('새계정', '새 계정을 만들고 싶어요.'), + ('기타', '기타사항 (직접 입력)'), + ) + + studentID = models.IntegerField(default = 0, unique = True) + withdrawal_reason = models.CharField(max_length = 10, choices = REPORT_CHOICES) + description = models.TextField(max_length = 200, blank = True, null = True) + withdrawal_date = models.DateTimeField(default = timezone.now) + expiration_date = models.DateTimeField(default = lambda: timezone.now() + timezone.timedelta(days = 7)) # 만료 일자 + + def __str__(self): + return f'[{self.studentID}] {self.withdrawal_reason}' \ No newline at end of file From 1e4e4e0d4404674091cde6e8015f5a98c12a62c5 Mon Sep 17 00:00:00 2001 From: dpfls0922 Date: Sun, 12 May 2024 23:51:22 +0900 Subject: [PATCH 5/9] =?UTF-8?q?[Feat]=20#47=20=ED=9A=8C=EC=9B=90=ED=83=88?= =?UTF-8?q?=ED=87=B4=20=EA=B8=B0=EB=A1=9D=20=EB=AA=A8=EB=8D=B8=20=EC=8B=9C?= =?UTF-8?q?=EB=A6=AC=EC=96=BC=EB=9D=BC=EC=9D=B4=EC=A0=80=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- users/serializers.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/users/serializers.py b/users/serializers.py index d0fcc78..6ca6ce1 100644 --- a/users/serializers.py +++ b/users/serializers.py @@ -7,7 +7,7 @@ from django.contrib.auth import authenticate # DefautlAuthBackend인 TokenAuth 방식으로 유저 인증 from django.contrib.auth.models import update_last_login -from .models import Profile, CustomUser +from .models import Profile, CustomUser, WithdrawalRecord # 회원가입 class SignUpProfileSerializer(serializers.ModelSerializer): @@ -136,4 +136,12 @@ def update(self, instance, validated_data): if profile_data: profile.phoneNumber = profile_data.get('phoneNumber', profile.phoneNumber) profile.save() - return instance \ No newline at end of file + return instance + + + +# 회원탈퇴 +class RecordSerializer(serializers.ModelSerializer): + class Meta: + model = WithdrawalRecord + fields = ('studentID', 'withdrawal_reason', 'description', 'withdrawal_date') \ No newline at end of file From 500ba2e2de7b1ff4132453cbf41732b386090ce5 Mon Sep 17 00:00:00 2001 From: dpfls0922 Date: Sun, 12 May 2024 23:52:30 +0900 Subject: [PATCH 6/9] =?UTF-8?q?[Add]=20#47=20=ED=9A=8C=EC=9B=90=ED=83=88?= =?UTF-8?q?=ED=87=B4=20=EA=B8=B0=EB=A1=9D=20=EA=B4=80=EB=A6=AC=EC=9E=90=20?= =?UTF-8?q?=ED=8E=98=EC=9D=B4=EC=A7=80=EC=97=90=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- users/admin.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/users/admin.py b/users/admin.py index f86626c..9311ed3 100644 --- a/users/admin.py +++ b/users/admin.py @@ -1,7 +1,7 @@ #users/admin.py from django.contrib import admin from django.contrib.auth.admin import UserAdmin as BaseUserAdmin -from .models import CustomUser, Profile +from .models import CustomUser, Profile, WithdrawalRecord class ProfileInline(admin.StackedInline): model = Profile @@ -11,4 +11,5 @@ class ProfileInline(admin.StackedInline): class CustomUserAdmin(BaseUserAdmin): inlines = (ProfileInline, ) -admin.site.register(CustomUser, CustomUserAdmin) \ No newline at end of file +admin.site.register(CustomUser, CustomUserAdmin) +admin.site.register(WithdrawalRecord) \ No newline at end of file From a94266dfee2a4a6c5f0fc85ba57dc689ee0026da Mon Sep 17 00:00:00 2001 From: dpfls0922 Date: Sun, 12 May 2024 23:54:12 +0900 Subject: [PATCH 7/9] =?UTF-8?q?[Feat]=20#47=20=ED=9A=8C=EC=9B=90=ED=83=88?= =?UTF-8?q?=ED=87=B4=20=EC=82=AC=EC=9C=A0=EB=A5=BC=20=EC=9E=85=EB=A0=A5?= =?UTF-8?q?=EB=B0=9B=EC=95=84=20=EC=9D=B4=EB=A5=BC=20DB=20=EC=97=90=20?= =?UTF-8?q?=EC=A0=80=EC=9E=A5=ED=95=98=EB=8A=94=20=EB=A1=9C=EC=A7=81=20?= =?UTF-8?q?=EA=B5=AC=ED=98=84=20=EB=B0=8F=20=EB=A1=9C=EA=B9=85=20=EC=84=A4?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- UmbrellaFriend/settings.py | 5 +++ users/views.py | 62 ++++++++++++++++++++++++++++++++++++-- 2 files changed, 64 insertions(+), 3 deletions(-) diff --git a/UmbrellaFriend/settings.py b/UmbrellaFriend/settings.py index 713e75b..d33a853 100644 --- a/UmbrellaFriend/settings.py +++ b/UmbrellaFriend/settings.py @@ -215,5 +215,10 @@ 'level': 'INFO', 'propagate': False, }, + 'users.views': { + 'handlers': ['file'], + 'level': 'INFO', + 'propagate': False, + }, }, } \ No newline at end of file diff --git a/users/views.py b/users/views.py index 66917c8..6f217db 100644 --- a/users/views.py +++ b/users/views.py @@ -3,8 +3,16 @@ from rest_framework.response import Response from rest_framework.views import APIView from rest_framework.permissions import IsAuthenticated -from .serializers import SignUpSerializer, LoginSerializer, UserUpdateSerializer -from .models import CustomUser +from .serializers import SignUpSerializer, LoginSerializer, UserUpdateSerializer, RecordSerializer +from .models import CustomUser, WithdrawalRecord +from umbrella.models import Rent +from mypage.models import UmbrellaReport +import logging + + +logging.basicConfig(level=logging.ERROR) +logger = logging.getLogger(__name__) + class SignUpView(generics.CreateAPIView): queryset = CustomUser.objects.all() @@ -26,6 +34,7 @@ def post(self, request): password_error = None for field, error in errors.items(): + logger.error(f"field: [{field}] error: [{error}]") if field == 'profile': if not profile_error: for sub_field, sub_error in error.items(): @@ -116,4 +125,51 @@ def put(self, request, *args, **kwargs): return Response({'status': 400, 'message': invalid_error[0], 'data': ''}, status = status.HTTP_400_BAD_REQUEST) if password_error: return Response({'status': 400, 'message': password_error[0], 'data': ''}, status = status.HTTP_400_BAD_REQUEST) - return Response({'status': 400, 'message': '유효하지 않은 데이터입니다.', 'data': ''}, status=status.HTTP_400_BAD_REQUEST) \ No newline at end of file + return Response({'status': 400, 'message': '유효하지 않은 데이터입니다.', 'data': ''}, status=status.HTTP_400_BAD_REQUEST) + + +class DeleteAccountView(generics.GenericAPIView): + permission_classes = [IsAuthenticated] + + + def delete(self, request): + try: + user = request.user + + studentID = user.profile.studentID + withdrawal_reason = request.data.get('withdrawal_reason') + description = request.data.get('description') + + valid_choices = [choice[0] for choice in WithdrawalRecord.REPORT_CHOICES] # choice[0] 각 튜플의 첫 번째 요소 + if withdrawal_reason not in valid_choices: + return Response({'status': status.HTTP_400_BAD_REQUEST, 'message': '유효하지 않은 탈퇴 사유입니다.', 'data': ''}, status = status.HTTP_400_BAD_REQUEST) + + if withdrawal_reason == '기타': + if not description: + return Response({'status': status.HTTP_400_BAD_REQUEST, 'message': '기타 사유를 입력해주세요.', 'data': ''}, status = status.HTTP_400_BAD_REQUEST) + + if WithdrawalRecord.objects.filter(studentID = studentID).exists(): + return Response({'status': status.HTTP_400_BAD_REQUEST, 'message': '중복된 학생 ID가 있어 회원탈퇴를 진행할 수 없습니다.', 'data': ''}, status=status.HTTP_400_BAD_REQUEST) + + # 대여한 우산이 있는지 확인 + rented_umbrella = Rent.objects.filter(user = user, return_date = None).first() + if rented_umbrella: + return Response({'status': status.HTTP_400_BAD_REQUEST, 'message': '우산을 반납하지 않아 탈퇴할 수 없습니다.\n반납 후 다시 진행해 주세요!', 'data': ''}, status = status.HTTP_400_BAD_REQUEST) + + # 회원과 관련된 Umbrella reports 데이터 조회 + umbrella_reports = UmbrellaReport.objects.filter(user = user) + umbrella_reports.update(user = None) + + record_data = {'studentID': studentID, 'withdrawal_reason': withdrawal_reason, 'description': description} + record_serializer = RecordSerializer(data = record_data) + if record_serializer.is_valid(): + record_serializer.save() + + # 회원 탈퇴 + user.delete() + return Response({'status': status.HTTP_200_OK, 'message': '회원 탈퇴가 완료되었습니다.\n우산 대여가 필요하면 다시 찾아주세요!', 'data': ''}, status = status.HTTP_200_OK) + else: + return Response({'status': status.HTTP_400_BAD_REQUEST, 'message': '회원탈퇴 실패', 'data': ''}, status = status.HTTP_400_BAD_REQUEST) + except Exception as e: + logger.error(f'회원탈퇴 오류: {e}', exc_info = True) + return Response({'status': status.HTTP_500_INTERNAL_SERVER_ERROR, 'message': '회원탈퇴 중 오류가 발생했습니다.\n다시 시도해주세요!', 'data': ''}, status = status.HTTP_500_INTERNAL_SERVER_ERROR) \ No newline at end of file From f8dc1c16396775e9dc8e9198df1bb498d8674ecd Mon Sep 17 00:00:00 2001 From: dpfls0922 Date: Sun, 12 May 2024 23:55:28 +0900 Subject: [PATCH 8/9] =?UTF-8?q?[Feat]=20#47=207=EC=9D=BC=EC=9D=B4=20?= =?UTF-8?q?=EC=A7=80=EB=82=9C=20=ED=9A=8C=EC=9B=90=ED=83=88=ED=87=B4=20?= =?UTF-8?q?=EA=B8=B0=EB=A1=9D=20=EC=82=AD=EC=A0=9C=ED=95=98=EB=8A=94=20?= =?UTF-8?q?=EC=9E=91=EC=97=85=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../delete_expired_withdrawal_records.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 home/management/commands/delete_expired_withdrawal_records.py diff --git a/home/management/commands/delete_expired_withdrawal_records.py b/home/management/commands/delete_expired_withdrawal_records.py new file mode 100644 index 0000000..ef599cd --- /dev/null +++ b/home/management/commands/delete_expired_withdrawal_records.py @@ -0,0 +1,17 @@ +from django.core.management.base import BaseCommand +from django.utils import timezone +from users.models import WithdrawalRecord +from datetime import datetime + + +class Command(BaseCommand): + help = '만료된 회원탈퇴 기록 지우기' + + def handle(self, *args, **options): + print("[", datetime.now().strftime("%Y-%m-%d %H:%M:%S"), "]") + try: + expired_records = WithdrawalRecord.objects.filter(expiration_date__lte=timezone.now()) + num_deleted, _ = expired_records.delete() + print(f'{num_deleted} 개의 만료된 회원탈퇴 기록이 삭제되었습니다.') + except Exception as e: + print(f'회원탈퇴 기록 삭제 중 에러 발생: {e}') \ No newline at end of file From c0e514b27db3e2edf348d72295ca8001d3036927 Mon Sep 17 00:00:00 2001 From: dpfls0922 Date: Sun, 12 May 2024 23:58:10 +0900 Subject: [PATCH 9/9] =?UTF-8?q?[Add]=20#47=207=EC=9D=BC=EC=9D=B4=20?= =?UTF-8?q?=EC=A7=80=EB=82=9C=20=ED=9A=8C=EC=9B=90=ED=83=88=ED=87=B4=20?= =?UTF-8?q?=EA=B8=B0=EB=A1=9D=20=EC=82=AD=EC=A0=9C=EB=A5=BC=20crontab?= =?UTF-8?q?=EC=9C=BC=EB=A1=9C=20=EA=B4=80=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- UmbrellaFriend/settings.py | 3 ++- home/cron.py | 7 +++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/UmbrellaFriend/settings.py b/UmbrellaFriend/settings.py index d33a853..8e3b220 100644 --- a/UmbrellaFriend/settings.py +++ b/UmbrellaFriend/settings.py @@ -148,7 +148,8 @@ CRONJOBS = [ - ('0 0 * * *', 'home.cron.send_return_reminder_email', '>> /tmp/scheduled_job.log'), + ('0 0 * * *', 'home.cron.send_return_reminders', '>> /tmp/email_push.log 2>&1'), + ('0 0 * * *', 'home.cron.delete_withdrawal_records', '>> /tmp/delete_withdrawal_record.log 2>&1'), ] diff --git a/home/cron.py b/home/cron.py index aca26cc..c5c9eb4 100644 --- a/home/cron.py +++ b/home/cron.py @@ -1,4 +1,7 @@ from django.core.management import call_command -def send_return_reminder_email(): - call_command('send_return_reminders') \ No newline at end of file +def send_return_reminders(): + call_command('send_return_reminders') + +def delete_withdrawal_records(): + call_command('delete_expired_withdrawal_records') \ No newline at end of file