From 0f362f2c6199877e3e02e3f5c6984bb7d0f0241b Mon Sep 17 00:00:00 2001 From: Ishaan Mittal Date: Mon, 23 Oct 2023 23:30:31 +0530 Subject: [PATCH] correcting period 4 bills --- home/admin.py | 14 +++++++++++++- home/apps.py | 1 + messWebsite/settings.py | 2 +- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/home/admin.py b/home/admin.py index 6455274..46631ad 100644 --- a/home/admin.py +++ b/home/admin.py @@ -859,8 +859,20 @@ def hostel(self, obj): def room_number(self, obj): return obj.email.room_no - actions = ["export_as_csv"] + actions = ["export_as_csv", "update_bill"] + @admin.action(description="Update the bills") + def update_bill(self, request, queryset): + """ + Update action available in the admin page + """ + for obj in queryset: + days = obj.period4_short + obj.period4_long + if(obj.period4_high_tea): + continue + days = 31 - days + obj.period4_bill = days * 115 + obj.save() def export_as_csv(self, request, queryset): """ Export action available in the admin page diff --git a/home/apps.py b/home/apps.py index a3d281b..4c8a2c0 100644 --- a/home/apps.py +++ b/home/apps.py @@ -12,6 +12,7 @@ class HomeConfig(AppConfig): def ready(self): import home.signals import socket, sys + # bind to port 47200, then check for it for every worker try: sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.bind(("127.0.0.1", 47200)) diff --git a/messWebsite/settings.py b/messWebsite/settings.py index 3423d05..3f480c6 100644 --- a/messWebsite/settings.py +++ b/messWebsite/settings.py @@ -54,7 +54,7 @@ "django.middleware.clickjacking.XFrameOptionsMiddleware", "messWebsite.middleware.LoginRequiredMiddleware", 'whitenoise.middleware.WhiteNoiseMiddleware', - + 'allauth.account.middleware.AccountMiddleware', ] ROOT_URLCONF = "messWebsite.urls"