From 08fffa4c922d9e60a82d5d0b4c29f91eeb3b8af5 Mon Sep 17 00:00:00 2001 From: gzbender Date: Wed, 24 Apr 2019 13:43:01 +0300 Subject: [PATCH] =?UTF-8?q?=D0=BF=D0=B8=D1=81=D1=8C=D0=BC=D0=B0=20=D1=81?= =?UTF-8?q?=20=D0=B3=D1=80=D0=B0=D0=BC=D0=BE=D1=82=D0=B0=D0=BC=D0=B8=20?= =?UTF-8?q?=D0=BE=D1=82=D0=BF=D1=80=D0=B0=D0=B2=D0=BB=D1=8F=D1=8E=D1=82?= =?UTF-8?q?=D1=81=D1=8F=20=D1=81=D0=BB=D0=B8=D1=88=D0=BA=D0=BE=D0=BC=20?= =?UTF-8?q?=D0=BC=D0=BD=D0=BE=D0=B3=D0=B8=D0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/notification/tasks.py | 2 +- apps/payment/models.py | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/apps/notification/tasks.py b/apps/notification/tasks.py index 7430e0b9..f4f42183 100644 --- a/apps/notification/tasks.py +++ b/apps/notification/tasks.py @@ -61,7 +61,7 @@ def send_certificates(email=None, date=None, dry_run=False): date = datetime.strptime(date, '%d-%m-%Y').date() if date else now().date() today = now().date() - users = set(list(SchoolPayment.objects.filter(date_end=date, add_days=False).values_list('user_id', flat=True))) + users = set(list(SchoolPayment.objects.paid().filter(date_end=date, add_days=False).values_list('user_id', flat=True))) user_notifications_qs = UserNotification.objects.filter(user_id__in=users) user_notifications = {un.user_id: un for un in user_notifications_qs} notified_users = user_notifications_qs.filter(certificate_last_email__date=today).values_list( diff --git a/apps/payment/models.py b/apps/payment/models.py index b5baefd9..5b7192ce 100644 --- a/apps/payment/models.py +++ b/apps/payment/models.py @@ -83,6 +83,9 @@ class PaymentManger(PolymorphicManager): def all(self): return self.filter(status__isnull=False) + def paid(self): + return self.filter(status__in=Payment.PW_PAID_STATUSES) + class Payment(PolymorphicModel): PW_PAID_STATUSES = [