1
1
from datetime import timedelta
2
2
3
+ from django .conf import settings
3
4
from django .core .management .base import BaseCommand
4
5
from django .template .loader import render_to_string
5
6
from django .utils import timezone
@@ -21,21 +22,28 @@ class Command(BaseCommand):
21
22
@monitor (monitor_slug = SentryMonitor .NOTIFY_VALIDATORS )
22
23
def handle (self , * args , ** options ):
23
24
self .stdout .write (self .style .NOTICE ("Notifying the validators..." ))
24
-
25
+ # NOTE: In production use standard email notification time(7days/14days),shorter delays(1day/2days) elsewhere for testing
26
+ production = settings .GO_ENVIRONMENT == "production"
27
+ if production :
28
+ regional_email_notification_days = 7
29
+ global_email_notification_days = 14
30
+ else :
31
+ regional_email_notification_days = 1
32
+ global_email_notification_days = 2
25
33
# Regional Validators: 14 days
26
34
queryset_for_regional_validators = LocalUnit .objects .filter (
27
35
status__in = [LocalUnit .Status .UNVALIDATED , LocalUnit .Status .PENDING_EDIT_VALIDATION ],
28
36
is_deprecated = False ,
29
37
last_sent_validator_type = Validator .LOCAL ,
30
- created_at__lte = timezone .now () - timedelta (days = 7 ),
38
+ created_at__lte = timezone .now () - timedelta (days = regional_email_notification_days ),
31
39
)
32
40
33
41
# Global Validators: 28 days
34
42
queryset_for_global_validators = LocalUnit .objects .filter (
35
43
status__in = [LocalUnit .Status .UNVALIDATED , LocalUnit .Status .PENDING_EDIT_VALIDATION ],
36
44
is_deprecated = False ,
37
45
last_sent_validator_type = Validator .REGIONAL ,
38
- created_at__lte = timezone .now () - timedelta (days = 14 ),
46
+ created_at__lte = timezone .now () - timedelta (days = global_email_notification_days ),
39
47
)
40
48
41
49
for local_unit in queryset_for_regional_validators :
0 commit comments