From 1973af07a143bcf3f67e8fadd5ff98376866749f Mon Sep 17 00:00:00 2001 From: Sander Roosendaal Date: Tue, 16 May 2017 20:16:13 +0200 Subject: [PATCH 1/2] check rowerplan in checkexpired --- rowers/management/commands/getexpired.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rowers/management/commands/getexpired.py b/rowers/management/commands/getexpired.py index 76eefb58..66df22c0 100644 --- a/rowers/management/commands/getexpired.py +++ b/rowers/management/commands/getexpired.py @@ -20,7 +20,8 @@ def getexpired(): lijst = [] for r in rs: if r.planexpires < datetime.datetime.now().date(): - lijst.append(r) + if r.rowerplan == 'pro' or r.rowerplan == 'coach': + lijst.append(r) return lijst From e1ab50d9593ecb79cb58c58d215a07a75b7fb994 Mon Sep 17 00:00:00 2001 From: Sander Roosendaal Date: Tue, 16 May 2017 20:18:03 +0200 Subject: [PATCH 2/2] bug fix --- rowers/management/commands/getexpired.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/rowers/management/commands/getexpired.py b/rowers/management/commands/getexpired.py index 66df22c0..b5b24e41 100644 --- a/rowers/management/commands/getexpired.py +++ b/rowers/management/commands/getexpired.py @@ -29,15 +29,16 @@ class Command(BaseCommand): def handle(self, *args, **options): expiredrowers = getexpired() - fullemail = 'roosendaalsander@gmail.com' - subject = "Expired rowers report" - message = "Dear Sander,\n\n" - message += "Best Regards, the Rowsandall Team" - message += "Expired rowers report\n\n" + if len(expiredrowers) > 0: + fullemail = 'roosendaalsander@gmail.com' + subject = "Expired rowers report" + message = "Dear Sander,\n\n" + message += "Best Regards, the Rowsandall Team" + message += "Expired rowers report\n\n" - for r in expiredrowers: - message += r.user.first_name+" "+r.user.last_name+" "+r.user.username - message += "\n" + for r in expiredrowers: + message += r.user.first_name+" "+r.user.last_name+" "+r.user.username + message += "\n" email = EmailMessage(subject, message, 'Rowsandall ', @@ -45,4 +46,4 @@ class Command(BaseCommand): - res = email.send() + res = email.send()