From 4f128a8a1b0707e442307711474bcc1c22db96cc Mon Sep 17 00:00:00 2001
From: Piotr Gawron <piotr.gawron@uni.lu>
Date: Fri, 1 Jun 2018 16:03:32 +0200
Subject: [PATCH] notification about future voucher expiry date starts 7 days
 before expiry date

---
 smash/web/views/notifications.py | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/smash/web/views/notifications.py b/smash/web/views/notifications.py
index 58e305a6..aa56fe87 100644
--- a/smash/web/views/notifications.py
+++ b/smash/web/views/notifications.py
@@ -171,8 +171,10 @@ def get_subjects_with_no_visit(user):
 
 
 def get_subjects_with_almost_expired_vouchers(user):
-    notification_min_date = get_today_midnight_date() + datetime.timedelta(days=14)
-    contact_attempt_min_date = get_today_midnight_date() - datetime.timedelta(days=14)
+    # if expiry date is in the next 7 days
+    notification_min_date = get_today_midnight_date() + datetime.timedelta(days=7)
+    # if last successful contact was over 7 days ago
+    contact_attempt_min_date = get_today_midnight_date() - datetime.timedelta(days=7)
     result = StudySubject.objects.filter(
         subject__dead=False,
         resigned=False,
-- 
GitLab