Skip to content

Commit 0b28ce5

Browse files
Merge pull request #2554 from IFRCGo/chore/disable-local-unit-email-notifications
Disable local unit email notification
2 parents 11593bd + 5466994 commit 0b28ce5

File tree

4 files changed

+15
-11
lines changed

4 files changed

+15
-11
lines changed

deploy/helm/ifrcgo-helm/values.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,8 +272,8 @@ cronjobs:
272272
schedule: '0 0 * * 0'
273273
- command: 'ingest_icrc'
274274
schedule: '0 3 * * 0'
275-
- command: 'notify_validators'
276-
schedule: '0 0 * * *'
275+
# - command: 'notify_validators'
276+
# schedule: '0 0 * * *'
277277
# https://github.com/jazzband/django-oauth-toolkit/blob/master/docs/management_commands.rst#cleartokens
278278
- command: 'oauth_cleartokens'
279279
schedule: '0 1 * * *'

local_units/management/commands/notify_validators.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,24 @@
44
from django.core.management.base import BaseCommand
55
from django.template.loader import render_to_string
66
from django.utils import timezone
7-
from sentry_sdk.crons import monitor
87

98
from local_units.models import LocalUnit, Validator
109
from local_units.utils import (
1110
get_email_context,
1211
get_local_unit_global_validators,
1312
get_local_unit_region_validators,
1413
)
15-
from main.sentry import SentryMonitor
14+
15+
# from main.sentry import SentryMonitor
1616
from notifications.notification import send_notification
1717

18+
# from sentry_sdk.crons import monitor
19+
1820

1921
class Command(BaseCommand):
2022
help = "Notify validators for the pending local units in different period of time"
2123

22-
@monitor(monitor_slug=SentryMonitor.NOTIFY_VALIDATORS)
24+
# @monitor(monitor_slug=SentryMonitor.NOTIFY_VALIDATORS) # NOTE: Disabled for now
2325
def handle(self, *args, **options):
2426
self.stdout.write(self.style.NOTICE("Notifying the validators..."))
2527
# NOTE: In production use standard email notification time(7days/14days),shorter delays(1day/2days) elsewhere for testing

local_units/tasks.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
from local_units.bulk_upload import BaseBulkUploadLocalUnit, BulkUploadHealthData
88
from local_units.models import LocalUnit, LocalUnitBulkUpload, LocalUnitChangeRequest
9-
from notifications.notification import send_notification
109

1110
from .utils import (
1211
get_email_context,
@@ -15,6 +14,9 @@
1514
get_local_unit_region_validators,
1615
)
1716

17+
# from notifications.notification import send_notification
18+
19+
1820
User = get_user_model()
1921

2022
logger = logging.getLogger(__name__)
@@ -51,7 +53,7 @@ def send_local_unit_email(local_unit_id: int, new: bool = True):
5153
email_context["validator_email"] = user.email
5254
email_context["full_name"] = user.get_full_name()
5355
email_body = render_to_string("email/local_units/local_unit.html", email_context)
54-
send_notification(email_subject, user.email, email_body, email_type)
56+
print(email_subject, user.email, email_body, email_type) # send_notification
5557

5658

5759
@shared_task
@@ -75,7 +77,7 @@ def send_validate_success_email(local_unit_id: int, message: str = ""):
7577
email_subject = "Your Local Unit Addition Request: Approved"
7678
email_body = render_to_string("email/local_units/local_unit.html", email_context)
7779
email_type = f"{message} Local Unit"
78-
send_notification(email_subject, user.email, email_body, email_type)
80+
print(email_subject, user.email, email_body, email_type) # send_notification
7981
return email_context
8082

8183

@@ -102,7 +104,7 @@ def send_revert_email(local_unit_id: int, change_request_id: int):
102104
email_body = render_to_string("email/local_units/local_unit.html", email_context)
103105
email_type = "Revert Local Unit"
104106

105-
send_notification(email_subject, user.email, email_body, email_type)
107+
print(email_subject, user.email, email_body, email_type) # send_notification
106108
return email_context
107109

108110

@@ -129,7 +131,7 @@ def send_deprecate_email(local_unit_id: int):
129131
email_subject = "Your Local Unit Addition Request: Deprecated"
130132
email_body = render_to_string("email/local_units/local_unit.html", email_context)
131133
email_type = "Deprecate Local Unit"
132-
send_notification(email_subject, user.email, email_body, email_type)
134+
print(email_subject, user.email, email_body, email_type) # send_notification
133135
return email_context
134136

135137

main/sentry.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ class SentryMonitor(models.TextChoices):
128128
INGEST_NS_DOCUMENT = "ingest_ns_document", "0 0 * * 0"
129129
INGEST_NS_INITIATIVES = "ingest_ns_initiatives", "0 0 * * 0"
130130
INGEST_ICRC = "ingest_icrc", "0 3 * * 0"
131-
NOTIFY_VALIDATORS = "notify_validators", "0 0 * * *"
131+
# NOTIFY_VALIDATORS = "notify_validators", "0 0 * * *" # NOTE: Disable local unit email notification for now
132132
OAUTH_CLEARTOKENS = "oauth_cleartokens", "0 1 * * *"
133133

134134
@staticmethod

0 commit comments

Comments
 (0)